Pristine Ack-5.5
[Ack-5.5.git] / lang / m2 / libm2 / CSP.def
1 DEFINITION MODULE CSP;
2 (*
3   Module:       Communicating Sequential Processes
4   From:         "A Modula-2 Implementation of CSP",
5                 M. Collado, R. Morales, J.J. Moreno,
6                 SIGPlan Notices, Volume 22, Number 6, June 1987.
7   Version:      $Id: CSP.def,v 1.3 1994/06/24 12:48:22 ceriel Exp $
8
9    See this article for an explanation of the use of this module.
10 *)
11
12   FROM SYSTEM IMPORT BYTE;
13
14   TYPE Channel;
15
16   PROCEDURE COBEGIN;
17   (* Beginning of a COBEGIN .. COEND structure *)
18
19   PROCEDURE COEND;
20   (* End of a COBEGIN .. COEND structure *)
21
22   PROCEDURE StartProcess(P: PROC);
23   (* Start an anonimous process that executes the procedure P *)
24
25   PROCEDURE StopProcess;
26   (* Terminate a Process (itself) *)
27
28   PROCEDURE InitChannel(VAR ch: Channel);
29   (* Initialize the channel ch *)
30
31   PROCEDURE GetChannel(ch: Channel);
32   (* Assign the channel ch to the process that gets it *)
33
34   PROCEDURE Send(data: ARRAY OF BYTE; VAR ch: Channel);
35   (* Send a message with the data to the cvhannel ch *)
36
37   PROCEDURE Receive(VAR ch: Channel; VAR dest: ARRAY OF BYTE);
38   (* Receive a message from the channel ch into the dest variable *)
39
40   PROCEDURE SELECT(n: CARDINAL);
41   (* Beginning of a SELECT structure with n guards *)
42
43   PROCEDURE NEXTGUARD(): CARDINAL;
44   (* Returns an index to the next guard to be evaluated in a SELECT *)
45
46   PROCEDURE GUARD(cond: BOOLEAN; ch: Channel;
47                   VAR dest: ARRAY OF BYTE): BOOLEAN;
48   (* Evaluates a guard, including reception management *)
49
50   PROCEDURE ENDSELECT(): BOOLEAN;
51   (* End of a SELECT structure *)
52
53 END CSP.