Posted by : Sushanth Tuesday, 15 December 2015

Binary Semaphore
A binary semaphore may only take on the values 0 and 1 and can be defined by the following three operations:
1.A binary semaphore may be initialized to 0 or 1.
2.The semWaitB operation checks the semaphore value. If the value is zero, then
the process executing the semWaitB is blocked. If the value is one, then the
value is changed to zero and the process continues execution.
3.The semSignalB operation checks to see if any processes are blocked on this
semaphore (semaphore value equals zero). If so, then a process blocked by a
semWaitB operation is unblocked. If no processes are blocked, then the value
of the semaphore is set to one.
Definition:




Example:



Binary Semaphore Vs Mutex:
A key difference between the two is that the process that locks the mutex (sets the value to zero) must be the one to unlock it (sets the value to 1). In contrast, it is possible for one process to lock a binary semaphore and for another to unlock it.

Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © Technical Articles - Skyblue - Powered by Blogger - Designed by Johanes Djogan -