-- Cedar Remote Debugging: processes - PrincOps-level interface

-- AMProcessBasic.mesa

-- Andrew Birrell February 3, 1983 10:43 am

DIRECTORY
AMProcess  USING[ State ],
PrincOps   USING[ ControlLink, Frame, FrameHandle, GFTIndex, NullLink ],
PSB    USING[ Priority, PsbIndex, PsbNull ],
WorldVM  USING[ World ];

AMProcessBasic: DEFINITIONS =

BEGIN

Abort: PROC[world: WorldVM.World, psbi: PSB.PsbIndex];


GFTable: TYPE = LONG POINTER TO PACKED ARRAY PrincOps.GFTIndex OF BOOL;

Info: PROC[world: WorldVM.World,
psbi: PSB.PsbIndex,
freeze, thaw, fullStatus: BOOL,
filter: GFTable,
wantedStates: PACKED ARRAY AMProcess.State OF BOOL]
RETURNS[
state: AMProcess.State,
faultData: LONG CARDINAL,
priority: PSB.Priority,
frame: PrincOps.FrameHandle,
frozenFrame: PrincOps.FrameHandle,
topFrame: PrincOps.FrameHandle];
-- NOTE: if "filter" is not NIL, it must be resident! --

Thaw: PROC[world: WorldVM.World, psbi: PSB.PsbIndex];


-- fixed facilities for process freezing, for access from AMTypes. --
freezer: PRIVATE READONLY POINTER TO local PrincOps.Frame;
Frozen: PRIVATE TYPE = ARRAY PSB.PsbIndex OF PrincOps.ControlLink;
freezees: PRIVATE READONLY LONG POINTER TO Frozen;

LocalLink: PROC[given: PrincOps.ControlLink, psbi: PSB.PsbIndex]
RETURNS[link: PrincOps.ControlLink] = INLINE
-- Returns the control link that would exist if there were no frozen processes. --
-- Assumes psbi is the process on whose stack the given link occurred. --
-- If called from resident code this procedure will not fault. --
BEGIN
IF (link ← given) = [frame[freezer]] AND freezer # NIL
THEN IF (link ← freezees[psbi]) = PrincOps.NullLink -- not really frozen! -- THEN link ← given;
END;

ReturnLink: PROC[world: WorldVM.World, frame: PrincOps.FrameHandle,
psbi: PSB.PsbIndex ← PSB.PsbNull]
RETURNS[link: PrincOps.ControlLink];
-- Returns the link that would exist if there were no frozen processes. --
-- Assumes frame is valid. --
-- If frame.returnlink is frozen, determines "real" link by looking in "freezees" array.
-- If psbi = PSB.PsbNull, determines psbi by enumerating all frozen processes (slowly).

END.