with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;
procedure beznumerka is
task type Pisarz (num: Integer);
task type Czytelnik (id: Integer);
task type czytelnia is
entry ChceCzytac;
entry ChcePisac;
entry Koniec;
entry Mozesz;
end czytelnia;a
P1: Pisarz(1);
P2: Pisarz(2);
C3: Czytelnik(3);
C1: Czytelnik(1);
C2: czytelnik(2);
-- komentarz --
task body czytelnia is
iluczyta: Integer := 0;
begin
loop
select
accept Koniec;
iluczyta := iluczyta - 1;
or
accept ChceCzytac;
iluczyta := iluczyta + 1;
or
accept ChcePisac;
while iluczyta > 0 loop
accept Koniec;
iluczyta := iluczyta - 1;
end loop;
accept Mozesz;
accept Koniec;
end select;
end loop;
end czytelnia;
CZ: czytelnia;
task body Czytelnik is
begin
loop
Cz.ChceCzytac;
Put("Jestem czytajacym czytelnikiem o ID: ");
Put(id);
Put("Koncze czytac");
New_Line;
Cz.Koniec;
end loop;
end Czytelnik;
task body Pisarz is
begin
loop
Cz.ChcePisac;
Cz.Mozesz;
Put("Jestem PiSHaCZym pisarzem o numerze: ");
Put(num);
New_Line;
Cz.Koniec;
end loop;
end Pisarz;
begin
null;
end beznumerka;