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

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 625006
To read all comments associated with this story, please click here.
RE[3]: Mutex behavior
by Alfman on Fri 19th Feb 2016 07:09 UTC in reply to "RE[2]: Mutex behavior"
Alfman
Member since:
2011-01-28

elahav,

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?



Oh sorry, you were talking about my other example.
Yes a pthread condition variable might work there, there are many options really.


AFAIK pthread condition variables only support mutex synchronization which can potentially block the sender when it needs to change the predicate condition variable. The block would only be momentary, but with asynchronous programming the main thread should not enter a wait state to wait on locks in other threads - it goes against the design. I felt a spinlock was the best choice here to protect the thread data queue. Both linux eventfd and semaphores (and even pipes) allow us to send events without risk of putting the main thread in a blocked state.

Reply Parent Score: 2