-- File: DispatcherLockedFast.mesa, Last Edit: HGM April 7, 1979 2:59 PM

-- Copyright Xerox Corporation 1979, 1980

-- Need
to add DispatcherLockedFast to PupInnerDefs

DIRECTORY
-- PupIn
nerDefs: FROM "PupInnerDefs",-- -- EXPORTS
DriverDefs: FROM "DriverDefs" USING [
dispatcherLock, dispatcherReady, globalInputQueue, globalOutputQueue,
ReturnFreeBuffer],
BufferDefs: FROM "BufferDefs" USING [Buffer, Enqueue];

DispatcherLockedFast: MONITOR LOCKS DriverDefs.dispatcherLock

IMPORTS DriverD
efs, BufferDefs
EXPORTS --PupInnerDefs, --DriverDefs
SHARES BufferDefs =
BEGIN

-- These are called from interrupt routines,
on the Alto, they must be locked in memory

PutOnGlobalInputQueue: PUBLIC ENTRY PROCEDURE [b: BufferDefs.Buffer] =
BEGIN
BufferDefs.Enqueue[@DriverDefs.globalInputQueue,b];
NOTIFY DriverDefs.dispatcherReady;
END;

PutOnGlobalDoneQueue: PUBLIC PROCEDURE [b: BufferDefs.Buffer] =
BEGIN
IF ~b.allNets AND b.requeueProcedure=DriverDefs.ReturnFreeBuffer THEN
DriverDefs.ReturnFreeBuffer[b]
ELSE PutOnGlobalDoneQueueLocked[b];
END;

PutOnGlobalDoneQueueLocked: ENTRY PROCEDURE [b: BufferDefs.Buffer] = INLINE
BEGIN
BufferDefs.Enqueue[@DriverDefs.globalOutputQueue,b];
NOTIFY DriverDefs.dispatcherReady;
END;

END. -- DispatcherLockedFast