Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with Ada.Text_Io; use Ada.Text_Io;
- procedure THREE_TASKS is
- --Deklarasi Variael Global
- COUNT, I, J : INTEGER range 0 .. INTEGER'LAST := 0;
- --Spesifikasi tipe task
- task INC is
- entry UPDATE(C: in out INTEGER);
- end INC;
- task ONE;
- task TWO;
- --Bodi tipe task
- --rendezvous task
- task body INC is
- begin
- loop
- accept UPDATE (C : in out INTEGER) do
- C := C+1;
- end UPDATE;
- end loop;
- end INC;
- task body One is
- begin
- Ada.Text_IO.Put("Mulai TASK_ONE");
- New_Line;
- loop
- I := I+1;
- if I = 50 then exit; end if;
- INC.UPDATE(COUNT);
- Ada.Text_IO.Put("TASK_ONE :" & Integer'Image(I) & " COUNT =" & Integer'Image(COUNT));
- New_Line;
- delay 1.1;
- end loop;
- end ONE;
- task body TWO is
- begin
- Ada.Text_IO.Put("Mulai TASK_TWO");
- New_Line;
- loop
- J := J+1;
- if J = 50 then exit; end if;
- INC.UPDATE(COUNT);
- Ada.Text_IO.Put("TASK_TWO :" & Integer'Image(J) & " COUNT =" & Integer'Image(COUNT));
- New_Line;
- delay 0.7;
- end loop;
- end TWO;
- --program utama
- begin -- THREE_TASKS
- -- TASK INC, ONE dan TWO semuanya akan memulai eksekusi segera
- -- setelah kendali mencapai titik ini, bahkan sebelum sesuatu
- -- statemen dalam program utama dieksekusi.
- -- Ada standard tidak menetapkan urutan task mana yang mulai pertama.
- -- null
- Ada.Text_IO.Put("Mulai contoh Rendezvous dalam Ada, Shared Variable Problem");
- New_Line;
- end THREE_TASKS;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement