Semaphores
A semaphore is an integer variable with two atomic operations: wait and signal. Other names for wait are down, P, and lock. Other names for signal are up, V, unlock, and post.
A process that executes a wait on a semaphore variable S cannot proceed until the value of S is positive. It then decrements the value of S. The signal operation increments the value of the semaphore variable.
Some (flawed) pseudocode:
void wait( int *s ) void signal( int *s )
{ {
while( *s <= 0 ) ; (*s)++;
(*s)--; }
}