๐ Mutex
๐ Semaphore
๐ With lock
โ
permits: 3 / 3
๏ผ
โถ Run all
โ release
โบ Reset
threads โ door โ shared resource
inside:
0/1
ยท waiting:
0
ยท balance:
100
threads
๐ช
mutex ยท 1 key
holder: โ
critical section
shared state
balance: 100
4 threads ร +1 โ should be 104
room is empty
One key, one holder
Hit
โถ Run all
: all four threads ask for the lock, only one gets in.
โธ
A mutex is
one key
โ one holder at a time. A semaphore is
N permits
โ it counts how many may be inside.