Professional Documents
Culture Documents
W7 - Locks
● problems
○ (1) a thread can monopolize the processor by
keeping the lock → ⛔ correctness/fairness/starve
○ (2) not work on multiprocessors
○ (3) interrupt losts
○ (4) inefficient → ⛔ performance
Solution 2: A failed attempt
Just using loads/stores
● spin-wait for the lock
● problems
○ ⛔ correctness/fairness/starve
○ ⛔ performance
● (1) correctness ✅
● (2) fairness ⛔
● (3) starvation ⛔
● (4) performance ⛔
○ threads will spin for the duration of a time slice before gigging up the
CPU → waste of CPU cycles
Solution 4: Compare-and-swap
Solution 5: Load-linked and
store-conditional