Concurrency and Condition Variables


(David Robert Olsen) #1

After successfully implementing condition variables and passing all the tests, I have observed that my implementation does not allow concurrency. Is it possible for there to be Mesa-CV’s that allow concurrency, or am I missing the point?


(Geoffrey Challen) #2

I’m confused. CVs are primarily a signaling mechanism. How do they allow or not allow concurrency?

Put another way: can you provide an example of a case where the semantics of the CV are limited concurrency?


(David Robert Olsen) #3

Nevermind, I just misunderstood what was happening. I was caught up on multiple threads being woken up by cv_broadcast each having to acquire and release the cv’s lock. Once they are woken up and clear the lock they are free.


(Geoffrey Challen) #4

Right. But that’s the semantics of cv_broadcast. You may want to think about why you’d use that versus cv_signal, which only wakes up one thread. (And we’ll go through an example in lecture.)