Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 5) Suponga que N personas llegan a la cola de un banco. Una vez que la persona se agrega
- en la cola no espera más de 15 minutos para su atención, si pasado ese tiempo no fue
- atendida se retira. Para atender a las personas existen 2 empleados que van atendiendo
- de a una y por orden de llegada a las personas.
- Autor: ferminmine
- https://github.com/ferminmine
- */
- PROCESS PERSONA [i=1 to N]{
- send iniciarTimer[i];
- send atender(i);
- receive me_atienden[i](atienden);
- if (atiended){
- //codigo de atencion
- } else irse();
- }
- PROCESS EMPLEADO [q=1 to 2]{
- while (true){
- receive atender(id);
- send estado[id]('atiendo', q);
- receive rta_estado[q](rta);
- if (rta){
- //lo atiendo
- } else //paso al siguiente
- }
- }
- PROCESS ADMIN_ESTADO [f=1 to N]{
- receive estado[t](primer, id);
- if (primer == "reloj"){
- send me_atienden[t] (false);
- receive estado[t](aux, id)// hace este receive para esperar que el empleado lo saque de la cola de ATENDER
- send rta_estado[id](false); // y aca le manda false asi lo pasa por alto y no lo atiende ya que el cliente se fue.
- } elseif (primer == "atiendo"){
- send me_atienden[t](true);
- send rta_estado[id](true);
- }
- }
- PROCESS TIMER [t= 1 TO N]{
- int cant:=0;
- receive iniciarTimer[cliente];
- while (cant<15){
- cant++;
- }
- // o reemplazar while por un comentario como "pasan los 15 minutos"
- send estado[cliente]('reloj',t);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement