home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / xco212p.zip / ISODEF / semaphor.def < prev    next >
Text File  |  1995-03-27  |  1KB  |  42 lines

  1. DEFINITION MODULE Semaphores;
  2.  
  3.   (* Provides mutual exclusion facilities for use by processes. *)
  4.  
  5. TYPE
  6.   SEMAPHORE;
  7.  
  8. PROCEDURE Create (VAR s: SEMAPHORE; initialCount: CARDINAL );
  9.   (* Creates and returns s as the identity of a new semaphore that has its associated count
  10.      initialized to initialCount, and has no processes yet waiting on it.
  11.   *)
  12.  
  13. PROCEDURE Destroy (VAR s: SEMAPHORE);
  14.   (* Recovers the resources used to implement the semaphore s, provided that no process is
  15.      waiting for s to become free.
  16.   *)
  17.  
  18. PROCEDURE Claim (s: SEMAPHORE);
  19.   (* If the count associated with the semaphore s is non-zero, decrements this count and
  20.      allows the calling process to continue; otherwise suspends the calling process until
  21.      s is released.
  22.   *)
  23.  
  24. PROCEDURE Release (s: SEMAPHORE);
  25.   (* If there are any processes waiting on the semaphore s, allows one of them
  26.      to enter the ready state; otherwise increments the count associated with s.
  27.   *)
  28.  
  29. PROCEDURE CondClaim (s: SEMAPHORE): BOOLEAN;
  30.   (* Returns TRUE if the call Claim(s) would cause the calling process to be suspended;
  31.      in this case the count associated with s is not changed. Otherwise returns TRUE and
  32.      the associated count is decremented.
  33.   *)
  34.  
  35. PROCEDURE IsSemaphoreException(): BOOLEAN;
  36.   (* Returns TRUE if the current coroutine is in the exceptional execution state because
  37.      of the raising of the Semaphores exception; otherwise returns FALSE.
  38.   *)
  39.  
  40. END Semaphores.
  41.  
  42.