StorageAccountingImpl.Mesa
last edited August 19, 1983 9:56 am by Paul Rovner
DIRECTORY
AllocatorOps USING[permanentPageZone],
PrincOps USING[PsbIndex],
StorageAccounting USING[defaultCollectionInterval, PSBIMap],
SafeStorage USING[];
StorageAccountingImpl: MONITOR -- Protects the storage account books
IMPORTS AllocatorOps
EXPORTS StorageAccounting, SafeStorage
= BEGIN OPEN StorageAccounting;
VARIABLES
nWordsRequested: PUBLIC INT ← 0;
nWordsAllocated: PUBLIC INT ← 0; -- >= CollectionInterval implies collect
SUMnWordsAllocated: PUBLIC INT ← 0;
nWordsReclaimed: PUBLIC INT ← 0;
nObjectsCreated: PUBLIC INT ← 0;
nObjectsReclaimed: PUBLIC INT ← 0;
MapPsbiToWordsAllocated: PUBLIC LONG POINTER TO StorageAccounting.PSBIMap;
CollectionInterval: PUBLIC INT ← StorageAccounting.defaultCollectionInterval;
SuspensionThreshold: PUBLIC INT ← ComputeSuspensionThreshold[];
PROCS
ComputeSuspensionThreshold: PROC RETURNS[LONG INTEGER] =
{RETURN[CollectionInterval+CollectionInterval]};
NWordsAllocated: PUBLIC --to SS-- ENTRY SAFE PROC
RETURNS[INT] = TRUSTED {ENABLE UNWIND => NULL;
RETURN[SUMnWordsAllocated + nWordsAllocated];
};
NWordsReclaimed: PUBLIC --to SS-- SAFE PROC
RETURNS[INT] = TRUSTED {
RETURN[nWordsReclaimed];
};
SetCollectionInterval: PUBLIC --to SS-- ENTRY SAFE PROC[newInterval: LONG CARDINAL]
RETURNS[oldInterval: LONG CARDINAL] = TRUSTED {ENABLE UNWIND => NULL;
oldInterval ← CollectionInterval;
CollectionInterval ← newInterval;
SuspensionThreshold ← ComputeSuspensionThreshold[];
};
ResetNWordsAllocated: PUBLIC ENTRY PROC = {ENABLE UNWIND => NULL;
SUMnWordsAllocated ← SUMnWordsAllocated + nWordsAllocated;
nWordsAllocated ← 0;
FOR i: PrincOps.PsbIndex IN PrincOps.PsbIndex
DO
MapPsbiToWordsAllocated.elements[i].total
← MapPsbiToWordsAllocated.elements[i].total
+ MapPsbiToWordsAllocated.elements[i].current;
MapPsbiToWordsAllocated.elements[i].current ← 0;
ENDLOOP;
};
ResetTotalNWordsAllocatedOnly: PUBLIC ENTRY PROC = {
SUMnWordsAllocated ← SUMnWordsAllocated + nWordsAllocated;
nWordsAllocated ← 0;
};
START HERE
MapPsbiToWordsAllocated ←
AllocatorOps.permanentPageZone.NEW[StorageAccounting.PSBIMap[LAST[PrincOps.PsbIndex]+1]];
FOR i: PrincOps.PsbIndex IN PrincOps.PsbIndex
DO MapPsbiToWordsAllocated.elements[i] ← [total: 0, current: 0] ENDLOOP;
END.