Here are some discussions about mutex (lock) and binary semaphore from two OS books.
Stalling's Operating Systems book says
A concept related to the binary semaphore is the 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.
What does the first book mean by "it is possible for one process to lock a binary semaphore and for another to unlock it"? Could someone give a useful example of it?
Does "locking" a binary semaphore mean calling "wait()"
- with immediately returning (because the binary semaphore originally had value 1) or
- without immediate returning (because the binary semaphore originally had value 0)?
(The former is more similar to lock a mutex lock than the latter.)
Thanks.