It is widely accepted concept that when a thread is releasing an object
(e.g. mutex) that another thread is waiting for (blocked), the other
gets unblocked AND takes ownership (lock) of that object.
Consider a situation where there are 3 threads H,M,L with priorities
High,Medium,Low respectively. H has a mutex locked and the other two are
blocked on the same mutex. H releases the mutex and goes to sleep. M
starts to execute and goes through the critical section releasing the
mutex at the end. L gets the ownership of the mutex, although it is not
running as the M is higher priority.
If M tries to lock the mutex again, it will get blocked waiting for L to
finish critical section.
This behavior seems to me to be questionable in RTOS. If you compute a
response time for a thread you really need to add the longest time (T)
it takes to go through critical section (at the priority of your thread)
in your whole system multiplied by number of mutex locks in its path.
If the release operation only unblocks the highest priority thread
waiting for that object and then the unblocked thread has to reacquire
the object at its own (In the above scenario the M does not get blocked
and runs through critical section) the calculation will be different
(1xT + (n-1)xC, where C is longest time to run through critical section
for threads with higher priority then the thread you computing the
response time for)
Is there something I’m missing, are there any other things I didn’t