[SOLVED] CS SWEN90004 Modelling Complex Software Systems

$25

File Name: CS_SWEN90004_Modelling_Complex_Software_Systems.zip
File Size: 442.74 KB

5/5 - (1 vote)

School of Computing and Information Systems The University of Melbourne
SWEN90004 Modelling Complex Software Systems
Some Concurrency Workshop 3 solutions
The exercises

Copyright By Assignmentchef assignmentchef

1. Here is an FSP definition of the coin process:
COIN = (heads-> win -> COIN | tails -> lose -> COIN).
2. Here is an FSP description of the squaring process:
const N = 4
range T = 0..N
SQUARE = (in[i:T] -> out[i*i] -> SQUARE).
3. Here is an FSP description of the water level sensor:
* FSP code for a sensor that monitors a tank volume and checks
* whether the level is low, high, or ok.
// The readings of the level are assumed to be provided by an
// external process; the action reading[v] means a reading of
// v is received.There are 7 different levels:
range T = 0..6
= (read[v:T] -> MEASURE[v]),
MEASURE[v:T]
=(when(v<2) low ->SENSOR
| when (v > 4)high -> SENSOR
| when (v > 1 && v < 5) ok -> SENSOR

4. The drinks dispensing machine:
* FSP code for a drinks dispensing machine.
* Assumption: Once there is 15 cents to buy the drink,
* the user cannot add more coins.
= CREDIT[0],
// Inserting money is modelled using an indexed process,
// where the index represents the amount entered so far
CREDIT[i:0..30]
= ( when (i <= 10) insert[5] -> CREDIT[i+5]
| when (i <= 10) insert[10] -> CREDIT[i+10]
| when (i <= 10) insert[20] -> CREDIT[i+20]
// When credit is sufficient, give i-15 in change
// (since the cost is 15 cents):
| when (i >= 15) press_button -> CHANGE[i-15]
// 20c change is not possible: the maximal input is 10+20,
// so the maximal change is 15. The index represents the
// amount of change owing:
CHANGE[i:0..15]
= ( when (i > 10) return[10] -> CHANGE[i-10]
| when (i >= 5 && i < 20) return[5]-> CHANGE[i-5]
| when (i < 5)dummy-> END
){dummy}.
5. Moving around on the 4 4 board:
* FSP code for a pebble moving around on an NxN board.
const N = 4
range T = 1..N
P= STATE[1][1], // The pebble starts in row 1, column 1
STATE[row:T][col:T]
= ( when (row > 1) down-> STATE[row-1][col]
| when (row < N) up-> STATE[row+1][col]
| when (col > 1) left-> STATE[row][col-1]
| when (col < N) right -> STATE[row][col+1]

CS: assignmentchef QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS SWEN90004 Modelling Complex Software Systems
$25