CpaImpl.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Willie-Sue, May 28, 1986 10:35:11 am PDT
microcode statistics, for Dorados only
DIRECTORY
BasicTime USING [GMT, Now, Period],
Cpa,
PrincOpsUtils USING [LongZero],
VM USING [PagesForWords, AddressForPageNumber, Interval, Pin, SimpleAllocate];
CpaImpl: CEDAR MONITOR
IMPORTS BasicTime, PrincOpsUtils, VM, Cpa =
BEGIN
cpaSpace: LONG POINTER TO Cpa.CpaRecord ← NIL;
cpaOn: BOOLFALSE;
beginCpa: BasicTime.GMT;
stopCpa: BasicTime.GMT;
CpaOn: ENTRY PROC = {
IF cpaOn THEN RETURN;
IF cpaSpace = NIL THEN {
nPages: INT = VM.PagesForWords[SIZE[Cpa.CpaRecord]];
interval: VM.Interval = VM.SimpleAllocate[nPages];
VM.Pin[interval];
cpaSpace ← LOOPHOLE[VM.AddressForPageNumber[interval.page]];
};
TRUSTED { PrincOpsUtils.LongZero[LOOPHOLE[cpaSpace], SIZE[Cpa.CpaRecord]] };
Cpa.CPA[cpaSpace];
beginCpa ← BasicTime.Now[];
cpaOn ← TRUE;
};
CpaOff: ENTRY PROC = {
IF ~cpaOn THEN RETURN;
Cpa.CPA[NIL];
stopCpa ← BasicTime.Now[];
cpaOn ← FALSE;
};
Time: ENTRY PROC RETURNS[INT] = {
IF cpaOn THEN {
Cpa.CPA[NIL];  -- turn off
stopCpa ← BasicTime.Now[];
cpaOn ← FALSE;
};
RETURN[BasicTime.Period[beginCpa, stopCpa]];
};
ECalls: ENTRY PROC RETURNS[LONG CARDINAL] = TRUSTED {
n: LONG CARDINAL ← 0;
ptr: LONG POINTER TO LONG CARDINAL ← @cpaSpace.efc0;
IF cpaSpace = NIL THEN RETURN[0];
IF cpaOn THEN {
Cpa.CPA[NIL];  -- turn off
stopCpa ← BasicTime.Now[];
cpaOn ← FALSE;
};
FOR i: INT IN [0..21B) DO
n ← n + ptr^;
ptr ← ptr+SIZE[LONG CARDINAL];
ENDLOOP;
RETURN[n];
};
LCalls: ENTRY PROC RETURNS[LONG CARDINAL] = TRUSTED {
n: LONG CARDINAL ← 0;
ptr: LONG POINTER TO LONG CARDINAL ← @cpaSpace.lfc1;
IF cpaSpace = NIL THEN RETURN[0];
IF cpaOn THEN {
Cpa.CPA[NIL];  -- turn off
stopCpa ← BasicTime.Now[];
cpaOn ← FALSE;
};
FOR i: INT IN [0..21B) DO
n ← n + ptr^;
ptr ← ptr+SIZE[LONG CARDINAL];
ENDLOOP;
RETURN[n];
};
AllCalls: PROC RETURNS[LONG CARDINAL] = TRUSTED {
IF cpaSpace = NIL THEN RETURN[0];
RETURN[ECalls[] + LCalls[] + cpaSpace.sfc + cpaSpace.kfcb]
};
END.