Questions tagged [mutex]
The mutex tag has no summary.
20 questions
-1 votes
0 answers
45 views
Mutex protects client list but does not prevent socket closure in multithreaded C server [closed]
I am implementing a multithreaded C server where clients are stored in a linked list of structs. Each struct contains, among other fields, the socket (sk) for communicating with the client. The list ...
0 votes
1 answer
159 views
Difference between outcome of using mutex/spinlock/semaphore in this deadlock situation?
I'm not sure if my answers to the following exercise is correct: Suppose the program is run with two threads. Further suppose that the following sequence of events occurs: Time Thread 0 ...
6 votes
1 answer
1k views
Specify that a method needs a mutex held when calling
Current situation Right now I have a method like Data lookupData(Key id) { std::lock_guard<std::mutex> lock(m_mutex); auto it = m_dict.find(id); if(it == m_dict.end()) { ...
0 votes
1 answer
1k views
Is a mutex lock always implemented as spin waiting?
Is a mutex lock always implemented as spin waiting? Can a mutex lock be implemented as block waiting? (Operating System Concepts section 5.4 only mentions the implementation by spin waiting. See below....
-1 votes
1 answer
205 views
is there difference between releasing two semaphores in the same or reverse order as they are acquired?
Generally, if two semaphores are acquired one after the other, is there difference between releasing them in the same order or the reverse order as they are acquired? In the following solution to the ...
-2 votes
2 answers
1k views
what would happen if you signal() before wait()?
A bakery shop has to provide a stream of muffins for customers. The muffins are made by a baker in the kitchen and placed on a conveyor belt. The conveyor belt carries the muffins to where the ...
0 votes
0 answers
86 views
Pausing threads calling the same method by making them try to lock an already locked mutex
I am confronted to a question regarding synchronisation between threads having shared data. This is a stripped down versino of my class : class Foo { private: boost::mutex m_mutex; std:vector&...
2 votes
0 answers
199 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 ...