CacheObject

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 = OBJECT
  METHODS
    destroy();
     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 block b at the location offset.
    invalidate(offset: VMTypes.PageNumber) RAISES {VMError.E};
     invalidate is called after the content of page offset is written out to a device.


    chooseVictim(VAR frame: PhysAddr.T);
     Choose a memory page to be paged out. frame is 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 Vino disaster paper 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 iterator
lookupDirty(): ARRAY OF CacheBlock.T;
flushDirty(): ARRAY OF CacheBlock.T;


    print(): TEXT;
  END;
  Iterator = OBJECT
  METHODS
    next(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.

Last updated: Sun Oct 13 16:36:49 PDT 1996
Stefan Savage (savage@cs.washington.edu)