Test and test-and-set: Difference between revisions

Content deleted Content added
Overlinking fixed
Chgros (talk | contribs)
No edit summary
Line 19:
The entry protocol uses normal memory reads to spin, waiting for the lock to become free. Test-and-set is only used to try to get the lock when normal memory read says its free. Thus the expensive atomic memory operations happens less often than in simple spin around test-and-set.
 
If the [[programming language]] used supports [[Lazy evaluation#Minimal evaluation|minimal evaluation]], the entry protocol could be implemented as:
 
'''procedure''' EnterCritical() {