1

I don't really get the difference between semaphores and condition variables...

What can be used with threads and what can't, when should I use what?

AX2
  • 135
  • 12
  • 1
    Take a look at: http://stackoverflow.com/questions/3513045/conditional-variable-vs-semaphore – InterruptedException Nov 09 '14 at 17:36
  • I'd probably read about semaphores again. They are different enough where confusion of the differences isn't likely. Maybe take a moment to ponder how processes are scheduled and why that could be a problem using a condition mechanism for critical code sections. – ChiefTwoPencils Nov 09 '14 at 19:45

1 Answers1

1

In windows semaphores are used for inter-process thread synchronization. Whereas, on the other hand condition variable can only be used for thread synchronization in a process. Visit this link for information on some thread synchronization techniques used in windows:

http://www.codeproject.com/Articles/7953/Thread-Synchronization-for-Beginners

Also, condition variables are atomic in nature. If you are a windows programmer, you can use critical sections for thread synchronization in a process.