mutex priority inheritance not transitive (in violation of posix?)

Till Straumann strauman at
Fri Mar 25 18:47:09 UTC 2011

While playing with mutexes (binary semaphores with priority-
inheritance) I found that priority-inheritance is not
transitive, i.e., if there is a chain of tasks (Ti) blocking on
mutexes (Mj)

      M2 > held by > T2 > blocked on > M1 > held by T1

and a high priority thread T3 wants to acquire M2
then priority inheritance lifts T2's priority to
match T3's but this increase of priority is not propagated
on to T1.

While I understand that a implementation of transitive
semantics could be quite costly I believe that the
current limitation should be described in the documentation.

It also seems that the current behavior violates 1003.1

   When a thread is blocking higher priority
   threads because of owning one or more mutexes
   with the PTHREAD_PRIO_INHERIT protocol
   attribute, it shall execute at the higher of
   its priority or the priority of the highest
   priority thread waiting on any of the mutexes
   owned by this thread and initialized with this

While this requirement was fulfilled when T2 tried
to take M1 (priority of T1 was lifted to T2's) it
is no longer met once T3 boosted T2's priority.
At that point T1 is no longer executing at the priority
of the highest priority thread waiting on M1.

-- Till

More information about the users mailing list