View Full Version : Difference Between Mutex and Binary Semaphore
aurobind
05-18-2005, 11:40 AM
Hi,
Please tell me the differences between mutex and binary semaphores.
If possible, pls give the scenarios where a mutex and binary semaphore are used.
Thanks
vikas
05-18-2005, 12:36 PM
hmm ... kind of offtopic ( try to search 4 it in a OS book )
rohitd
11-16-2005, 12:11 PM
accocrding to me a mutex is a binary lock which can be acquired only once , it has the capability to handle the Priority inversion, while semaphore may be of incrementng or decrimenting and ca be acuired by more than 2 task at the same time while mutex cant be taken by more than 2 tasks
rohitd
saurabhg84
10-15-2007, 07:08 PM
Its hard to figure out the difference between mutex and a binary semaphore till you get into the implementation details of both these.
Basically, a mutex attribute (structure) will have a field called ownership information, i.e.: the PID (process ID) of the process which is waiting on it, whereas binary semaphore implementation lacks ownership information.
This means that if there are 2 processes 'A' & 'B' sharing a mutex and if 'A' locks (waits on) the mutex, only A will be able to release the mutex, whereas if it would have been a binary semaphore, even process 'B' can accidentally release (signal) the mutex.
Apart from this, mutex is heavy weight and binary semaphore is light weight (speaking in UNIX lingo)...
Powered by vBulletin® Version 4.2.0 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.