Yurttas/PL/IL/Ada-95/F/06/trains/trains 02.adb
Jump to navigation
Jump to search
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_02.adb
15
16
17with Ada.Text_IO;
18use Ada.Text_IO;
19
20procedure Trains_02 is
21
22 Train : Integer;
23
24 procedure Approach_Points is
25 begin
26 Put_Line("...Approach_Points");
27 end Approach_Points;
28
29 procedure Cross_Points is
30 begin
31 Put_Line(" Cross_Points");
32 end Cross_Points;
33
34 procedure Go_Away_From_Points(T: Integer) is
35 begin
36 Put_Line(" Go_Away_From_Points...");
37 Train := T;
38 end Go_Away_From_Points;
39
40 task Points is
41 entry Enter;
42 entry Leave;
43 end Points;
44
45 task body Points is
46 begin
47 loop
48 accept Enter;
49 accept Leave;
50 exit when Train=2;
51 end loop;
52 end Points;
53
54 task Train2;
55
56 task Train1;
57
58 task body Train2 is
59 begin
60 Approach_Points;
61 Points.Enter;
62 Cross_Points;
63 Points.Leave;
64 Go_Away_From_Points(2);
65 end Train2;
66
67 task body Train1 is
68 begin
69 Approach_Points;
70 Points.Enter;
71 Cross_Points;
72 Points.Leave;
73 Go_Away_From_Points(1);
74 end Train1;
75
76begin
77
78 null;
79
80end Trains_02;