Module 7: Synchronization
  Lecture 13: Introduction to Atomic Primitives
 


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