Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with Ada.Text_IO; use Ada.Text_IO;
- package body paczka is
- procedure p is
- task Bufor is
- entry Wstaw(x: in Integer);
- entry Pobierz(x: out Integer);
- end Bufor;
- task body Bufor is
- Buf: array(0..19) of Integer;
- We, Wy: Integer := 0;
- Licznik: Integer := 0;
- begin
- loop
- select
- when Licznik < 20 =>
- accept Wstaw(X: in Integer) do
- Buf(We) := X;
- end Wstaw;
- Licznik := Licznik + 1;
- We := (We + 1) mod 20;
- or
- when Licznik > 0 =>
- accept Pobierz(X: out Integer) do
- X := Buf(Wy);
- end Pobierz;
- Licznik := Licznik - 1;
- Wy := (Wy + 1) mod 20;
- end select;
- end loop;
- end Bufor;
- task Producent;
- task body Producent is
- Elem: Integer := 5;
- begin
- loop
- Elem := Elem + 1;
- B.Bufor.Wstaw(Elem);
- end loop;
- end Producent;
- task Konsument;
- task body Konsument is
- Elem: Integer;
- begin
- loop
- Bufor.Pobierz(Elem);
- Put_Line (Elem);
- end loop;
- end Konsument;
- begin
- null;
- end p;
- end paczka;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement