Szymański's algorithm: Difference between revisions

Content deleted Content added
Petelomax (talk | contribs)
Wherrera (talk | contribs)
m remove dup typo
Line 1:
{{draft task}}
 
<em>Szymański's algorithm</em> is a is a mutual exclusion algorithm devised by computer scientist Bolesław Szymański.
 
The algorithm allows mutiple processes or tasks to access a serial resource without conflict, using only linear waiting times.
Line 24:
"""
 
using ThreadSafeDicts # implement a single lock on all threadthreads's shared values as a lockable Dict (keyed by thread id)
 
const dict = ThreadSafeDict()
Line 39:
yield()
end
dict[id] = 3 # Standing in doorway
if any(t -> flag(t) == 1, others) # Another process is waiting to enter
dict[id] = 2 # Waiting for other processes to enter