Semaphore
A semaphore is a protected variable or abstract data type that constitutes a constitutes a classic method of controlling access by several processes to a common resource in a parallel programming environment. It generally takes one or two forms: binary and counting. A binary semaphore is a simple true and false that controls access to single resource.
There is one Pascal example is defined below
procedure V (S : Semaphore);
begin (* Atomic operation: increment the semaphore. *) S := S + 1; end; (* Atomic operation: decrement the semaphore. *) procedure P (S : Semaphore); begin (* Whole operation is atomic *) repeat Wait(); until S > 0; S := S - 1; end;Reference
Treese, GW & Stewart, LC 2003, Designing systems for Internet commerce, 2nd edn, Addison-Wesley, Boston, MA.

