Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------------
- -- synchronous PC using Rendezvous --
- ------------------------------------------------------------------
- with Ada.Text_IO; use Ada.Text_IO;
- procedure buff is
- task Buf is
- entry Put(x: in Integer);
- entry Get(x: out Integer);
- end Buf;
- task Producer;
- task Consumer;
- task body Buf is
- curr: Integer;
- begin
- loop
- accept Put(x: in Integer) do
- curr := x;
- end Put;
- accept Get(x: out Integer) do
- x := curr;
- end Get;
- end loop;
- end Buf;
- task body Producer is
- begin
- for I in 1..14 loop
- Buf.Put(I);
- end loop;
- Put_Line("Producer ending");
- end Producer;
- task body Consumer is
- x: Integer;
- begin
- loop
- Buf.Get(x);
- Put_Line("Get: " & Integer'Image(x));
- end loop;
- --Put_Line("Consumer ending");
- --terminate;
- end Consumer;
- begin
- Put_Line("Hello world");
- --null;
- end buff;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement