Search code examples
mutexkeilrtxpriority-inversion

Keil RTX priority inheritance with os_mut_wait and short timeout?


Priority Inheritance is a feature of Keil RTX (and others) to prevent priority inversion. If a high priority task is trying to obtain the mutex already obtained by a low level task, priority inheritance would normally cause the low level task to be assigned the high priority task's priority to allow it run to unlock.

For how long does the low priority task run at the higher priority?

If the high priority task is waiting a long time I would expect the low priority task to run at high priority until the resource is released. If the high priority task is configured to wait a short time does the low priority task revert to its low priority after that time?

In particular if the timeout is 0, does priority inheritance come into effect at all?


Solution

  • In Keil RTX at least, the low priority task runs at high priority until it releases the resource even if the high priority task is configured to wait a short time, and with no timeout the low priority task is not bumped up to the high priority.

    I would be interested to know what other RTOSs do.