StorageAccounting.Mesa
last edited August 19, 1983 9:54 am by Paul Rovner
DIRECTORY
PrincOps USING[PsbIndex],
Process USING[GetCurrent],
Collector USING[InternalReclaim];
StorageAccounting: DEFINITIONS
IMPORTS Process, Collector
= BEGIN
TYPES
PSBIMap: TYPE =
RECORD[elements: SEQUENCE maxLength: [0..LAST[PrincOps.PsbIndex]+1] OF CellCount];
CellCount: TYPE = RECORD[total, current: LONG INTEGER];
CONSTANTS
defaultCollectionInterval: LONG CARDINAL = 40000B;
VARIABLES
nWordsRequested: INT;
nWordsAllocated: INT;
SUMnWordsAllocated: INT;
nWordsReclaimed: INT;
nObjectsCreated: INT;
nObjectsReclaimed: INT;
MapPsbiToWordsAllocated: LONG POINTER TO PSBIMap;
CollectionInterval: INT;
SuspensionThreshold: INT;
PROCS
ResetNWordsAllocated: PROC;
ResetTotalNWordsAllocatedOnly: PROC;
ConsiderCollection: PROC[requestedWords, suppliedWords: LONG CARDINAL] =
INLINE {
psbi: PrincOps.PsbIndex = LOOPHOLE[Process.GetCurrent[]];
nw: LONG INTEGER ← MapPsbiToWordsAllocated.elements[psbi].current + suppliedWords;
MapPsbiToWordsAllocated.elements[psbi].current ← nw;
nWordsAllocated ← nWordsAllocated + suppliedWords;
total count for all processes since the last colection
nWordsRequested ← nWordsRequested + requestedWords; -- total count for all processes
IF LOOPHOLE[nWordsAllocated, INT] >= CollectionInterval
THEN Collector.InternalReclaim[allocationInterval, nw > SuspensionThreshold];
};
END.