<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">DEFINITION MODULE Semaphores;
(*
  Module:	Processes with semaphores
  Author:	Ceriel J.H. Jacobs
  Version:	$Id$

  On systems using quasi-concurrency, the only opportunities for process-
  switches are calls to Down and Up.
*)

  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 &gt; 0, then just decrement "s".
     Else, suspend the current process until the semaphore becomes
     positive again.
  *)

  PROCEDURE Up(VAR s: Sema);
  (* Increment the semaphore "s".
  *)

  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.
</pre></body></html>