Since the wait and signal operations on semaphores and on condition variables are similar, to help you distinguish their differences and use them correctly, the following is a brief comparison.
|Can be used anywhere in a program, but should not be used in a monitor||Can only be used in monitors|
|Wait() does not always block the caller (i.e., when the semaphore counter is greater than zero).||Wait() always blocks the caller.|
|Signal() either releases a blocked thread, if there is one, or increases the semaphore counter.||Signal() either releases a blocked thread, if there is one, or the signal is lost as if it never happens.|
|If Signal() releases a blocked thread, the caller and the released thread both continue.||If Signal() releases a blocked thread, the caller yields the monitor (Hoare type) or continues (Mesa Type). Only one of the caller or the released thread can continue, but not both.|