Module 11: "Synchronization"
  Lecture 21: "Introduction to Synchronization"
 

Synchronization Types

  • Mutual exclusion
    • Synchronize entry into critical sections
    • Normally done with locks
  • Point-to-point synchronization
    • Tell a set of processors (normally set cardinality is one) that they can proceed
    • Normally done with flags
  • Global synchronization
    • Bring every processor to sync
    • Wait at a point until everyone is there
    • Normally done with barriers

Synchronization

  • Normally a two-part process: acquire and release; acquire can be broken into two parts: intent and wait
    • Intent: express intent to synchronize (i.e. contend for  the lock, arrive at a barrier)
    • Wait: wait for your turn to synchronization (i.e. wait until you get the lock)
    • Release: proceed past synchronization and enable other contenders to synchronize
    • Waiting algorithms do not depend on the type of synchronization

Waiting algorithms

  • Busy wait (common in multiprocessors)
    • Waiting processes repeatedly poll a location (implemented as a load in a loop)
    • Releasing process sets the location appropriately
    • May cause network or bus transactions
  • Block
    • Waiting processes are de-scheduled
    • Frees up processor cycles for doing something else
  • Busy waiting is better if
    • De-scheduling and re-scheduling take longer than busy waiting
    • No other active process
    • Does not work for single processor
  • Hybrid policies: busy wait for some time and then block

Implementation

  • Popular trend
    • Architects offer some simple atomic primitives
    • Library writers use these primitives to implement synchronization algorithms
    • Normally hardware primitives for acquire and possibly release are provided
    • Hard to offer hardware solutions for waiting
    • Also hardwired waiting may not offer that much of flexibility