|
The VM extension provides two types of address spaces,
"AddressSpace.T" and "Space.T".
|
INTERFACE AddressSpace;
IMPORT Translation, MemoryObject, AddressMap;IMPORT VMError;IMPORT VMTypes;
TYPET <: Public;Public = Translation.T OBJECTMETHODSinit(name: TEXT): T;This is the constructor.nameis used only for debugging purposes.
destroy();Frees up all the resources held by the address space.
allocate(VAR pageNum: VMTypes.PageNumber;numPages: VMTypes.PageCount; anyWhere: BOOLEAN)RAISES {VMError.E};deallocate(pageNum: VMTypes.PageNumber; numPages: VMTypes.PageCount)RAISES {VMError.E};
These methods reserve or unreserve the virtual address region without allocating memory. They are used to reserve a certain region for later use. If anyWhereis true, thenallocatefirst tries the addresspageNum. If it is occupied, then it chooses a free region by its own. IfanyWhereis false and the addresspageNumis occupied, thenallocateraises an exception.
Note: The semantics of when "anyWhere" is false is different from UNIX "mmap". This has to be fixed soon!
pageNumandnumPagesare counted in the MMU page size unit.
map(pageNum: VMTypes.PageNumber; numPages: VMTypes.PageCount;mObj: MemoryObject.T;mOff: VMTypes.PageNumber; lazy := FALSE) RAISES {VMError.E};
mapmaps the regionmOfftomOff+numPagesof the memory object "mObj" on the virtual addresspageNumtopageNum + numPages.mOff,pageNum, andnumPagesare all specified in machine MMU page unit. On Alpha, the page size is 8192 bytes.
The regionpageNumtopageNum + numPagesmust be reserved beforehand usingallocate.
Iflazyis true, then the pages is the region is not immediately paged in. Instead, they are brought in as the user app page faults in the region. Iflazyis false, then the pages are eager copied.
unmap(pageNum: VMTypes.PageNumber; numPages: VMTypes.PageCount)RAISES {VMError.E};
Unmaps the memory object mapped on the space. Currently, the region pageNum .. pageNum+numPagesmust be exactly same as the region specified in previous "mmap" call. In other words, you can not unmap a subregion(or superregion) of a region created by mmap.
clear() RAISES {VMError.E};print(): TEXT;iterate(): Iterator;END;Iterator = AddressMap.Iterator;
CONSTBrand = "AddressSpace-1.1";
PROCEDURE Equal(as1, as2: T): BOOLEAN;PROCEDURE Hash(as: T): CARDINAL;PROCEDURE Compare(as1, as2: T): [-1..1];
END AddressSpace.