PDInterpSysCallsCedar4Impl.mesa
Michael Plass, November 17, 1983 2:16 pm
Last Edited by: Pier, November 30, 1983 6:45 pm
DIRECTORY Environment, Space, PDInterpSysCalls;
PDInterpSysCallsCedar4Impl:
MONITOR
IMPORTS Space
EXPORTS PDInterpSysCalls
~ BEGIN
spaces:
LIST
OF Space.Handle;
SetDisplayLights:
PUBLIC
ENTRY
PROC [value: [0..9999]] = {};
AllocateSpace:
PUBLIC
ENTRY
PROC [words:
INT]
RETURNS [
LONG
POINTER] ~ {
ENABLE UNWIND => NULL;
pages: CARDINAL ← (words+Environment.wordsPerPage)/Environment.wordsPerPage;
space: Space.Handle ← Space.Create[size: pages, parent: Space.virtualMemory];
Space.Map[space];
IF pages > 16 THEN Space.CreateUniformSwapUnits[16, space];
spaces ← CONS[space, spaces];
RETURN [Space.LongPointer[space]];
};
FreeSpace:
PUBLIC
ENTRY
PROC [pointer:
LONG
POINTER] ~ {
ENABLE UNWIND => NULL;
prev: LIST OF Space.Handle ← NIL;
FOR s:
LIST
OF Space.Handle ← spaces, s.rest
UNTIL s =
NIL
DO
IF Space.LongPointer[s.first] = pointer
THEN {
Space.Delete[s.first];
IF prev = NIL THEN spaces ← s.rest ELSE prev.rest ← s.rest;
RETURN;
};
prev ← s;
ENDLOOP;
BadFreeSpaceRequest[];
};
BadFreeSpaceRequest:
PUBLIC
ERROR ~
CODE;
END.