53 lines
894 B
Text
53 lines
894 B
Text
Semaphore mut = 1;
|
|
Semaphore pierasem = 0;
|
|
Semaphore mariosem = 1;
|
|
Semaphore pierosem = 0
|
|
int nbomb = 0;
|
|
boolean attesaPiero;
|
|
|
|
Process Mario{
|
|
while(true){
|
|
P(mariosem);
|
|
< friggi >
|
|
P(mut);
|
|
nbomb = 30;
|
|
if(attesaPiero)
|
|
attesaPiera = false;
|
|
V(pierosem);
|
|
if(butta == true) // e` stata Rosa
|
|
butta = false;
|
|
V(rosasem)
|
|
V(mut);
|
|
}
|
|
}
|
|
|
|
Process Piero{
|
|
while(true){
|
|
< attesa cliente >
|
|
P(pierosem);
|
|
P(mut);
|
|
nbomb --;
|
|
V(mut)
|
|
|
|
< servi cliente >
|
|
|
|
P(mut)
|
|
if(nbomb == 0)
|
|
V(mariosem);
|
|
attesaPiero = true;
|
|
else
|
|
V(pierosem);
|
|
V(mut)
|
|
}
|
|
}
|
|
|
|
Process Rosa{
|
|
while(true){
|
|
wait_timer();
|
|
P(mut);
|
|
butta = true;
|
|
V(mut);
|
|
P(rosasem);
|
|
set_timer(60);
|
|
}
|
|
}
|