UniTO/anno2/YearI/FirstSem/MCAD/esercizi2019/bomboloni_sol/mia_rendevouz

77 lines
1.3 KiB
Text
Raw Normal View History

2018-12-03 17:53:23 +01:00
Process Bancone {
int nbomb = 0;
long tick = 0, alarm = -1;
bool butta = false;
2018-12-03 23:28:13 +01:00
entry friggi_i(out int rimasti);
2018-12-03 17:53:23 +01:00
entry friggi_f;
entry servi_cliente_i;
entry servi_cliente_f;
entry scaduti;
entry clock;
entry wait_timer;
entry set_timer (in long n);
do
2018-12-03 23:28:13 +01:00
[] nbomb == 0 or butta; accept friggi_i(out nrimasti);
nrimasti = nbomb;
2018-12-03 17:53:23 +01:00
[] ; accept friggi_f() ->
nbomb = 30;
alarm = tick + minuti(60);
butta = false;
[] nbomb > 0 and !butta; accept servi_cliente_i();
[] ; accept servi_cliente_f() ->
nbomb--;
[] ; accept clock(); ->
tick++;
[] tick >= alarm and alarm != -1; accept wait_timer() ->
butta = true;
nbomb = 0;
alarm = -1;
[] ; accept set_timer(in long n) ->
alarm = tick + n;
[] ; accept scaduti ->
butta = true;
od;
}
Process Mario {
2018-12-03 23:28:13 +01:00
int nrimasti;
2018-12-03 17:53:23 +01:00
while(true){
2018-12-03 23:28:13 +01:00
call Bancone.friggi_i(nrimasti);
if(nrimasti) < butta >;
2018-12-03 17:53:23 +01:00
< friggi bomboloni >
call Bancone.friggi_f();
}
}
Process Piero {
while(true){
2018-12-03 23:28:13 +01:00
< attendi cliente >
2018-12-03 17:53:23 +01:00
call Bancone.servi_cliente_i();
< servi cliente >
call Bancone.servi_cliente_f();
}
}
Process Rosa {
while(true){
call Bancone.wait_timer();
call Bancone.butta();
call Bancone.set_timer(60);
}
}
Process Clock {
while(true){
< hardware clock ticks >
call Bancone.clock();
}
}