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
Mutual exclusion
(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!
===Software solutions=== In addition to hardware-supported solutions, some software solutions exist that use [[busy waiting]] to achieve mutual exclusion. Examples include: * [[Dekker's algorithm]] * [[Peterson's algorithm]] * [[Lamport's bakery algorithm]]<ref>{{cite journal|last=Lamport|first=Leslie|title=A new solution of Dijkstra's concurrent programming problem|journal=Communications of the ACM|date=August 1974|volume=17|issue=8|pages=453–455|doi=10.1145/361082.361093|s2cid=8736023|doi-access=free}}</ref> * [[Szymański's algorithm]] * Taubenfeld's black-white bakery algorithm<ref name="Taubenfeld:2004" /> * [[Maekawa's algorithm]] These algorithms do not work if [[out-of-order execution]] is used on the platform that executes them. Programmers have to specify strict ordering on the memory operations within a thread.<ref>{{cite journal|last=Holzmann|first=Gerard J.|author2=Bosnacki, Dragan|title=The Design of a Multicore Extension of the SPIN Model Checker|journal=IEEE Transactions on Software Engineering|date=1 October 2007|volume=33|issue=10|pages=659–674|doi=10.1109/TSE.2007.70724|s2cid=9080331|url=https://pure.tue.nl/ws/files/2357048/Metis212904.pdf |archive-url=https://ghostarchive.org/archive/20221009/https://pure.tue.nl/ws/files/2357048/Metis212904.pdf |archive-date=2022-10-09 |url-status=live}}</ref> It is often preferable to use synchronization facilities provided by an [[operating system]]'s multithreading library, which will take advantage of hardware solutions if possible but will use software solutions if no hardware solutions exist. For example, when the operating system's [[lock (computer science)|lock]] library is used and a thread tries to acquire an already acquired lock, the operating system could suspend the thread using a [[context switch]] and swap it out with another thread that is ready to be run, or could put that processor into a low power state if there is no other thread that can be run. Therefore, most modern mutual exclusion methods attempt to reduce [[Latency (engineering)|latency]] and busy-waits by using queuing and context switches. However, if the time that is spent suspending a thread and then restoring it can be proven to be always more than the time that must be waited for a thread to become ready to run after being blocked in a particular situation, then [[spinlock]]s are an acceptable solution (for that situation only).{{citation needed|date=August 2015}}
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)