/[cvs.andrew.net.au]/uni/COMP2310/lab4/mutual.adb
ViewVC logotype

Annotation of /uni/COMP2310/lab4/mutual.adb

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Mon Aug 15 06:21:13 2005 UTC (17 years, 7 months ago) by apollock
Branch: MAIN
CVS Tags: HEAD
Final

1 apollock 1.1 with Ada.Text_IO; use Ada.Text_IO;
2     with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
3     with Protected_Shared_Natural; use Protected_Shared_Natural;
4     procedure mutual is
5     Number_Of_Children : constant Positive := 4;
6     task type Next_Task(Id : Natural) is
7     entry Start;
8     entry Stop;
9     end Next_Task;
10     type Next_Task_Ptr is access Next_Task;
11     My_Task_Array : array(Integer range 0..Number_Of_Children-1) of Next_Task_Ptr;
12     My_Data : Shared_Natural(42);
13    
14     task body Next_Task is
15     Local_Value : Natural;
16     begin
17     accept Start do
18     null;
19     end Start;
20     for I in 1..10 loop
21     My_Data.Increment(Id);
22     delay 0.0;
23     end loop;
24     --Local_Value := My_Data.Read;
25     My_Data.Read(Local_Value);
26     Put("Final Value on Task "); Put(Local_Value); Put( Id); New_Line;
27     accept Stop do
28     null;
29     end Stop;
30     end Next_Task;
31    
32     Value : Natural;
33     begin
34     for I in My_Task_Array'Range loop
35     My_Task_Array(I) := new Next_Task(I);
36     end loop;
37     --Value := My_Data.Read;
38     My_Data.Read(Value);
39     Put("Initial Value on Master ");Put(Value);New_Line;
40     for I in My_Task_Array'Range loop
41     My_Task_Array(I).Start;
42     end loop;
43     for I in My_Task_Array'Range loop
44     My_Task_Array(I).Stop;
45     end loop;
46     --Value := My_Data.Read;
47     My_Data.Read(Value);
48     Put("Final Value on Master ");Put(Value);New_Line;
49     Value := My_Data.ReadCount;
50     Put("Number of reads "); Put(Value); New_Line;
51     end mutual;

  ViewVC Help
Powered by ViewVC 1.1.22