Lecture 28

Examples of Distributed Systems

   (where to look for structural and programming ideas)

  (1) replicated files -- Section 8.4  [described last time]

        draw structure as in Figure 8.14

        client/server and peer interactions
        get local read lock and all write locks

  (2) dining philosophers -- Section 9.7, Chapter 13 of SR book

        centralized:  one waiter
        distributed:  one waiter per fork
        decentralized:  one waiter per philosopher

        we have seen centralized structure (Figure 8.6)

        distributed structure is same as for replicated files

        draw decentralized structure, as in Figure 9.19 (c)

          synchronization:
             one token per fork; it moves between two waiters
             clean/dirty states and rules to avoid deadlock
 
          could use this idea for replicated files:
             "locks" migrate to point(s) of activity

  (3) distributed file system DFS -- Chapter 17 of SR book
        (see also examples/chap17 in the SR distribution)

        idea:  perform operations on local and/or remote files and directories

        structure:
            users on machine 1            users on machine 2

            command interpreters          command interpreters

              local file system  <--->      local file system

        naming convention for remote files:  machine:pathname

        structure is similar to Web/Internet and to connected but
          separate local file systems:  /r/machine/...
        trend has been to more transparent names

        interacting with xterm windows for your project:
          see p. 263 of SR book for how to access windows as devices
          in Unix (/tty/...  names)


Programming Distributed Systems

   approaches:
     (1) C plus sockets
     (2) Java plus sockets and/or RMI
     (3) SR (or Ada)

   (1) and (2) -- have separately started program parts and use a connection protocol

        start coordinator
        start parts -- they connect to coordinator and get back links to other parts

        + can add new parts dynamically
        - lots of management

   (3) -- one program, all parts compiled in advance

        start main part; it creates others and passes them connections

        + easier to program than (1) or (2)
        - parts compiled in advance => cannot dynamically add parts


Distributed Programming in SR

   big picture of parts of a distributed SR program

         vm1:                         vm2:
           globals                      globals
           resources                    resources
           ---------                    ---------
           Runtime System               Runtime System

         
   global -- one copy per vm; created when first imported
   resource -- one "main" resource to start; program creates others
   vm -- one "host" vm to start; program creates others

   Resource and operations on them

      structure:  resource name
                    op declarations
                  body name(formals)
                    variables
                    procedures
                    processes
                  end

       resource capabilities:  var rc : cap name

       resource creation:      rc := create name(args)

       invoking operations     rc.op(args)    # call or send in general

       destroying a resource   destroy rc

   Virtual Machines (pseudo resources; see Chapter 12 of SR book)

       vm capabilities:  var vc : cap vm

       vm creation:  vc := create vm() [on hostname]
             # default location is local machine

       resource creation on a vm:  rc := create name(args) on vc
             # default location is same vm as creator

   capabilities are special pointers (references to objects); use them
      to invoke operations
   see SR book and SR examples for details


Exam 2 -- on Thursday

   hand out copy of old exam and go over it
   formal this year will be the same, but there will only be 5 problems

   topics to review
     semaphores -- Chapter 4
     monitors -- Chapter 5
     message passing -- Chapter 7
     RPC and rendezvous -- Chapter 8
     interacting peers -- Sections 9.1 to 9.3 and 9.7; more examples in Chapter 11
     implementation concepts in Chapters 6 and 10

   to prepare, I suggest working exercises in the text for these chapters