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.

Thread beginning with comment 625161
To read all comments associated with this story, please click here.
What if?
by flyingrobots on Mon 22nd Feb 2016 20:36 UTC
Member since:

What if I told you that for most cases you don't need them? Would you believe me? What if I also told you would see dramatic increases in performance for those areas of code that had high levels of contention?

QNX only....

Reply Score: 1

RE: What if?
by elahav on Tue 23rd Feb 2016 14:36 in reply to "What if?"
elahav Member since:

It's hard to say, because you haven't provided any details.
In general, there are a few ways to avoid or reduce the use of mutexes, but, as far as I know, there is always a trade-off:
1. Avoid data sharing, e.g., with a pure event-driven design or by a strict assignment of tasks to threads. While I often go for such a design myself, it does restrict parallelism, and therefore does not scale well with the number of processors.
2. Solve the data-sharing problem with lock-free data structures or read-modify-write schemes. These are typically harder to implement and are not always applicable.

Nevertheless, the issue is a moot one as far as the article goes: 99% of the multi-threaded code out there uses mutexes, which means that the OS must support this mechanism.

Reply Parent Score: 1