Skip to content
Commit 3e13ed24 authored by Gregory Nutt's avatar Gregory Nutt
Browse files

Within the OS, when a thread obtains a semaphore count it must call...

Within the OS, when a thread obtains a semaphore count it must call sem_addholder() if CONFIG_PRIORITY_INHERITANCE is enabled.  If a count is available, then sem_wait() calls sem_addholder(), otherwise it waited for the semaphore and called sem_addholder() when it eventually received the count.

This caused a problem when the thread calling sem_wait() was very low priority.  When it received the count, there may be higher priority threads "hogging" the CPU that prevent the lower priority task from running and, as a result, the sem_addholder() may be delayed indefinitely.

The fix was to have sem_post() call sem_addholder() just before restarting the thread waiting for the semaphore count.

This problem was noted by Benix Vincent who also suggested the solution.
parent 6acc831e
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment