| Digital Puer 2006-10-19, 1:26 am |
| Hi, I keep getting this question on programming interviews
(C++/Java on Linux platforms): In the context of Linux and Posix,
what is the difference between semaphores, mutexes, and
condition variables?
I know the difference in principal from academic textbooks,
but I do not know the practical differences in terms of
the Posix APIs (if that's applicable at all). I BS'ed the
interviewer basically that: semaphores are counting
semaphores; mutexes are binary semaphores; and
condition variables are used for signalling wait/notify
for monitors (such as those in Java) but threads
using monitors do not block on condition variables
but rather on mutexes guarding the condition variables.
Is any of this right?
Some help would be appreciated.
|