Here are questions that you can use to test your understanding of the FSP/LTSA material presented during the last two lectures.
1. A variable stores values in the range 0..N and supports the actions "read" and "write". Model the variable as a process called VARIABLE, using FSP. For N=2, check that your process can support the following trace:
write[2] -> read[2] -> read[2] -> write[1] -> write[0] -> read[0]
In a programming language, the above trace would correspond to a program that looked like this
a = 2; println(a); println(a); a = 1; a = 0; println(a)
and the output would of course be "2, 2, 0"
2. A bistable digital circuit receives a sequence of trigger inputs and alternately outputs 0 and 1. Model the process BISTABLE in FSP and check that it produces the required output. For instance, one possible trace might be:
trigger -> 1 -> trigger -> 0 -> trigger -> 1 -> ...
The other possible trace might be:
trigger -> 0 -> trigger -> 1 -> trigger -> 0 -> ...
3. Create a FSP process called GAME where if a user selects the input "one" or "two", the output is "win". But if the user selects the input "three", the output is "lose".
4. Create a FSP process called DOUBLE in which an input from the range 0..N can be selected and the output is then the selected value times two. So, the start of one trace might look like this:
in[5] -> out[10] -> in[2] -> out[4] -> ...
5. Create an FSP process that allows a PLAYER to move "ahead" and then choose between "right" or "left". If they select "right" they can move "ahead" and make another decision but if they select "left" the process ends. (Recall you can use the predefined STOP process to end a process in FSP.)
6. Extend the client-server system described in lecture 13 such that three clients can access the server at once. Treat the server as a shared resource that requires mutual exclusion.
7. Modify the model that you created in number 6 such that the call to the server may terminate with a timeout action rather than a response from the server. Describe what happens to your model when this occurs.