-- RTProcess.Mesa
-- last edited September 9, 1982 9:34 am by Paul Rovner

DIRECTORY
Process USING[Priority],
RTBasic USING[TV],
PSB USING[PsbIndex];

RTProcess: DEFINITIONS
= BEGIN OPEN RTBasic;

-- TYPEs
Handle: TYPE = REF Object;
Object: TYPE;

Status: TYPE = {stopped, ready, waitingCV, waitingML, pageFault, invalid};


-- SIGNALs
InvalidProcess: ERROR[h: Handle];

NotStopped: ERROR[h: Handle];

InvalidPriority: ERROR[h: Handle, p: Process.Priority];


-- PROCs for dealing with Cedar processes

GetStatus: PROC[h: Handle] RETURNS[Status];

Stop: PROC[h: Handle];

Proceed: PROC[h: Handle];

ReturnFrom: PROC[h: Handle, frameFromWhichToReturn: TV, result: TVNIL];
-- raises NotStopped

Abort: PROC[h: Handle];
-- raises NotStopped

TopFrame: PROC[h: Handle] RETURNS[TV--for a frame--];
-- raises NotStopped

ChangePriority: PROC[h: Handle, new: Process.Priority]
RETURNS[old: Process.Priority];
-- raises NotStopped, InvalidPriority

Current: PROC RETURNS[Handle];

PSBIToHandle: PROC[psbi: PSB.PsbIndex] RETURNS[Handle];
-- returns NIL if psbi isn't a Cedar rpocess

HandleToPSBI: PROC[h: Handle] RETURNS[PSB.PsbIndex];

EnumerateCedarProcesses: PROC[p: PROC[Handle] RETURNS[stop: BOOLEAN]]
RETURNS[stopped: BOOLEAN];

Valid: PROC[h: Handle] RETURNS[BOOLEAN];

PageFaults: PROC[h: Handle] RETURNS[LONG INTEGER];

CellsAllocated: PROC[h: Handle] RETURNS[LONG INTEGER];

RegisterTerminationNotifier: PROC[h: Handle, p: PROC[Handle]];

-- escape hatch
SetAttachment: PROC[h: Handle, attachment: REF ANY];
GetAttachment: PROC[h: Handle] RETURNS[REF ANY];


--PROCs for dealing with non-Cedar processes
IsAlive: PROC[psbi: PSB.PsbIndex] RETURNS[BOOLEAN];

--PROCs for controlling the page fault watcher
StartWatchingFaults: PROC;
StopWatchingFaults: PROC;

GetTotalPageFaults: PROC RETURNS[LONG INTEGER];
GetPSBIPageFaults: PROC[psbi: PSB.PsbIndex] RETURNS[LONG INTEGER];
ClearFaultHistory: PROC;
EnumerateFaultingProcesses: PROC[p: PROC[psbi: PSB.PsbIndex,
pageFaultCount, numberEnumerated: LONG INTEGER]
RETURNS[stop: BOOLEAN]]
RETURNS[stopped: BOOLEAN];

END.