DIRECTORY Process USING [DisableTimeout, EnableAborts]; Queue: CEDAR DEFINITIONS LOCKS queue USING queue: Queue IMPORTS Process = BEGIN length: CARDINAL = 12; Queue: TYPE = REF QueueRep; QueueRep: TYPE = MONITORED RECORD [ body: ARRAY [FIRST[CARDINAL]..length) OF WORD, head, tail: CARDINAL _ FIRST[CARDINAL], nonEmpty: CONDITION]; Empty: ENTRY PROCEDURE [queue: Queue] RETURNS [empty: BOOLEAN] = INLINE {ENABLE UNWIND => NULL; RETURN[empty: queue.tail = queue.head]}; Full: ENTRY PROCEDURE [queue: Queue] RETURNS [full: BOOLEAN] = INLINE BEGIN ENABLE UNWIND => NULL; RETURN[full: (queue.tail + 1) MOD length = queue.head]; END; Initialize: ENTRY PROC [queue: Queue] = TRUSTED INLINE BEGIN ENABLE UNWIND => NULL; local: QueueRep _ queue^; Process.DisableTimeout[condition: @local.nonEmpty]; Process.EnableAborts[pCondition: @local.nonEmpty]; RETURN; END; Pop: ENTRY PROCEDURE [queue: Queue] RETURNS [item: WORD] = INLINE BEGIN ENABLE UNWIND => NULL; IF queue.tail = queue.head THEN WAIT queue.nonEmpty; item _ queue.body[queue.head]; queue.head _ SUCC[queue.head] MOD length; RETURN; END; Push: ENTRY PROCEDURE [queue: Queue, item: WORD] = INLINE BEGIN ENABLE UNWIND => NULL; queue.body[queue.tail] _ item; queue.tail _ SUCC[queue.tail] MOD length; NOTIFY queue.nonEmpty; RETURN; END; END. ’Queue.mesa Copyright Σ Xerox Corporation 1987. All rights reserved. Tim Diebert: April 27, 1987 1:56:28 pm PDT Constants: TYPEs: INLINE ENTRY PROCEDUREs: Κ²˜šœ ™ Jšœ8™8Icode™*—J˜šΟk ˜ Jšœœ ˜-—J˜šΠlnœœ ˜Jšœœ ˜Jšœ ˜J™JšΟb ™ —˜Jšœœ˜—˜JšŸ™—˜Jšœœœ ˜šœ œ œœ˜#Jš œœœœ œœ˜.Jšœ œœœ˜'Jšœ  œ˜——˜Jšœ™—˜š Οnœœ œœ œ˜GJš œœœœœ"˜@——˜š  œœ œœœ ˜KJšœœœ˜Jšœœ˜7Jšœ˜——˜š   œœœœœ˜