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
Reentrant mutex
(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 emulation == Software emulation can be accomplished{{Clarify|date=May 2019}} using the following structure:{{Citation needed|date=July 2015}} * A "control" [[Condition variable|condition]] using a regular lock * Owner identifier, unique to each thread (defaulting to empty / not set) * Acquisition count (defaulting to zero) === Acquisition === # Acquire the control condition. # If the owner is set and not the current thread, wait for the control condition to be notified (this also releases the condition). # Set the owner to the current thread. The owner identifier should have already been cleared at this point unless the acquirer is already the owner. # Increment the acquisition count (should always result in 1 for new owners). # Release the control condition. === Release === # Acquire the control condition, asserting that the owner is the releaser. # Decrement the acquisition count, asserting that the count is greater than or equal to zero. # If the acquisition count is zero, clear the owner information and notify the control condition. # Release the control condition.
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)