Hi,
I’ve tried to find the answer to this question both here and by reading the code, but still I’m not sure.
Consider the following theoretical scenario,
We have three tasks t1, t2 and t3, t3 being the one with highest prio, t1 lowest.
-
t1 executes and successfully takes a mutex
-
t2 executes and blocks waiting on a semaphore that will at some point be “given” from an ISR.
-
t1 executes and blocks waiting on the same semaphore as t2. At this point t2 with its higher priority would get the semaphore when the ISR gives it. This is, as far as I understand, due to a queue/list both t1 and t2 are put on, a queue/list “owned” by the semaphore.
-
t3 executes and tries to get the same mutex t1 took in step 1 above. t3 blocks, and t1 will get hoisted priority due to priority inheritance, but is still blocked since it waits for the semaphore.
-
The ISR gives the semaphore both t1 and t2 is waiting for.
Who will get the semaphore t1 or t2 ? At this point t1 has highest priority, but at the time t1 started waiting for the semaphore t2 had the highest priority.
As far as I can see, priority inheritance is not applied “retroactively”, meaning, t2 would get the semaphore even though t1 at the point of time the semaphore is given from ISR has higher prio.
I do not consider this a bug, I just want to know. My gut-feeling is that it would be very cumbersome to look for other resources t1 is holding at the time t3 wants to acquire the mutex, and re-calculate the priority list in the semaphore.
Do I understand it correctly, or is there some kind of mechanism that will apply priority inheritance “retroactively” ?
br H