Created
May 5, 2017 11:16
-
-
Save lsartori94/039415bf231bd760fd589e67349ff092 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process puestos[i=0..9] | |
{ | |
FILA.desencolar(id) | |
while(id <> -1) | |
{ | |
HINCHA[id].atender(i); | |
PUESTO[i].atender(); | |
FILA.desencolar(id); | |
} | |
} | |
process hincha[i=1..H] | |
{ | |
int puesto; | |
FILA.encolar(i); | |
HINCHA[i].esperar(puesto); | |
delay(t) //me atienden | |
PUESTO[puesto].terminar(); | |
PUERTA[h].entrar(); | |
delay(t) //paso por la puerta | |
PUETA[h].fin(); | |
} | |
monitor PUESTO[i=0..3] | |
{ | |
cond cola; | |
procedure terminar | |
{ | |
atendiendo = false; | |
signal(cola); | |
} | |
procedure atender | |
{ | |
if(atendiendo){wait(cola)} | |
atendiedo = true; | |
} | |
} | |
monitor HINCHA{i=0..H] | |
{ | |
int puesto; | |
cond cola; | |
procedure esperar(p) | |
{ | |
p= puesto; | |
wait(cola); | |
} | |
procedure atender(p) | |
{ | |
puesto = p; | |
signal(cola); | |
} | |
} | |
monitor PUERTA[i=0..3] | |
{ | |
int cant = 0; | |
Cond paso; | |
procedure entrar | |
{ | |
if(cant == 1) {wait(paso)} | |
else cant++ | |
} | |
procedure fin | |
{ | |
signal(paso); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment