ack/lang/m2/libm2/Semaphores.def

28 lines
735 B
Modula-2
Raw Normal View History

1987-05-13 14:36:45 +00:00
DEFINITION MODULE Semaphores;
TYPE Sema;
PROCEDURE Level(s: Sema) : CARDINAL;
(* Returns current value of semaphore s *)
PROCEDURE NewSema(n: CARDINAL) : Sema;
(* Creates a new semaphore with initial level "n" *)
PROCEDURE Down(VAR s: Sema);
(* If the value of "s" is > 0, then just decrement "s".
Else, suspend the current process until the semaphore becomes
positive again.
May result in a process switch.
*)
PROCEDURE Up(VAR s: Sema);
(* Increment the semaphore "s".
This call may result in a process switch
*)
PROCEDURE StartProcess(P: PROC; n: CARDINAL);
(* Create a new process with procedure P and workspace of size "n".
Also transfer control to it.
*)
END Semaphores.