CEG 7370: Distributed Computing Principles

Semantics of Semaphores

  1. Semaphore Definition
    P(s) ≡ ‹ await s > 0 → s := s-1 ›
    V(s) ≡ ‹ s := s+1 ›
  2. Semaphore Invariant
    nP ≤ nV + initValue
    s = initValue + nV - nP
    SEM: s ≥ 0
  3. Synchronization Rule
    {R and B} S {Q}
    {R} ‹await B → S › {Q}
     
  4. Semaphore Ops
    (R and s > 0) ⇒ Qss-1
    {R} P(s) {Q}
    R ⇒ Qss+1
    {R} V(s) {Q}

Copyright © 2012 Prabhaker Mateti