-- File: DispatcherCold.mesa, Last Edit: HGM November 12, 1979 5:35 PM
-- Copyright Xerox Corporation 1979, 1980
DIRECTORY
StatsDefs: FROM "StatsDefs" USING [StatIncr],
DriverDefs: FROM "DriverDefs" USING [
dispatcherLock, dispatcherReady, dispatcherPleaseDie,
globalInputQueue, globalOutputQueue, MainDispatcher,
Network, Router, RouterObject,
doStats, doDebug, giantVector, GiantVector],
CommUtilDefs: FROM "CommUtilDefs" USING [SetTimeout, MsecToTicks],
BufferDefs: FROM "BufferDefs" USING [
Buffer, ReturnFreeBuffer, QueueCleanup, QueueInitialize];
DispatcherCold: MONITOR LOCKS DriverDefs.dispatcherLock
IMPORTS CommUtilDefs, StatsDefs, DriverDefs, BufferDefs
EXPORTS DriverDefs =
BEGIN
pupRouter: PUBLIC DriverDefs.Router ← @dummyRouter;
mainFork: PROCESS;
dummyRouter: DriverDefs.RouterObject ← [
input: DummyInputer,
broadcast: DummyBroadcaster,
addNetwork: DummyAddDelete,
removeNetwork: DummyAddDelete ];
Buffer: TYPE = BufferDefs.Buffer;
DummyInputer: PUBLIC PROCEDURE [b: Buffer] =
BEGIN
IF DriverDefs.doStats THEN StatsDefs.StatIncr[statPacketsDiscarded];
BufferDefs.ReturnFreeBuffer[b];
END;
DummyBroadcaster: PROCEDURE [b: Buffer] =
BEGIN
b.requeueProcedure[b];
END;
DummyAddDelete: PROCEDURE [DriverDefs.Network] = BEGIN END;
DispatcherOn: PUBLIC PROCEDURE =
BEGIN
DriverDefs.dispatcherPleaseDie ← FALSE;
BufferDefs.QueueInitialize[@DriverDefs.globalInputQueue];
BufferDefs.QueueInitialize[@DriverDefs.globalOutputQueue];
mainFork ← FORK DriverDefs.MainDispatcher[];
END;
SetPupRouter: PUBLIC PROCEDURE [router: DriverDefs.Router] =
BEGIN
IF router=NIL THEN router ← @dummyRouter;
pupRouter ← router;
END;
DispatcherOff: PUBLIC PROCEDURE =
BEGIN
DispatcherOffLocked[];
JOIN mainFork;
BufferDefs.QueueCleanup[@DriverDefs.globalInputQueue];
BufferDefs.QueueCleanup[@DriverDefs.globalOutputQueue];
END;
DispatcherOffLocked: ENTRY PROCEDURE = INLINE
BEGIN
DriverDefs.dispatcherPleaseDie ← TRUE;
NOTIFY DriverDefs.dispatcherReady;
END;
-- initialization
CommUtilDefs.SetTimeout[@DriverDefs.dispatcherReady,CommUtilDefs.MsecToTicks[30000]];
IF DriverDefs.doDebug THEN
BEGIN
debugPointer: LONG POINTER TO DriverDefs.GiantVector ← DriverDefs.giantVector;
debugPointer.globalInputQueue ← @DriverDefs.globalInputQueue;
debugPointer.globalOutputQueue ← @DriverDefs.globalOutputQueue;
END;
END. -- DispatcherCold