Re: Types of mutexes?
Corey Minyard <[email protected]>
| Newsgroups | gmane.linux.ngpt.devel |
|---|---|
| Message-ID | <[email protected]> |
I have numerous comments on this.
* It is true that PROTECT mutexes (or priority ceiling mutexes, by
their more common name) are easier to implement than priority
inheritance mutexes. It is not true that they are lower impact,
if impact means the amount of CPU they use. At least on CPUs with
compare-and-swap, priority inheritance mutexes can be implemented
without a system call on an uncontended access to the mutex.
* The major benefit of priority ceiling mutexes is that they are
deadlock free on a correctly implemented uniprocessor system.
This is not true for multi-processor machines, and this benefit
is kind of meaningless for systems of any complexity because they
are impossible to completely characterize (and thus impossible to
correctly implement).
* To correctly use priority ceiling mutexes, you must know the
highest priority thread that will claim the mutex (including
priorities that were boosted by claiming other mutexes). The
complexity of determining this grows exponentially with the size
of the application. People will not want to do this on things
like, say, telephone switches.
* Some high-use mutexes (say, the memory allocation mutex in a Java
VM) will be used by basically all threads, and thus must have
their ceiling set to the highest priority thread in the system (if
you have access to the mutexes at all). It is possible to make
every mutex in the system priority inheriting and the system
safely function.
IMO, in general, priority ceiling mutexes are good for hard real-time
system with limited complexity. Priority inheritance mutexes are good
for complex soft real-time systems. (If you have to build a complex
hard real-time system, you have my sympathy :-). I'm guessing that most
users will be in the complex soft real-time category, so I think it
makes more sense to provide priority inheritance mutexes. Actually
priority ceiling is so easy to implement that it makes sense to provide
both.
BTW, I have an implementation of priority inheritance using
compare-and-swap that doesn't do a system call on an uncontested access.
It's at http://ssthreads.sf.net, if you are interested.
-Corey
Perez-Gonzalez, Inaky wrote:
>Hi All
>
>We are studying what types of POSIX mutexes to implement, out of PROTECTION
>and PRIORITY_INHERITANCE; being PROTECTION much more simpler, and
>INHERITANCE kind of difficult and with a high footprint/impact, I'd like to
>ask everybody if they have a _huge_ desperate need for INHERITANCE, and what
>is the need they envision for it or usage they have seen.
>
>Thanks :)
>_______________________________________________
>pthreads-devel mailing list
>[email protected]
>http://www-124.ibm.com/developerworks/oss/mailman/listinfo/pthreads-devel
>
>