Yurttas/PL/IL/Ada-95/F/06/trains/trains 04.adb

 1--
 2-- Copyright(C) 1998
 3-- All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4--
 5-- Permission to use, copy, modify, and distribute this
 6-- software and its documentation for EDUCATIONAL purposes
 7-- and without fee is hereby granted provided that this
 8-- copyright notice appears in all copies.
 9--
10 
11-- date   : January 1, 1998.
12-- authorĀ : Salih Yurttas.
13
14-- trains_04.adb
15
16
17with Ada.Text_IO;
18use Ada.Text_IO;
19
20procedure Trains_04 is
21
22  package Int_IO is new Integer_IO(Integer);
23  use Int_IO;
24
25  Train : Integer := 0;
26
27  procedure Approach_Points is
28  begin
29    Put_Line("...Approach_Points");
30  end Approach_Points;
31
32  procedure Cross_Points is
33  begin
34    Put_Line("   Cross_Points");
35  end Cross_Points;
36
37  procedure Go_Away_From_Points is
38  begin
39    Put_Line("   Go_Away_From_Points...");
40  end Go_Away_From_Points;
41
42  task Points is
43    entry Enter;
44    entry Leave;
45  end Points;
46
47  task body Points is
48  begin
49    loop
50      Train := Train+1;
51      Put(Train);
52      New_Line;
53      accept Enter;
54      accept Leave;
55      exit when Train=2;
56    end loop;
57  end Points;
58
59  task Train1;
60
61  task body Train1 is
62  begin
63    Approach_Points;
64    Points.Enter;
65    Cross_Points;
66    Points.Leave;
67    Go_Away_From_Points;
68  end Train1;
69
70  task Train2;
71
72  task body Train2 is
73  begin
74    Approach_Points;
75    Points.Enter;
76    Cross_Points;
77    Points.Leave;
78    Go_Away_From_Points;
79  end Train2;
80
81begin
82
83  null;
84
85end Trains_04;