Text preview for : Process.mesa_Oct77.pdf part of xerox Process.mesa Oct77 xerox mesa 3.0_1977 listing Process.mesa_Oct77.pdf



Back to : Process.mesa_Oct77.pdf | Home

process.mESA 24-0CT-77 18:38:25 Page 1


-- File Process.Mesa
-- Last edited by Sandman on August 23, 1977 9:49 PM
DIRECTORY
FrameDefs: FROM "framedefs",
InlineDefs: FROM "inlinedefs",
SystemDefs: FROM "systemdefs",
ControlDefs: FROM "controldefs",
ProcessDe fs: FROM "processdefs";
DEFINITIONS FROM
InlineDefs, ControlDefs, ProcessDefs;
Process: PROGRAM IMPORTS FrameDefs, SystemDefs EXPORTS ProcessDefs SHARES ProcessDefs =
BEGIN
PVector: POINTER TO ProcessVector ~ PV;
PriorityNotAvailable: PUBLIC ERROR = CODE;
InvalidPriority: PUBLIC ERROR = CODE;
InvalidProcess: PUBLIC ERROR = CODE;
ProcessNotScheduled: PUBLIC ERROR = CODE;
ValidatePriority: PROCEDURE[p: ProcessPriority]
BEGIN
IF P = Unscheduled OR
p IN [HighestProcessPriority .. LowestProcessPriority] THEN RETURN;
ERROR InvalidPriority;
END;

ValidateProcess: PROCEDURE[p:ProcessHandle] =
BEGIN
ValidatePriority[p.pn I InvalidPriority =) ERROR InvalidProcess ];
IF p.pn = Unscheduled THEN RETURN;
IF PVector[p.pn] # p THEN ERROR InvalidProcess;
END;

CreateProcessFromFrame: PUBLIC PROCEDURE [frame: FrameHandle. priority: ProcessPriority]
RETURNS [p: ProcessHandle] =
BEGIN OPEN p.state;
ValidatePriority[priority];
IF PVector[priority] # ProcessNIL THEN ERROR PriorityNotAvailable;
p~SystemDefs.AllocateHeapNode[SIZE[ProcessObject]];
instbyte"O;
IF FrameDefs.Class[frame] = global THEN
BEGIN
stkptr" 1;
stk[O] ~ 0;
END
ELSE stkptr .. 0;
X ~ frame;
y ~ 0;
p.pn .. priority;
IF priority # Unscheduled THEN PVector[priority] ~ p;
END:

CreateProcessrromProcedure: PUBLIC PROCEDURE [proc: PROCEDURE, priority: ProcessPriorily]
RrTURNS [p: Processllandle] =
B[GIN OprN p.slale:
Val idatePriorily[priority]:
IF PVeclor[priorily] # ProcessNIL TIIFN [RROR PriorityNotAvailable:

p"SystemDefs.AllocatelleapNode[SIZE[ProcessObject]]:
lns lbyLe"O;
stkpLr"O;
X"proc;
y .. O;
p.pn"pr iOI' ity;
IF pr ior i ty # Unschedul ad TIIrN PVactol'[pr ior i ly]"p;
[NO;
Oestl'oyProcess: PUBl Ie PRocrDuRr [p: Processllandle] =
process.mESA 24-0CT-77 18:38:25 Page 2


BEGIN
ValidateProcess[p];
SetProcessPriority[p, Unscheduled];
SystemDefs.FreeHeapNode[p];
END;

MakeProcessReady: PUBLIC PROCEDURE [p: ProcessHandle] =
BEGIN
ValidateProcess[p];
IF p.pn = Unscheduled THEN ERROR ProcessNotScheduled:
DisableInterrupts[];
RP~ ~ BITOR[RP~.BITSHIFT[1,p.pn]];
WakeupsWaiting~ ~ BITOR[WakeupsWaiting~,BITSHIFT[1.p.pn]];
EnableInterrupts[];
RETURN
END:

ActivateProcess: PUBLIC PROCEDURE [p: ProcessHandle] =
BEGIN
ValidateProcess[p]:
IF p.pn = Unscheduled THEN ERROR ProcessNotScheduled:
DisableInterrupts(]:
AP~ ~ BITOR[AP~.BITSHIFT[1.p.pn]];
ActiveWord~ ~ BITOR[ActiveWord~.BITSHIFT[l.p.pn]];
EnableInterrupts[]:
RETURN
END;

DeActivateProcess: PUBLIC PROCEDURE [p: ProcessHandle] =
BEGIN
ValidateProcess[p];
IF p.pn = Unscheduled THEN ERROR ProcessNotScheduled;
DisableInterrupts[];
AP~ ~ BITAND[AP~,BITNOT[BITSHIFT[l.p.pn]]];
ActiveWord~ ~ BITAND[ActiveWord~.BITNOT[BITSHIfT[l.p.pn]]];
EnableInterrupts[];
RETURN
END;

EnumerateProcess: PUBLIC PROCEDURE [proc: PROCEDURE[ProcessHandle] RETURNS [BOOLEAN]]
RETURNS [p: ProcessHandle] =
BEGIN
i: ProcessPriority:
FOR i IN [HighestProcessPriority .. LowestProcessPriority] DO
IF (ppPVector[i]) 1/ ProcessNIL AND pI/NIL THEN
IF proc[p] THEN RETURN;
ENDLOOP;
RETURN [ProcessNIL]
END:

SetProcessPriority: PUBLIC PROCEDURE [p: ProcessHandle. priority: ProcessPriority]
BfGIN
m: WORD:
ValidateProces~[p];
IF PVector[priority] 1/ ProcessNIL THEN ERROR PriorityNotAvailable;
IF p.pn 1/ Unscheduled TUEN
BEGIN
m ~ BITNOT[BITSIlIrT[l,p.pn]];
Disablelnterrupts[];
RP' ~ BITAND[RP~,m];
WakeupsWaiLin9' p BITAND[WakeupsWaitin9~.m];
AP' ~ BITANO[APt,m];
ActiveWord~ p BITANO[ActiveWordt,m];
PVector[p.pn] ~ ProcessNIL;
[nableInterrupts[];
rND;
p.pn~priority;
Ir pr ior i Ly 1/ Unscheduled TIIrN PVector[pr ior i ly] P p;
FND;
GeLProcessPI'iol'ily: PUBLIC PIlOCroURf [p: Processllandle] R[TURNS [ProcessPriol'ily]
process.mESA 24-0CT-77 18:38:25 Page 3


BEGIN
ValidateProcess[p];
RETURN [p.pn]
END;
GetCurrentProcess: PUBLIC PROCEDURE RETURNS [ProcessHandle] =
BEGIN
RETURN [PVector[CPNt]]
END;
GetCurrentPriority: PUBLIC PROCEDURE RETURNS [ProcessPriority]
BEGIN
RETURN [CPNt]
END;

END ...