Closed skliper closed 10 months ago
I'll add functional test cases (including #1411).
Note the current bin sem tests and count sem tests are very old and miss a few things (flush of a binary sem timed wait, any counting sem flush tests, all polling tests). Considering rewrite.
New logic under consideration:
Note RTEMS OS_BinSemGetInfo_Impl
and OS_CountSemGetInfo_Impl
should return OS_ERR_NOT_IMPLEMENTED
or could lead to unexpected results:
https://github.com/nasa/osal/blob/1a8823f2dc93da2bcb3696c92c7aee4f512ed4f7/src/os/rtems/src/os-impl-binsem.c#L275-L279
https://github.com/nasa/osal/blob/1a8823f2dc93da2bcb3696c92c7aee4f512ed4f7/src/os/rtems/src/os-impl-countsem.c#L239-L243
Note - updated title and text since there is no flush API for a counting semaphore.
Describe the bug
RTEMS_UNSATISFIED
is returned with flushed, or when called withRTEMS_NO_WAIT
and semaphore isn't available.Current RTEMS implementation doesn't return the expected OS status for all cases (or match Linux/VxWorks behavior).
Expected handling:
OS_BinSemTake_Impl
- flush or success returnsOS_SUCCESS
https://github.com/nasa/osal/blob/edede38d8cf629fa4490b65dc674ad17b11b1050/src/os/rtems/src/os-impl-binsem.c#L210-L216Broken:
OS_BinSemTimedWait_Impl
- flush, success, or when called withRTEMS_NO_WAIT
and semaphore isn't available returnsOS_SUCCESS
(BAD!), should returnOS_SEM_TIMEOUT
for the last case https://github.com/nasa/osal/blob/edede38d8cf629fa4490b65dc674ad17b11b1050/src/os/rtems/src/os-impl-binsem.c#L252-L266OS_CountSemTimedWait_Impl
-RTEMS_NO_WAIT
and semaphore not available returnsOS_SEM_FAILURE
(BAD!), should beOS_SEM_TIMEOUT
when not available https://github.com/nasa/osal/blob/edede38d8cf629fa4490b65dc674ad17b11b1050/src/os/rtems/src/os-impl-countsem.c#L217-L230To Reproduce Started investigating when CF reported the timed wait OS_DEBUG message on RTEMS when a semaphore wasn't available, the rest was inspection.
Expected behavior Return
OS_SEM_TIMEOUT
when status isRTEMS_UNSATISFIED
withRTEMS_NO_WAIT
. https://github.com/nasa/osal/blob/edede38d8cf629fa4490b65dc674ad17b11b1050/src/os/rtems/src/os-impl-binsem.c#L252-L266 https://github.com/nasa/osal/blob/edede38d8cf629fa4490b65dc674ad17b11b1050/src/os/rtems/src/os-impl-countsem.c#L217-L230Code snips See above.
System observed on:
Additional context Should add functional tests for this and confirm Linux/VxWorks/RTEMS behavior is consistent.
Reporter Info Jacob Hageman - NASA/GSFC