Week 5

  • UPC Exercises 1.1 through 1.7
  • Due: Tue, Feb 17, 11:59pm (tonight!)
  • Here's a link: private

Semaphores

  • Ben-Ari Ch 6
    • slides: PDF
      • begin slide 6.1, p. 105
  • Two operations:
    • wait(s)
      • Traditional: P(s)
        • originally: from the Dutch word, passeren (“to pass”)
        • later: prolagen—formed from the Dutch words proberen (“to try”) and verlagen (“to decrease”)
      • Definition:
         < await (s > 0) s = s - 1; > 
    • signal(s)
      • Traditional: V(s)
        • originally: from the Dutch word, vrijgeven (“to release”)
        • later: verhogen (“to increase”)
      • Definition:
         < s = s + 1; > 
  • wait(s) and signal(s) work the same for binary and counting (general) semaphores
    • binary semaphore: value is always either 1 or 0
    • general semaphore: value is nonnegative

Class exercises

  • The Bear and the Honeybees (handout) PDF
    • try to solve with a single binary semaphore
    • (discuss)
    • try using split binary semaphores
      • where for binary semaphores s1 and s2:
          0 <= s1+s2 <= 1 
    • technique: pass the baton
  • Dining UPC Philosophers PDF
  • Assigned: Thu, Feb 19
  • Due: Tue, Mar 3, 11:59pm (Tue before Spring break)