Semaphores for Synchronization in Operating Systems
Classified in Computers
Written on in
English with a size of 3.35 KB
Semaphores: Synchronization Tool
Semaphores are a synchronization tool designed to solve critical section and synchronization problems. A semaphore is an integer variable accessed only through two atomic operations: Wait and Signal. When a process modifies the semaphore's value, no other process can simultaneously modify that same semaphore value. The semaphore is initialized to a non-negative value.
Wait and Signal Operations
- Wait (P): Decrements the semaphore's value. If the value becomes negative, the process is blocked.
- Signal (V): Increments the semaphore's value. If the value is not positive, a blocked process waiting on this semaphore is unblocked.
The definitions are:
P(s):
while (s <= 0)
s--;
V(s):
s++;
Operating System Usage
Operating... Continue reading "Semaphores for Synchronization in Operating Systems" »