Title: Assignment 3 FSP
1Assignment 3 - FSP
Unassessed Exercise 1. A variable store values
in the range 0..N and supports the actions read
and write. Model the variable as a process,
VARIABLE, using FSP. The processs LTS graph for
N2 is shown below. Your FSP model must produce
an identical graph.
2Assignment 3 - FSP
UE1. Solution.
const N ... range R 0..N VARIABLE
VAR0, VARiR (readi -gt VARi
writevR -gt VARv ).
3Assignment 3 - FSP
UE2. Consider the following scenario. There
are n bees and a hungry bear. They share a pot of
honey. The pot is initially empty its capacity
is H portions of honey. The bear waits until the
pot is full, eats all the honey and waits until
the pot is full again this pattern repeats
forever. Each bee repeatedly gathers one portion
of honey and puts it into the pot if the pot is
full when a bee arrives it must wait until the
bear has eaten the honey before adding its
portion this pattern repeats forever. Model
this scenario using FSP. The LTS graph for 4 bees
is shown below. Your FSP model must produce an
identical graph.
4Assignment 3 - FSP
UE2.
5Assignment 3 - FSP
UE2. Solution.
const H4 const N3 BEE (addhoney -gt
BEE). BEAR (eat -gt BEAR). POT
POT0, POTi0..H (when (iltH)
j0..N.addhoney -gt POTi1 when
(iH) eat -gt POT0). HONEYBEAR
(i0..NBEE BEAR POT).
6Assignment 3 - FSP
UE3. To restore order on the log-flume ride the
management installs a ticket machine that issues
tickets to passengers. Tickets are numbered in
the range 1..MT. When ticket MT has been issued
the next ticket to be issued is ticket number 1.
The log-flume controller only allows passengers
to enter in ticket number order. Complete the
following FSP model and show that even when their
entry priority is low meek passengers will still
get a ride.
7Assignment 3 - FSP
UE3.
set Bold bold1..2 set Meek
meek1..2 set RIDERS Bold, Meek const
SEATS 2 const MT4 range T 1..MT LOG (clean
-gt ride -gt LOG). PASSENGER (tickettT -gt
embarkt -gt disembark -gt PASSENGER). TICKET
.. CONTROL (..). LOGFLUME (LOG
RIDERSPASSENGER RIDERSTICKET
RIDERSCONTROL/ride/RIDERS.ride,clean/RIDERS.c
lean) gtgtMeek.embarkT. progress
BOLD Bold.embarkT progress MEEK
Meek.embarkT
8Assignment 3 - FSP
UE3. Solution
set Bold bold1..2 set Meek
meek1..2 set RIDERS Bold, Meek const
SEATS 2 const MT4 range T 1..MT LOG
(clean -gt ride -gt LOG). PASSENGER (tickettT
-gt embarkt -gt disembark -gt PASSENGER). TICKETT
ICKET1, TICKETtT(tickett -gt
TICKETtMT1).
9Assignment 3 - FSP
UE3. Solution
CONTROL (clean -gt ENTER01), ENTER
i0..SEATStT ( when (iltSEATS)
embarkt -gt ENTERi1tMT1 when
(iSEATS) ride -gt EXITSEATSt), EXITi1..SEA
TStT ( when (igt1) disembark -gt
EXITi-1t when (i1) disembark -gt clean
-gt ENTER0t). LOGFLUME (LOG
RIDERSPASSENGER RIDERSTICKET
RIDERSCONTROL/ride/RIDERS.ride,clean/RIDERS.c
lean) gtgtMeek.embarkT. progress BOLD
Bold.embarkT progress MEEK Meek.embarkT