]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/m2/gm2-libs-iso/Semaphores.def
Merge modula-2 front end onto gcc.
[thirdparty/gcc.git] / gcc / m2 / gm2-libs-iso / Semaphores.def
1 (* Library module defined by the International Standard
2 Information technology - programming languages
3 BS ISO/IEC 10514-1:1996E Part 1: Modula-2, Base Language.
4
5 Copyright ISO/IEC (International Organization for Standardization
6 and International Electrotechnical Commission) 1996-2021.
7
8 It may be freely copied for the purpose of implementation (see page
9 707 of the Information technology - Programming languages Part 1:
10 Modula-2, Base Language. BS ISO/IEC 10514-1:1996). *)
11
12 DEFINITION MODULE Semaphores;
13
14 (* Provides mutual exclusion facilities for use by processes. *)
15
16 TYPE
17 SEMAPHORE;
18
19 PROCEDURE Create (VAR s: SEMAPHORE; initialCount: CARDINAL );
20 (* Creates and returns s as the identity of a new semaphore that
21 has its associated count initialized to initialCount, and has
22 no processes yet waiting on it.
23 *)
24
25 PROCEDURE Destroy (VAR s: SEMAPHORE);
26 (* Recovers the resources used to implement the semaphore s,
27 provided that no process is waiting for s to become free.
28 *)
29
30 PROCEDURE Claim (s: SEMAPHORE);
31 (* If the count associated with the semaphore s is non-zero,
32 decrements this count and allows the calling process to
33 continue; otherwise suspends the calling process until
34 s is released.
35 *)
36
37 PROCEDURE Release (s: SEMAPHORE);
38 (* If there are any processes waiting on the semaphore s,
39 allows one of them to enter the ready state; otherwise
40 increments the count associated with s.
41 *)
42
43 PROCEDURE CondClaim (s: SEMAPHORE): BOOLEAN;
44 (* Returns FALSE if the call Claim(s) would cause the calling
45 process to be suspended; in this case the count associated
46 with s is not changed. Otherwise returns TRUE and the
47 associated count is decremented.
48 *)
49
50 END Semaphores.
51