permits: 3 / 3
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.