Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Semaphore (programming)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Semaphores vs. mutexes== A [[mutex]] is a [[Mutual exclusion#Types of mutual exclusion devices|locking mechanism]] that sometimes uses the same basic implementation as the binary semaphore. However, they differ in how they are used. While a binary semaphore may be colloquially referred to as a mutex, a true mutex has a more specific use-case and definition, in that only the [[Task (computing)|task]] that locked the mutex is supposed to unlock it. This constraint aims to handle some potential problems of using semaphores: # [[Priority inversion]]: If the mutex knows who locked it and is supposed to unlock it, it is possible to promote the priority of that task whenever a higher-priority task starts waiting on the mutex. # Premature task termination: Mutexes may also provide deletion safety, where the task holding the mutex cannot be accidentally deleted. {{citation needed|date=May 2019}} (This is also a cost; if the mutex can prevent a task from being reclaimed, then a garbage collector has to monitor the mutex.) # Termination deadlock: If a mutex-holding task terminates for any reason, the [[Real-time operating system|OS]] can release the mutex and signal waiting tasks of this condition. # Recursion deadlock: a task is allowed to lock a [[reentrant mutex]] multiple times as it unlocks it an equal number of times. # Accidental release: An error is raised on the release of the mutex if the releasing task is not its owner.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)