What are Semaphores?
Semaphores are IPC mechanism which allow different processes to synchronize their access to certain resources.
Semaphores in Linux
The simplest kind of semaphores is called a binary semaphore and they have two states ( locked or unlocked ).
These act like traffic lights, which allows certain processes to exclusively access certain resources. When a process wants exclusive access to a resource, example: shared memory, they attempt to lock the semaphore associated with that resource. If the semaphore they are attempting to lock is already locked, the caller is suspended, otherwise they are granted to lock.
When the process completes the task, it unlock the resource and any processes that have attempted to lock that semaphore in the meantime are woken up again to attempt the lock again. This way only one process can have access to the resource at once.
In addition, semaphores can also be used as a signaling mechanism.
Related posts:
- Introduction to Linux
- Difference between Linux and Windows
- Linux Directory Structure
- Linux Basic Commands
- Linux File Permissions
- Linux Server Administration Commands
- Linux Advanced File Permissions
- Semaphores in Linux
- Linux Commands A
- Linux Commands B
- Linux Commands C
- Linux Commands D
- Linux Commands E
- Linux Commands F
- Linux Commands G
- Linux Commands H
- Linux Commands I
- Linux Commands J
- Linux Commands K
- Linux Commands L
- Linux Commands M
- Linux Commands N
- Linux Commands O
- Linux Commands P
- Linux Commands Q
- Linux Commands R
- Linux Commands S
- Linux Commands T
- Linux Commands U
- Linux Commands V
- Linux Commands W
- Linux Commands X
- Linux Commands Y
- Linux Commands Z
Your IP address1 is: 172.18.0.2
Tutorials
Latest Updates
Follow us
- Tech-Tutorials twitter.com/techcuriosity