Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with Ada.Text_IO; use Ada.Text_IO;
- procedure Filosofo1 is
- type izq is range 0 .. 4;
- task Comedor is
- entry ENTRAR;
- entry SALIR;
- end Comedor;
- task body Comedor is
- begin
- cant := izq'First;
- loop
- select
- when cant < 5 =>
- accept ENTRAR;
- cant := cant + 1;
- or
- accept SALIR;
- cant := cant - 1;
- end select;
- end loop;
- end Comedor;
- task Numerador is
- entry dmn(x:integer);
- end Numerador;
- task body Numerador is
- i: integer;
- begin
- for i in izq loop
- accept dmn(n : out int) do
- n := i;
- end dmn;
- end loop;
- end Numerador;
- task type Palito is
- entry Pedir;
- entry Devolver;
- end Palito;
- task body Palito is
- begin
- loop
- accept Pedir;
- accept Devolver;
- end loop;
- end Palito;
- Palitos : array (izq) of Palito;
- task type Filosofo is
- end Filosofo;
- task body Filosofo is
- izquierda: izq;
- der : izq;
- c:Comedor;
- begin
- numerador.dmn(izq);
- der:=(izq+1)mod 5;
- loop
- Put_Line ("El filosofo" & izq'Image(i) & " esta pensando");
- c.ENTRAR;
- Palitos(izq).Pedir;
- Palitos(der).Pedir;
- Put_Line ("El filosofo" & izq'Image(i) & " esta comiendo");
- Palitos(der).Devolver;
- Palitos(izq).Devolver;
- c.SALIR;
- end loop ;
- end FILOSOFO ;
- Filosofos: array (izq) of Filosofo;
- begin
- Put_Line ("Comienza simulador");
- end Filosofo1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement