Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1406, Squash RTEMS sem take timeout bug #1408

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/os/rtems/src/os-impl-binsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ int32 OS_BinSemTake_Impl(const OS_object_token_t *token)
int32 OS_BinSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs)
{
rtems_status_code status;
rtems_option option_set;
int TimeInTicks;
OS_impl_binsem_internal_record_t *impl;

Expand All @@ -235,7 +236,20 @@ int32 OS_BinSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs)
return OS_ERROR;
}

status = rtems_semaphore_obtain(impl->id, RTEMS_WAIT, TimeInTicks);
/* Select appropriate option to wait or not
* - RTEMS_WAIT with 0 timeout causes RTEMS to wait forever
* - RTEMS_NO_WAIT returns immediately (ignores TimeInTicks)
*/
if (TimeInTicks == 0)
{
option_set = RTEMS_NO_WAIT;
}
else
{
option_set = RTEMS_WAIT;
}

status = rtems_semaphore_obtain(impl->id, option_set, TimeInTicks);

if (status == RTEMS_TIMEOUT)
{
Expand Down
17 changes: 16 additions & 1 deletion src/os/rtems/src/os-impl-countsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ int32 OS_CountSemTake_Impl(const OS_object_token_t *token)
int32 OS_CountSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs)
{
rtems_status_code status;
rtems_option option_set;
int TimeInTicks;
OS_impl_countsem_internal_record_t *impl;

Expand All @@ -200,7 +201,21 @@ int32 OS_CountSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs)
return OS_ERROR;
}

status = rtems_semaphore_obtain(impl->id, RTEMS_WAIT, TimeInTicks);
/* Select appropriate option to wait or not
* - RTEMS_WAIT with 0 timeout causes RTEMS to wait forever
* - RTEMS_NO_WAIT returns immediately (ignores TimeInTicks)
*/
if (TimeInTicks == 0)
{
option_set = RTEMS_NO_WAIT;
}
else
{
option_set = RTEMS_WAIT;
}

status = rtems_semaphore_obtain(impl->id, option_set, TimeInTicks);

if (status == RTEMS_TIMEOUT)
{
return OS_SEM_TIMEOUT;
Expand Down