VMChunks.mesa
Copyright Ó 1990, 1991 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, February 7, 1990
Christian Jacobi, February 8, 1990
VMChunks: CEDAR DEFINITIONS
~ BEGIN
"Large grain storage manager"
A good storage manager could use the storage itself for managing the free list; this package does never touch the "memory", to reduce damage on erronous out of boundary writing by clients.
Domain: TYPE = REF DomainRep;
DomainRep: TYPE;
Chunk: TYPE = REF ChunkRep;
ChunkRep: TYPE;
Chunks are subject to garbage collection: When a chunk is collected, the allocated "memory" is reused.
AddressOfChunk will follow alignment conditions of processor.
CreateDomain: PROC [startAddress: CARD, size: CARD] RETURNS [Domain];
Returns new domain
IsChunk: PROC [x: REF ANY] RETURNS [BOOL];
x#NIL AND ISTYPE[x, Chunk]
NarrowChunk: PROC [x: REF ANY] RETURNS [Chunk];
NARROW[x, Chunk]
AllocateChunk: PROC [domain: Domain, size: CARD] RETURNS [Chunk];
Returns newly allocates chunk of required size or NIL, if not enough free memory in domain.
AddressOfChunk: PROC [chunk: Chunk] RETURNS [CARD];
Returns address of data denoted by chunk.
Data must not be used after chunk is garbage collected.
SizeOfChunk: PROC [chunk: Chunk] RETURNS [CARD];
Returns size of allocated data for chunk.
DomainOfChunk: PROC [chunk: Chunk] RETURNS [Domain];
Returns domain where chunk belongs to.
END.