Skip to main content
added 158 characters in body
Source Link
Tim
  • 5.6k
  • 7
  • 60
  • 94

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 "wait" and immediately "return" or only "wait"? 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.)

Could someone give a useful example of it?

Thanks.

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"?

Does "locking" a binary semaphore mean "wait" and immediately "return" or only "wait"? (The former is more similar to lock a mutex lock than the latter.)

Could someone give a useful example of it?

Thanks.

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.

Source Link
Tim
  • 5.6k
  • 7
  • 60
  • 94

What is "it is possible for one process to lock a binary semaphore and for another to unlock it" useful for?

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"?

Does "locking" a binary semaphore mean "wait" and immediately "return" or only "wait"? (The former is more similar to lock a mutex lock than the latter.)

Could someone give a useful example of it?

Thanks.