Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1.  
  2. 5) Suponga que N personas llegan a la cola de un banco. Una vez que la persona se agrega
  3. en la cola no espera más de 15 minutos para su atención, si pasado ese tiempo no fue
  4. atendida se retira. Para atender a las personas existen 2 empleados que van atendiendo
  5. de a una y por orden de llegada a las personas.
  6.  
  7. Autor: ferminmine
  8. https://github.com/ferminmine
  9.  
  10. */
  11.  
  12. PROCESS PERSONA [i=1 to N]{
  13. send iniciarTimer[i];
  14. send atender(i);
  15. receive me_atienden[i](atienden);
  16. if (atiended){
  17. //codigo de atencion
  18. } else irse();
  19. }
  20.  
  21. PROCESS EMPLEADO [q=1 to 2]{
  22. while (true){
  23. receive atender(id);
  24. send estado[id]('atiendo', q);
  25. receive rta_estado[q](rta);
  26. if (rta){
  27. //lo atiendo
  28. } else //paso al siguiente
  29. }
  30. }
  31.  
  32. PROCESS ADMIN_ESTADO [f=1 to N]{
  33. receive estado[t](primer, id);
  34. if (primer == "reloj"){
  35. send me_atienden[t] (false);
  36. receive estado[t](aux, id)// hace este receive para esperar que el empleado lo saque de la cola de ATENDER
  37. 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.
  38. } elseif (primer == "atiendo"){
  39. send me_atienden[t](true);
  40. send rta_estado[id](true);
  41. }
  42. }
  43.  
  44. PROCESS TIMER [t= 1 TO N]{
  45.  
  46. int cant:=0;
  47. receive iniciarTimer[cliente];
  48. while (cant<15){
  49. cant++;
  50. }
  51.  
  52. // o reemplazar while por un comentario como "pasan los 15 minutos"
  53. send estado[cliente]('reloj',t);
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement