Skip to contentSkip to conversation

any fairness in NTPL pthread mutexes?

DISCUSSION Robert Hancock 1 participant 1 message Nov 1, 2005 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 5 lines · Christopher Friesen

I'm using NPTL.

If I have a pthread mutex currently owned by a task, and two other tasks try to lock it, when the mutex is unlocked, are there any rules about the order in which the waiting tasks get the mutex (ie priority, FIFO, etc.)?

Not in the pthread spec (at least not for normal SCHED_OTHER tasks), and Linux/glibc don't really provide any either. In particular, if one thread unlocks a mutex and immediately tries to relock, there is no guarantee that any other thread waiting on the mutex will be able to get in and lock it before the first thread can relock.

Signature · 3 lines
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from [email protected]
Home Page: http://www.roberthancock.com/