-- file GlobalStorage
-- edited by Levin, March 3, 1978 9:13 AM
-- edited by Schroeder, August 23, 1978 2:38 PM
-- Converted to Mesa 5.0: March 26, 1979 8:07 PM
-- Global Storage Division - the memory czar. This division provides the memory space needed by other divisions by interfacing with the Mesa runtime storage allocator.
DIRECTORY
ControlDefs: FROM "ControlDefs",
FrameDefs: FROM "FrameDefs",
FrameOps: FROM "FrameOps",
gsD: FROM "GlobalStorageDefs",
ovD: FROM "OverviewDefs",
SegmentDefs: FROM "SegmentDefs",
SystemDefs: FROM "SystemDefs";
GlobalStorage: PROGRAM
IMPORTS FrameDefs, FrameOps, SegmentDefs, SystemDefs
EXPORTS gsD
SHARES gsD =
PUBLIC BEGIN
OPEN gsD;
flusherEnabled: BOOLEAN ← TRUE;
GetMemoryPages: PROCEDURE [numPages: CARDINAL, class: StorageClass] RETURNS [mp: MemoryPagePtr, error: ovD.ErrorCode] =
-- Obtains numPages contiguous memory page and returns a pointer to the start of these pages to the caller.
BEGIN
error ← ovD.ok;
mp ← SystemDefs.AllocateResidentPages[numPages
! SegmentDefs.InsufficientVM =>
BEGIN
error ← ovD.storageNotAvailable;
CONTINUE;
END
];
END; -- of GetMemoryPages --
ReturnMemoryPages: PROCEDURE [numPages: CARDINAL, class: StorageClass, page: MemoryPagePtr] =
-- Accepts the memory pages back into the storage pool from the storage class.
BEGIN
SystemDefs.FreePages[page];
END; -- of ReturnMemoryPages --
FlushCodeSegments: PROCEDURE =
BEGIN
ClearItOut: PROCEDURE[gFH:ControlDefs.GlobalFrameHandle]
RETURNS[BOOLEAN] = BEGIN
IF FrameOps.CodeHandle[gFH].lock = 0 THEN FrameDefs.SwapOutCode[gFH];
RETURN [FALSE];
END;
IF flusherEnabled THEN [] ← FrameDefs.EnumerateGlobalFrames[ClearItOut];
END; --Flush
DisableFlusher: PROCEDURE =
BEGIN
flusherEnabled ← FALSE;
RETURN;
END;
EnableFlusher: PROCEDURE =
BEGIN
flusherEnabled ← TRUE;
RETURN;
END;
END. -- of GlobalStorage --