Due 11/16/2011 3:59PM
| Machine | Request time: | Request type: | Duration until release |
| A | 00:00 | Shared | 05 |
| B | 00:05 | Shared | 10 |
| C | 00:08 | Exclusive | 02 |
| D | 00:10 | Shared | 05 |
| B | 00:14 | Exclusive | 05 |
| A | 00:20 | Shared | 05 |
Time: 00:00
| Machine A Lock: Shared Cache: File F |
Machine B Lock: None Cache: Empty |
Machine C Lock: None Cache: Empty |
Machine D Lock: None Cache: Empty |
Suppose we run the following program, with the code in the first
column running on one machine in a distributed system and the code on
the right running on another machine. The distributed system provides
a set of shared files with some consistency model. Initially A and B
are both 0.
| write(A, 1); // Write the value ``1'' to file A | write(B, 1); // Write the value ``1'' to file B |
| if(read(B) == 0) // read the value from file B | if(read(A) == 0) // read the value from file A |
| print ``A wins''; | print ``B wins''; |
(a) What are the possible outputs assuming the system enforces {\em
linearizability}?
(b) For the program described in the previous question, what are the
possible outputs assuming the system enforces {\em causal consistency}?
(c) What are the possible outputs for the above program assuming
the system enforces {\em sequential consistency}?
Suppose a distributed file system implements linearizable consistency using callbacks and does not use leases. Suppose that a client $c1$ that is caching file $F$ becomes disconnected from the network. Which of the following is true
i1 = 0;
while(true){
overwriteFile("/foo", i1);
i1++;
}
The function overwriteFile() replaces previous contents of the file with the specified value.
Machine 2 runs the following code
while(true){
int i2 = readValueFromFile("/foo");
overwriteFile("/bar", i2);
}
Machine 3 runs the following code
int i2 = readValueFromFile("/bar");
int i1 = readValueFromFile("/foo");
Suppose that machine 3 reads the value ``10'' on the first read (of i2). Which of the following is true of the value that machine 3 reads on the second read (of i1)? (If multiple items are true, choose the most precise/restrictive of the options. I.e., i1 < 10 is more precise/restrictive than i1 ≤ 10.)