|
Cache object is a subcomponent of the
MemoryObject. It
records all the physical page frames currently held by
the memory object it belongs to.
It also serves as the policy module for page eviction. In all the methods, the location is expressed in unit of MMU page. |
INTERFACE CacheObject;
IMPORT Word;IMPORT VMError;IMPORT PhysAddr;IMPORT VMTypes;
TYPE
T <: TPublic;TPublic = OBJECTMETHODSdestroy();
XXX This proc is notification from the memobject that the cache is no longer used. However, this proc is never called now because it is difficult to know the timing the cache should be deleted when the memory object participate in cow.
lookup(offset: VMTypes.PageNumber; VAR frame: PhysAddr.T): BOOLEAN;
Find the frame for the location offset. Returns true if found, false otherwise.
update(offset: VMTypes.PageNumber; frame: PhysAddr.T) RAISES {VMError.E};Record the blockbat the locationoffset.
invalidate(offset: VMTypes.PageNumber) RAISES {VMError.E};
invalidateis called after the content of pageoffsetis written out to a device.
chooseVictim(VAR frame: PhysAddr.T);
Choose a memory page to be paged out. frameis the page chosen by the vmcore. The cache object is free to override the frame (NIL is not allowed, though.) in the simplest case, this proc is a nop.
XXX Vinodisasterpaper talks something about the safety of this procedure. I ignore all of their concerns.
frameCount(): CARDINAL;Return the # of frames stored in the object.
getMemoryObject(): REFANY;
Returns the memory object associated with the pager. The return value is always of type MemoryObject.T, but we declare it refany to avoid import loop.
iterate(): Iterator;
XXX this is not mutexed.
Consider these to address atomicitiy problem with iteratorlookupDirty(): ARRAY OF CacheBlock.T;
flushDirty(): ARRAY OF CacheBlock.T;
print(): TEXT;END;
Iterator = OBJECTMETHODSnext(VAR off: VMTypes.PageNumber; VAR frame: PhysAddr.T): BOOLEAN;END;
CONST Brand = "CacheObject-1.0";
PROCEDURE Equal(co1, co2: T): BOOLEAN;PROCEDURE Hash(co: T): Word.T;
END CacheObject.