mutexsemaphorertosucospriority-inversion

semaphore priority inversion


Why do RTOSes not have any implementation to prevent priority inversion for semaphore even though it exists for mutex.

Semaphores do not need to prevent priority inversion?

The same situation happens both on uC/OS and GreenHills RTOS.

Thanks in advance.


Solution

  • Priority inversion occurs when a low-priority task owns a semaphore, and a high-priority task is forced to wait on the semaphore until the low-priority task releases it. If, prior to releasing the semaphore, the low priority task is preempted by one or more mid-priority tasks, then unbounded priority inversion has occurred because the delay of the high-priority task is no longer predictable. This defeats Deadline Monotonic Analysis (DMA) because it is not possible to predict if the high-priority task will meet its deadline.

    Sharing a critical resource between high and low priority tasks is not a desirable design practice. It is better to share a resource only among equal priority tasks or to limit resource accesses to a single resource server task. Examples are a print server task and a file server task. We have long advocated this practice. However, with the layering of increasingly diverse and complicated middleware onto RTOSs, it is becoming impractical to enforce such simple strategies. Hence, in the interest of safety, it is best to implement some method of preventing unbounded priority inversion.

    Check full link at http://www.smxrtos.com/articles/techppr/mutex.htm

    Regards,

    Otacon