Pristine Ack-5.5
[Ack-5.5.git] / lang / m2 / libm2 / Semaphores.def
1 DEFINITION MODULE Semaphores;
2 (*
3   Module:       Processes with semaphores
4   Author:       Ceriel J.H. Jacobs
5   Version:      $Id: Semaphores.def,v 1.3 1994/06/24 12:49:38 ceriel Exp $
6
7   On systems using quasi-concurrency, the only opportunities for process-
8   switches are calls to Down and Up.
9 *)
10
11   TYPE Sema;
12
13   PROCEDURE Level(s: Sema) : CARDINAL;
14   (* Returns current value of semaphore s *)
15
16   PROCEDURE NewSema(n: CARDINAL) : Sema;
17   (* Creates a new semaphore with initial level "n" *)
18
19   PROCEDURE Down(VAR s: Sema);
20   (* If the value of "s" is > 0, then just decrement "s".
21      Else, suspend the current process until the semaphore becomes
22      positive again.
23   *)
24
25   PROCEDURE Up(VAR s: Sema);
26   (* Increment the semaphore "s".
27   *)
28
29   PROCEDURE StartProcess(P: PROC; n: CARDINAL);
30   (* Create a new process with procedure P and workspace of size "n".
31      Also transfer control to it.
32   *)
33 END Semaphores.