ASmallTestProgram.mesa
Robert Hagmann February 21, 1984 7:46:57 am PST
DIRECTORY
BasicTime USING [GetClockPulses, Pulses, PulsesToMicroseconds],
Commander USING [CommandProc, Handle, Register],
IO,
Process USING[ Pause, SecondsToTicks ],
VMInternal;
ASmallTestProgram: CEDAR PROGRAM
IMPORTS BasicTime, Commander, IO, Process, VMInternal
SHARES VMInternal =
BEGIN
OPEN VMInternal;
PrintVMStats: Commander.CommandProc = {
size: INT = lastRealPage;
DO
pinned: INT ← 0;
free: INT ← 0;
readonly: INT ← 0;
readonlyrefd: INT ← 0;
rwdirty: INT ← 0;
rwdirtyrefd: INT ← 0;
rwclean: INT ← 0;
rwcleanrefd: INT ← 0;
unmapped: INT ← 0;
page: INT ← RealPageNumber.FIRST;
totalpages: INT ← 0 ;
startPulse: BasicTime.Pulses = BasicTime.GetClockPulses[];
endPulse: BasicTime.Pulses;
microsecs: LONG CARDINAL ;
TRUSTED {
WHILE page <= size DO
totalpages ← totalpages.SUCC;
WITH rmMap[page] SELECT FROM
rmE: reclaimable RMMapEntry => {
vP: PageNumber = rmE.virtual;
vmEntry: VMMapEntry = GetVMMap[vP];
WITH vmE: vmEntry SELECT InOut[vmEntry] FROM
in => {
refed: BOOL = vmE.state.flags.referenced;
dirty: BOOL = vmE.state.flags.dirty OR rmE.needsBackingStoreWrite;
IF vmE.state.flags.readonly THEN {
IF refed THEN readonlyrefd ← readonlyrefd.SUCC
ELSE readonly ← readonly.SUCC;
}
ELSE {
IF dirty THEN {
IF refed THEN rwdirtyrefd ← rwdirtyrefd.SUCC
ELSE rwdirty ← rwdirty.SUCC;
}
ELSE {
IF refed THEN rwcleanrefd ← rwcleanrefd.SUCC
ELSE rwclean ← rwclean.SUCC;
};
};
};
out => {
unmapped ← unmapped.SUCC; -- probably being swapped in
};
ENDCASE;
};
rmE: free RMMapEntry => {
free ← free.SUCC ;
};
rmE: pinned RMMapEntry => {
pinned ← pinned.SUCC;
};
ENDCASE;
page ← page.SUCC;
ENDLOOP;
};
endPulse ← BasicTime.GetClockPulses[];
microsecs ← BasicTime.PulsesToMicroseconds[endPulse-startPulse];
IO.PutF[cmd.out, "\n VM Stats microsecs %g free: %g pinned: %g unmapped: %g\n", IO.card[microsecs], IO.int[free], IO.int[pinned], IO.int[unmapped]];
IO.PutF[cmd.out, " readonly: %g readonlyrefd: %g rwdirty: %g rwdirtyrefd: %g\n", IO.int[readonly], IO.int[readonlyrefd], IO.int[rwdirty], IO.int[rwdirtyrefd]];
IO.PutF[cmd.out, " rwclean: %g rwcleanrefd: %g total pages: %g\n", IO.int[rwclean], IO.int[rwcleanrefd], IO.int[totalpages]];
Process.Pause[Process.SecondsToTicks[5]];
ENDLOOP;
};
Commander.Register[key: "PrintVMStats", proc: PrintVMStats,
doc: "Print pinned, and non-pinned readonly, r/w dirty and r/w clean pages in memory"];
END.