DeviceCleanupImpl.mesa (device turn off/on during outload/inload)
Copyright © 1985 by Xerox Corporation. All rights reserved.
Andrew Birrell May 25, 1983 6:26 pm
Russ Atkinson (RRA) February 19, 1985 2:19:01 pm PST
DIRECTORY
DeviceCleanup USING [Item, Linkage, Reason],
MPCodes USING [cleaningUp],
PrincOps USING [FrameHandle, Port],
PrincOpsUtils USING [ GetReturnFrame, GetReturnLink, MyLocalFrame, SetReturnLink],
Process USING [InitializeMonitor],
ProcessorFace USING [SetMP];
DeviceCleanupImpl: MONITOR
IMPORTS PrincOpsUtils, Process, ProcessorFace
EXPORTS DeviceCleanup
SHARES DeviceCleanup = {
linkage: PUBLIC DeviceCleanup.Linkage;
InitializeDeviceCleanup: PUBLIC PROC = {
reason: DeviceCleanup.Reason;
pItem: POINTER TO Item;
Process.InitializeMonitor[@LOCK]; -- because our main program is never executed
pItemFirst ← NIL;
LOOPHOLE[AwaitPerform, PrincOps.Port].dest ← PrincOpsUtils.GetReturnLink[];
linkage.Perform ← LOOPHOLE[@AwaitPerform];
DO
linkage.Await ← LOOPHOLE[Install];
reason ← AwaitPerform[];
ProcessorFace.SetMP[MPCodes.cleaningUp];
linkage.Await ← LOOPHOLE[PrincOpsUtils.MyLocalFrame[]];
FOR pItem ← pItemFirst, pItem.pItemNext WHILE pItem ~= NIL DO
[] ← pItem.Procedure[reason] -- value should be pItem
ENDLOOP
ENDLOOP
};
AwaitPerform: PORT RETURNS [reason: DeviceCleanup.Reason];
Install: ENTRY PROC [pItem: POINTER TO Item] = {
fCaller: PrincOps.FrameHandle = PrincOpsUtils.GetReturnFrame[]; -- cleanup procedure
pItem^ ← [pItemNext: pItemFirst, Procedure: LOOPHOLE[fCaller]];
pItemFirst ← pItem;
PrincOpsUtils.SetReturnLink[fCaller.returnlink]
};
Item: PUBLIC TYPE = RECORD [
pItemNext: POINTER TO Item,
Procedure: PROC [DeviceCleanup.Reason] RETURNS [POINTER TO Item] ← NULL];
pItemFirst: POINTER TO Item; -- list of waiting cleanup procedures
}.