Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [mutex]

The tag has no usage guidance.

0
votes
1answer
76 views

Multithreading - 2 active running threads calling each other without blocking itself

I have an implemented UDP receiver which is continuously receiving DTN packets (UDP encapsulated) and performing some operations on them. This whole process is working on a single main thread. However ...
2
votes
0answers
58 views

Testing an algorithm for safety in mutual exclusion

I am attempting to write a code to test Lamport's Mutual Exclusion algorithm for safety as a correctness measure. I am running the alogrithm on a single core cpu machine with multiple processes ...
3
votes
0answers
46 views

Release Phase in Lamport's Mutual Exclusion Algorithm

I was studying Lamport's mutual exclusion algorithm from the original paper, and noticed a difference in the release phase to the one given in Wikipedia. In the original paper, author states that : ...
3
votes
1answer
193 views

Simple solution for calling a function only on one thread, queuing waiting calls?

Let’s assume there is a function EventHandler that is called on multiple threads at different points in time. EventHandler has to call SomeOtherFunction, but these calls shall only happen on one ...
12
votes
2answers
573 views

How to test and benchmark mutex implementations

As the title says: How do you properly test and benchmark different implementations of mutexes in c++? Essentially I wrote my own std::mutex like class for a project running on a 2 core, armv7 with ...
1
vote
1answer
387 views

Small Mutex Implementation?

The relatively large size of std::mutex on different platforms (e.g. 40 or even 80 bytes) is often explained as ensuring the mutexes don't occupy the same cache-lines and so don't incur logically ...
5
votes
2answers
2k views

Mutex vs Semaphore: How to implement them _not_ in terms of the other?

Recently I had to implement a Semaphore using a Mutex and a Conditional Variable (this combination is also known as a Monitor) for an exercise at the university: the Semaphore's decrement operation ...