Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you implement a condition variable using semaphores?

A while back I was thinking about how to implement various synchronization primitives in terms of one another. For example, in pthreads you get mutexes and condition variables, and from these can build semaphores.

In the Windows API (or at least, older versions of the Windows API) there are mutexes and semaphores, but no condition variables. I think that it should be possible to build condition variables out of mutexes and semaphores, but for the life of me I just can't think of a way to do so.

Does anyone know of a good construction for doing this?

like image 608
templatetypedef Avatar asked Mar 19 '11 20:03

templatetypedef


1 Answers

Here's a paper from Microsoft Research [pdf] which deals with exactly that.

like image 107
Martin DeMello Avatar answered Sep 30 '22 13:09

Martin DeMello