Skip to content

Decade Old Design Error #507

@arakji

Description

@arakji

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.

  1. 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.

  2. thread 1 calls tx_semaphore_prioritize() on the semaphore. This places thread a at the head of the semaphore's Blocked List.

  3. 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.

  4. The ISR then calls tx_semaphore_put() on the semaphore and unblocks thread a.

  5. 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:

  1. Disables interrupts
  2. Prioritizes
  3. Puts
  4. Enables interrupts

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Discussion

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions