UniTO/anno2/Sem1/Galla/MCAD/esercizi2019/bomboloni_sol/mia_messagepassing
2024-10-29 09:11:05 +01:00

89 lines
1.7 KiB
Text
Executable file

Process Bancone {
int nbomb = 0;
long tick = 0;
long alarm = -1;
boolean butta = false;
signal s;
port signal friggi_i;
port signal friggi_f;
port signal servi_i;
port signal servi_f;
port signal wait_timer;
port long set_timer;
port signal scaduti;
do
[] nbomb == 0 or butta; p = receive(s) from friggi_i ->
send(nbomb) to p.ok;
[] ; receive(s) from friggi_f;
nbomb = 30;
butta = false;
alarm = tick + 60;
[] nbomb > 0 and !butta; p = receive(s) from servi_i ->
send(s) to p.ok;
[] ; receive(s) from servi_f ->
nbomb--;
[] tick >= alarm; p = receive(s) from wait_timer ->
send(s) to p.ok;
[] butta == false; receive(s) from scaduti ->
butta = true;
[] ; receive(s) from clock ->
tick++;
[] ; receive(n) from set_timer ->
alarm += n;
od
}
Process Mario {
int b_rimasti = 0;
signal s;
port int ok;
while(true){
send(s) to Bancone.friggi_i;
receive(b_rimasti) from ok;
if(b_rimasti) < butta >;
< friggi bomboloni >
send(s) to Bancone.friggi_f;
}
}
Process Piero {
signal s;
port signal ok;
while(true){
send(s) to Bancone.servi_i;
receive(s) from ok;
< servi cliente >
send(s) to Bancone.servi_f;
}
}
Process Rosa {
signal s;
port signal ok;
while(true){
send(s) to Bancone.wait_timer;
receive(s) from ok;
send(s) to Bancone.scaduti;
send(s) to Bancone.settimer(60);
}
}
Process Clock {
signal s;
while(true){
< hw clock >
send(s) to Bancone.clock;
}
}