Parallel Programming 8
Fine-grained Synchronization & Lock-free Programming
Deadlock ๋ฐ์ ์กฐ๊ฑด (๋ชจ๋ ๋ง์กฑํด์ผ ํจ)
- Mutual exclusion
- Hold and wait
- No preemption
- Circular wait
Livelock : a state where a system is executing many operations, but no thread is making meaningful progress. example : Operations continually abort and retry
Starvation : State where a system is making overall progress, but some progresses make no progress.
Usually not a permanent state
Coarse-grain locks
์ฅ์ : easy to make correct
๋จ์ : limits parallelism, no two critical sections can proceed in parallel
ย
Fine-grain locks
์ฅ์ : Fast, critical sections can proceed in parallel
๋จ์ : Easy to make mistakes, tricky to ensure correctness
ย
Lock-free data structures
why?
- Acquiring locks is expensive
- 99% of the time un-necessary
- Most concurrent actions donโt actually share data
Non-blocking algorithms are lock-free if some thread is guaranteed to make progress