[WEBINAR] The New Normal: Dealing with the Reality of an Unsecure World


Definition - What does Semaphore mean?

A semaphore is a synchronization object that controls access by multiple processes to a common resource in a parallel programming environment. Semaphores are widely used to control access to files and shared memory. The three basic functionalities associated with semaphores are set, check and wait until it clears to set it again. |

Semaphores are used to address benchmark synchronization problems.

The concept of semaphore was put forth by the Dutch computer scientist Edsger Dijkstra.

Techopedia explains Semaphore

Semaphores are non-negative integer values that support the operations semaphore->P () and semaphore->V (). P is an atomic operation that waits for a semaphore to be positive and then decrements it by one, while V is an atomic operation that increments a semaphore by one, which implies it wakes up a waiting P. Test and set associated with semaphore are routines implemented in hardware to coordinate lower-level critical sections.

Semaphores are normally implemented using file descriptors. Semaphore creations are not atomic. If two processes try to create, initialize and use a semaphore at the same time, a race condition is created. Semaphores are created and initialized to a positive value to show the availability of a resource to be used. Semaphores can be implemented through interrupts or by using test-set operations.

Every semaphore maintains sets of permits. It restricts the number of threads accessing the resources. Semaphores with only one permit and initialized to one serve as mutual exclusion locks. They are referred to as such because they have only two states: permit available or zero permit available. This encloses the property so that a lock can be released by a thread other than the owner, helping in deadlock recovery. Semaphores are used for mutual exclusions where the semaphore has an initial value of one, and P () and V () are called before and after the critical sections.

Techopedia Deals

Connect with us

Techopedia on Linkedin
Techopedia on Linkedin
"Techopedia" on Twitter

Sign up for Techopedia's Free Newsletter!

Email Newsletter

Join thousands of others with our weekly newsletter

Free Whitepaper: The Path to Hybrid Cloud
Free Whitepaper: The Path to Hybrid Cloud:
The Path to Hybrid Cloud: Intelligent Bursting To Amazon Web Services & Microsoft Azure
Free E-Book: Public Cloud Guide
Free E-Book: Public Cloud Guide:
This white paper is for leaders of Operations, Engineering, or Infrastructure teams who are creating or executing an IT roadmap.
Free Tool: Virtual Health Monitor
Free Tool: Virtual Health Monitor:
Virtual Health Monitor is a free virtualization monitoring and reporting tool for VMware, Hyper-V, RHEV, and XenServer environments.
Free 30 Day Trial – Turbonomic
Free 30 Day Trial – Turbonomic:
Turbonomic delivers an autonomic platform where virtual and cloud environments self-manage in real-time to assure application performance.