Basic

Classical Non-Distributed Concurrency Control

spin-lock

  • what:Atomic compare-and-swap/test-and-set instructions
  • why: easy
  • how: Requires locking memory bus on multi-core/multi-processor
  • problem:Busy wait not good for high contention. busy-waiting, busy-looping or spinning is a technique in which a process repeatedly checks to see if a condition is true, such as whether keyboard input or a lock is available.

mutex

  • what:Semaphores, At-Most-N policies,Mutual Exclusion
  • why:Conceptually,manages a pool of resources.
  • how:
    • P operation: Wait for resource to be available (lock s-=1)
    • V operation: Make resource available (unlock s+=1)
    • Deschedule (move to blocked queue) blocked thread or process
    • Reschedule (move to ready queue) when resource available
    • 初始s=1,s不会是负值

CONDITION VARIABLES

Event based

  • Wait – always waits. No predicate
  • Signal – Wake up a waiter
  • Broadcast – Wake up all waiters.