Title: Assignment 3 FSP
1Assignment 3 - FSP
Group Exercise 1. A drinks dispensing machine
charges 15p for a can of Sugarola. The machine
accepts coins with denominations 5p, 10p and 20p
and gives change. Using the alphabet can,
in.coin10, in.coin20, in.coin5,
out.coin10, out.coin5 model the machine as
an FSP process, DRINKS. A sample trace is shown
below.
2Assignment 3 - FSP
GE1. Solution.
DRINKS CREDIT0, CREDIT0 (in.coin5 -gt
CREDIT5 in.coin10 -gt
CREDIT10 in.coin20 -gt
CHANGE5), CREDIT5 (in.coin5 -gt
CREDIT10 in.coin10 -gt
CHANGE0 in.coin20 -gt
CHANGE10), CREDIT10 (in.coin5 -gt
CHANGE0 in.coin10 -gt
CHANGE5 in.coin20 -gt
CHANGE15), CHANGE0 (can -gt
DRINKS), CHANGE5 (can -gt out.coin5 -gt
DRINKS), CHANGE10 (can -gt out.coin10 -gt
DRINKS), CHANGE15 (can -gt out.coin5 -gt
out.coin10 -gt DRINKS).
3Assignment 3 - FSP
GE2. A, S and J work in a bar. A washes the
dirty glasses one at a time and places each on a
workspace. The workspace can hold a maximum of 10
glasses. S and J remove the glasses from the
workspace one at a time and dry them. You can
ignore what happens to a glass after it is
dried. Unfortunately, there is only one drying
cloth so S and J have to take turns at using it.
However, as J is able to dry faster he dries two
glasses at each turn while S only dries one. S
takes the first turn at drying. Model the
concurrent activity in the bar by completing the
following FSP template.
4Assignment 3 - FSP
GE2.
S (sdry -gt S). J (jdry -gt jdry -gt J). A
(wash -gt A). // gw is the number of glasses
washed. // j is the number of glasses washed by J
in this turn. // turn indicates whose turn it is
to wash. WORKSPACE(N5) WS000, WSgw0..N
j0..1turn0..1 (..). BAR (S J A
WORKSPACE(10)).
5Assignment 3 - FSP
GE2. A sample trace is shown below.
6Assignment 3 - FSP
GE2. Solution.
S (sdry -gt S). J (jdry -gt jdry -gt J). A
(wash -gt A). WORKSPACE(N5) WS000, WSgw0
..Nj0..1turn0..1 (gwgw-gt
WSgwjturn when (gwltN) wash -gt
WSgw1jturn when (gwgt0
turn0) sdry -gt
WSgw-101 when (gwgt0 j0
turn1) jdry -gt
WSgw-11turn when (gwgt0
j1 turn1) jdry -gt
WSgw-100). BAR (S J A
WORKSPACE(10)).