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

image

์žฅ์  : easy to make correct

๋‹จ์  : limits parallelism, no two critical sections can proceed in parallel

ย 

Fine-grain locks

image

์žฅ์  : 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