Lecture 19

Review -- on board at start

  monitor structure

  cond cv;     declaration
  wait(cv);    exit and block on delay queue
  signal(cv);  move first process from delay queue to entry queue; signaler continues
  empty(cv);   true if cv's queue is empty

  transparencies for Figures 5.2 and 5.3 to highlight how wait/signal work


Synchronization Techniques -- Section 5.2

   the following series of examples illustrate a variety of useful techniques
   [for each I remind the student of the problem -- or introduce it -- and
    illustrate the program structure]

   (1) producer/consumer problem and bounded buffer

         transparency for Figure 5.4
         uses while loops and recheck of conditions

   (2) readers/writers

         transparency for Figure 5.5
         uses broadcast signal

   (3) shortest job next

         transparency for Figure 5.6
         uses priority wait

   (4) interval timer

        processes call delay(interval)
        a clock "process" (interrupt handler) calls tick()

        (a) first approach:  awaken all delayed processes and let them check

              transparency for Figure 5.7
              uses a covering condition

        (b) second approach:  order delayed processes

              transparency for Figure 5.8
              again uses priority wait

        tradeoffs:  cost of false alarms; existence of a total order
                    a problem in the homework explores these

   (5) sleeping barber

        describe the idea of the problem
        draw a diagram like the one in Figure 5.9

        transparency for Figure 5.10
        has multiple delay points; uses rendezvous synchronization