Christof.Meerwald@ posix_sync.notes

> notes
>> posix sync

translate to German (by SYSTRAN)

POSIX Synchronisation


In the uncontended case a mutex can be acquired entirely in user-space.


When a contended mutex needs to be acquired, some implementations (Solaris and HP-UX, but not Linux) try to spin for some time in user-space on SMP systems to try to avoid using potentially costly kernel synchronisation primitives. Particularly HP-UX tries very hard and even repeatedly calls sched_yield before finally resorting to ksleep.

Condition Variable


A straightforward implementation of pthread_cond_broadcast (one that wakes up all waiters at once) can be quite inefficient as all waiters will usually have to contend for the mutex associated with the condition variable (HP-UX is known to be implemented that way).

If the notifying thread owns the mutex (which is not mandated by the POSIX specification) can queue the waiting threads to be woken up one by one when the mutex is unlocked (and thus avoiding contention).



This Web page is licensed under the Creative Commons Attribution - NonCommercial - Share Alike License. Any use is subject to the Privacy Policy.

Revision: 1.1, cmeerw.org/notes/posix_sync.html
Last modified: Sun Aug 12 11:31:36 2007
Christof Meerwald <cmeerw@cmeerw.org>
XMPP: cmeerw@cmeerw.org