-- PSBDefs.Mesa  Edited by Sandman on June 30, 1980  5:01 PM
-- Copyright  Xerox Corporation 1979, 1980

DIRECTORY
  ControlDefs USING [FrameHandle],
  ProcessDefs USING [Priority, Ticks];

PSBDefs: DEFINITIONS =
  BEGIN

  MonitorLock: TYPE = MACHINE DEPENDENT RECORD [
    lock: {locked, unlocked}, -- priority: Priority,
    queue: PackedQueue];

  MonitorHandle: TYPE = POINTER TO MonitorLock;
  LockedEmpty: MonitorLock = [locked, Empty];
  UnlockedEmpty: MonitorLock = [unlocked, Empty];

  -- NOTE: Both fields of a MonitorLock are packed into the same word, with
  --   the lock in the high-order bit and "locked" represented by zero, so
  --   that a MonitorHandle to a locked MonitorLock can be loopholed into a
  --   QueueHandle.

  Condition: TYPE = MACHINE DEPENDENT RECORD [
    wakeupWaiting: {no, yes}, queue: PackedQueue, timeout: ProcessDefs.Ticks];

  ConditionHandle: TYPE = POINTER TO Condition;

  -- NOTE: The first two fields of a Condition are packed into the same word,
  --   with wakeupWaiting in the high-order bit and "no" represented by zero,
  --   so that a ConditionHandle to a Condition without a waiting wakeup can
  --   be loopholed into a QueueHandle.

  ProcessHandle: TYPE = POINTER TO PSB;

  PSB: TYPE = MACHINE DEPENDENT RECORD [
    link: ProcessHandle,
    cleanup: ProcessHandle,
    timeout: ProcessDefs.Ticks,
    enterFailed: BOOLEAN,
    detached: BOOLEAN,
    fill: [0..37B],
    state: {frameReady, frameTaken, dead, alive},
    timeoutAllowed, abortPending, timeoutPending, waitingOnCV: BOOLEAN,
    priority: ProcessDefs.Priority,
    frame: ControlDefs.FrameHandle];

  PackedQueue: TYPE = POINTER [0..77777B] TO PSB;
  Empty: PackedQueue = FIRST[PackedQueue];

  END.