In computer science, a semaphore is a protected variable or abstract data type which constitutes a classic method of controlling access by several processes to a common resource in a parallel programming environment. A semaphore generally takes one of two forms: binary and counting. A binary semaphore is a simple "true/false" (locked/unlocked) flag that controls access to a single resource. A counting semaphore is a counter for a set of available...
more
In computer science, a semaphore is a protected variable or abstract data type which constitutes a classic method of controlling access by several processes to a common resource in a parallel programming environment. A semaphore generally takes one of two forms: binary and counting. A binary semaphore is a simple "true/false" (locked/unlocked) flag that controls access to a single resource. A counting semaphore is a counter for a set of available resources. Either semaphore type may be employed to prevent a race condition. On the other hand, a semaphore is of no value in preventing resource deadlock, such as illustrated by the dining philosophers problem.
The semaphore concept was invented by the Dutch computer scientist, Edsger Dijkstra, and has found widespread use in a variety of operating systems.
Assume the "resources" are tables in a restaurant and the "processes" are the restaurant's customers. The "semaphore" is represented by the maître d’hôtel, who has sole responsibility...
less