-
Notifications
You must be signed in to change notification settings - Fork 905
Description
Your RTOS has a decade old design error.
Note first that in ThreadX semaphore Blocked Lists are not sorted and application developers must call tx_semaphore_prioritize() on a semaphore before calling tx_semaphore_put() on it to ensure the highest priority task blocked on it is unblocked.
-
A semaphore has an unsorted Blocked List that contains (in the following order) thread d, thread c, thread b, and thread a. thread a is the highest priority thread in this list and thread b is the second highest one. The rest are lower priority.
-
thread 1 calls tx_semaphore_prioritize() on the semaphore. This places thread a at the head of the semaphore's Blocked List.
-
An interrupt occurs and it's ISR calls tx_semaphore_prioritize() on the semaphore. This does not change the semaphore's Blocked List as the highest priority thread is already at the head.
-
The ISR then calls tx_semaphore_put() on the semaphore and unblocks thread a.
-
thread 1 resumes. thread 1 calls tx_semaphore_put() on the semaphore and unblocks thread d. thread b should have unblocked.
This is an error.
The solution is to provide a tx_semaphore_prioritized_put() function that:
- Disables interrupts
- Prioritizes
- Puts
- Enables interrupts
Metadata
Metadata
Assignees
Labels
Type
Projects
Status