|
|
CEG 730 Distributed Computing PrinciplesWinter 2012//Mid Term Exam//75 minutes//100 pointsThis is a closed book, closed notes exam. Do not give or take help during the exam. |
| 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 |
V(s); P(s) is always equivalent
to a no-op ("skip", or do-nothing). True/False? Explain.
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
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