Re: any fairness in NTPL pthread mutexes?

From: Robert Hancock
Date: Mon Oct 31 2005 - 22:53:01 EST


Christopher Friesen wrote:

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.

--
Robert Hancock Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@xxxxxxxxxxxxx
Home Page: http://www.roberthancock.com/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/