Semaphores are very close to the core of every operating system. When you want to use concurrency, they are a valuable tool. They control, as in traffic, the access of several "consumers" to the same "resources".
For example, suppose you want to write to a log file from different applications, you can use an application that, using semaphores, stops or allows another to write to this file. Thus, each application first polled the semaphore application, and if it is enabled, then write to the file.
If you need more information / examples, see here:
http://www.experiencefestival.com/semaphore_programming_-_c_semaphore
Semaphores and concurrent programming
http://programmingexamples.wikidot.com/java-semaphore
Hope this helps,
source
share