Parallel programming - Semaphore

> (Data|State) Management and Processing > (Concurrency | Parallel | Asynchronous) programming

1 - About

In computer science, a semaphore is a variable or abstract data type that provides a simple but useful abstraction for controlling access by multiple processes to a common resource in a parallel programming environment. Semaphores are often used to restrict the number of threads than can access some (physical or logical) resource.

Semaphores are data structures that are used for synchronization between two or more processes.

Basically they can be viewed as a single integer that represents the amount of resources available. When a process wants a resource, it checks the value of the semaphore, and if it's non-zero, it decrements it in accordance with the amount of resources it wishes to use. The kernel of the operating system will block the process if the semaphore is zero or doesn't have a value high enough for the decrement.

Concurrency - Lock ?


3 - Documentation / Reference