Lecture 23

Review -- server patterns

   receive ... send
   receive  if () ...  send
   receive  nested if  send or hold   [duality with monitors]
   self-scheduling with polling

   all these used one server and N clients

   today:  multiple servers and clients
           interacting peers



File Server Problem

   setting      C1        S1
                ...       ...
                Cm        Sn

   client interface:  open; (read + write)*; close
        need rendezvous (open) plus conversation

   channels:  open            1
              open_reply      m, one per client
              access          n, one per file server
              access_reply    m, one per client

   rendezvous part

      client:  send open(myid, ...); receive open_reply[myid](serverid);

      server:  receive open(clientid); ...; send open_reply[clientid](myid);

   conversation part:  one client to one server, using clientid and serverid

   transparency for Figure 7.10

   what if cannot have a global channel with multiple receivers?
      [usually each channel has exactly one receiver]

      use a separate manager process:
         receive open(...); pick a server; send a message to it (forward open)

      also need done messages from servers to the manager to say they are free
         this implies that the manager receives two kinds of messages:
            opens from clients and dones from servers


Interacting Peers -- Section 7.4

   used to share data, combine data, make decisions
   [there are lots of examples in Chapters 9 and 11]

   exchanging values problem:

      there are n processes; each has a value; want every process to learn every value
      this type of exchange occurs in many places:  n-body simulation, reductions, etc.

   solution structures [draw them, as in Figure 7.14]:

      (a) centralized -- star, with coordinator in middle

      (b) symmetric -- complete graph

      (c) ring -- closed (circular) pipeline

   programming these -- I developed code outlines for each, showing
      the send and receive patterns

      I told the students to study the actual code on their own.
      (It's also in a homework problem.)

   message counts:
      (a) 2(n-1)   (b) n(n-1)  (c) 2n

   discussion of:
     time complexity
     possible use of broadcast
     possible overlap of communication and computation