3 ms·
Mutex specifically refers to OS/processor level constructs that protect critical sections using algorithms such as the bakery algorithm or special CPU instructi
by random314 7y ago
Mutex specifically refers to OS/processor level constructs that protect critical sections using algorithms such as the bakery algorithm or special CPU instructions. None of these are required to protect the critical section in the example above.
You can just use a busy flag. I am not familiar with JS, so this is approximate syntax.
while (busy) {
await busyIsFalse
}
busy = true
Critical Section
busy = false
notify busyIsFalse
Simple boolean flags will work