CEG 730 Distributed Computing Principles

Winter 2012//Mid Term Exam//75 minutes//100 points

This is a closed book, closed notes exam. Do not give or take help during the exam.
  1. (10*5 points) Explain/ discuss/ dispute/ compute the following statements. It is possible to write no more than, say, ten, sentences each, and yet receive full score.
    1. wp(S, True ) = True defines liveness of S. True/False? Explain.
    2. Compute wp(S, i = 2), where S is if i < 2 --> i := i + 1 [] i > 2 --> i := 2 fi
    3. Consider the program segment given here.
      Determine P a predicate that characterizes the weakest deadlock-free precondition for the program. Also, explain how you arrived at P.
       co <await x >= 4  --> x := x - 4>
       || <await x >= 5  --> x := x - 4>
       || <await x == 1  --> x := x + 8>
       oc
    4. Since the semantics of S1 || S2 permits their execution as if it is S1;S2, we can replace some occurrences, if not all, of S1;S2 with S1 || S2. True/False? Explain.

    5. A scheduling policy that is strongly fair must also be weakly fair. Discuss.
    6. "Some day, if not at the end of CEG 730, you will appreciate and marvel at the book Concurrent Programming by Andrews.'' Explain if this is a safety, or liveness property, or perhaps neither.
    7. In the context of RPC, a procedure designed to be called remotely can use global variables to communicate with the caller, provided we modify rpcgen appropriately. True/False? Explain.
    8. Marshalling in RPC is no more than a tight-packing of the bytes of the input arguments. True/False? Explain.
    9. The code V(s); P(s) is always equivalent to a no-op ("skip", or do-nothing). True/False? Explain.
    10. The "standard solution" P(m); CS; V(m) is starvation-free in the context of non-distributed systems.
  2. (25 points) Consider the following as an await-statement based model of the classic Dining Philosophers Problem. The expression i + 1 throughout is modulo 5. The up and dn (down) refer to whether the philosopher picked the fork up or put the fork down.
       global int up[0..4], dn[0..4] initially all 0;
       philosopher[i: 0..4]::
         do true -->
       	think
       	< await up[i] == dn[i] --> up[i] ++ >
       	< await up[i+1] == dn[i+1] --> up[i+1] ++ >
            eat
       	< dn[i] ++ >
       	< dn[i+1] ++ >
         od
    
    1. (15 points) Using the Pass-the-Baton technique systematically convert it to an equivalent algorithm using semaphores only. For now, disregard if the above is a ``solution'' or not.
    2. (10 points) Is this a deadlock-, livelock-, starvation-free ``solution'' to the Dining Philosophers Problem? If so, explain. If not so, fix it at the await-statement level .
  3. (25 points) The Recursive Data Representation: Small Set of Integers of Hoare's CSP paper is reproduced below. (a) (20 points) Extend it to respond to a request S(1)!secondMin() from S(0) that expects a reply with the second minimum of elements in the set if the set has more than 1 elements, or "undefined" otherwise. Include an explanation of how it works. (b) (5 points) Include a convincing argument/proof that your extension is correct, and that you have not broken existing functionality.
    S(i: 1 .. 100) ::
        do  n: integer; S(i-1)?has(n) --> S(0)!false
        []  n: integer; S(i-1)?insert(n) -->
            do  m: integer; S(i-1)?has(m) -->
                if  m <= n --> S(0)!(m = n)
                []  m >  n --> S(i+1)!has(m)
                fi
            []  m: integer; S(i-1)?insert(m) -->
                if m < n --> S(i+1)!insert(n); n := m
                [] m = n -->  skip
                [] m > n --> S(i+1)!insert(m)
    	    fi
            od
        od

Copyright © 2012 Prabhaker Mateti • Feb 09, 2012