Synchronization

Motivation

Amdahl’s Law guides the efficiency gains when using multiple cores

Locking Basics

Fine-grained locking vs. Coarse-grained locking

Hardware Specific Synchronization Instructions

Cache Coherence

MCS Lock

Deadlock

Wait Channel

Hand-over-Hand Locking

Lock order:

  1. Acquire spinlock (exclusive access to struct’s fields)
  2. Acquire waitchannel lock (exclusive access to waitchannel)
  3. Release spinlock (we have access to what we want, WC)

Spinlock that the wait channel uses is hidden in these calls

Example