Linked by Elad Lahav on Thu 18th Feb 2016 19:27 UTC

A mutex is a common type of lock used to serialize concurrent access by multiple threads to shared resources. While support for POSIX mutexes in the QNX Neutrino Realtime OS dates back to the early days of the system, this area of the code has seen considerable changes in the last couple of years.

Permalink for comment 624996
To read all comments associated with this story, please click here.
RE: Mutex behavior
by elahav on Fri 19th Feb 2016 01:27 UTC in reply to "Mutex behavior"
Member since:

If you are waiting on an event that can be generated by any, or even multiple, threads, then semaphores are not what you are looking for. Perhaps a condition variable?

Also, note that semaphores and mutexes, while sometimes confused for one another, achieve completely different tasks: the first are a synchronization (i.e., temporal) mechanism, the second a data-protection (i.e., spacial) mechanism. Search for "Concurrent Urban Legends" by Peter Buhr and Ashif Harji.

Interestingly, your original goal, that of explicitly handing over a mutex from one thread to another without releasing it is something that has come up several times in the past. It's not hard to implement, I'm just not sure that the semantics of such an operation are fully understood.

Reply Parent Score: 1