Module 7: Synchronization
  Lecture 13: Introduction to Atomic Primitives
 


TTS Traffic Analysis

  • Recall that unlock is always a simple store
  • In the worst case everyone will try to enter the CS at the same time
    • First time P transactions for ts and one succeeds; every other processor suffers a miss on the load in Test loop; then loops from cache
    • The lock-holder when unlocking generates an upgrade (why?) and invalidates all others
    • All other processors suffer read miss and get value zero now; so they break Test loop and try ts and the process continues until everyone has visited the CS

    (P+(P-1)+1+(P-1))+((P-1)+(P-2)+1+(P-2))+… = (3P-1) +
    (3P-4) + (3P-7) + … ~ 1.5P 2 asymptotically

    • For distributed shared memory the situation is worse because each invalidation becomes a separate message (more later)

Goals of a Lock Algorithm

  • Low latency: If no contender the lock should be acquired fast
  • Low traffic: Worst case lock acquire traffic should be low; otherwise it may affect unrelated transactions
  • Scalability: Traffic and latency should scale slowly with the number of processors
  • Low storage cost: Maintaining lock states should not impose unrealistic memory overhead
  • Fairness: Ideally processors should enter CS according to the order of lock request (TS or TTS does not guarantee this)