|
Memory object is a conainer of page frames. Internally, a memory object consists of two objects, cache and pager. Cache holds a set of page frames. All the frames in a memory object is recorded in the cache object. Pager implements a mechanism to transfer pages to and from memory and external I/O device. Pager is expected to be subtyped. Currently, two types of pagers are provided, namely, Bogopager and Filepager pager).
|
INTERFACE MemoryObject;
IMPORT Word, VMError, VMTypes;IMPORT MachineTrap;IMPORT PhysAddr;IMPORT PagerObject;IMPORT CacheObject;IMPORT Protection;
TYPEPageNumber = VMTypes.PageNumber;PageCount = VMTypes.PageCount;
TYPET <: Public;Public = OBJECTMETHODSinit(size: PageCount;pager: PagerObject.T := NIL;cache: CacheObject.T := NIL;name: TEXT := NIL): T RAISES {VMError.E};
This proc initializes the memory object. If pageris NIL, then the file pager will be newly created. Ifcacheis NIL, then the default cache will be newly created.sizespecifies the maximum number of pages that this memory object will occupy.
nameis used just for debugging.
request(offset: PageNumber; type: INTEGER;VAR frame: PhysAddr.T; VAR prot: Protection.T): BOOLEANRAISES {VMError.E};
This is called by AddressSpace page fault handler. Request returns the physical frame that backs the location offset, and the new protection bits that should be applied when mappingframeonto the faulted address.
typeis one of MachineTrap.Read/Write/Execute that indicates how the fault happened.
fork(): T RAISES {VMError.E};
Create an eager copy of the object. THIS WILL BE REMOVED IN THE FUTURE.
copyOnWrite(from := 0; len: PageCount := LAST(INTEGER)): TRAISES {VMError.E};
Create a memory object that clones the region from..from+lenof this memobject.
isMapped(): BOOLEAN;
Returns true is the memory object it mapped on any addrspace. We don't return where it is mapped for safety reason.
print(): TEXT;Returns some human-understandable descriptive string.
END;
CONSTRead = MachineTrap.Read;Write = MachineTrap.Write;Execute = MachineTrap.Execute;
CONST Brand = "MemoryObject-1.0";
PROCEDURE Destroyed(memObj: T);
This is an event. Called when memObjis going to be destroyed. The auth key is the memory object.
PROCEDURE Equal(mo1, mo2: T): BOOLEAN;PROCEDURE Hash(mo: T): Word.T;PROCEDURE Compare(mo1, mo2: T): [-1..1];
END MemoryObject.