MemoryObject

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).

  • Bogopager always provides a zero filled page on page fault. It doesn't provide the page out operation. Bogopager comes with the vmcore extension.
  • File pager provides a zero filled page on the first fault. It supports page-out on generic file system. When loaded into memory, the default pager replaces the public procedures to call bogopager. Thus, the bogopager and the file pager are used in the same way.

Note: The reason the bogopager is there is that the default pager depends on the file system, and file system depends on vmcore. Therefore, we can't put the default pager in vmcore, or we have circular dependency.



INTERFACE MemoryObject;
IMPORT Word, VMError, VMTypes;
IMPORT MachineTrap;
IMPORT PhysAddr;
IMPORT PagerObject;
IMPORT CacheObject;
IMPORT Protection;
TYPE
  PageNumber = VMTypes.PageNumber;
  PageCount = VMTypes.PageCount;
TYPE
  T <: Public;
  Public = OBJECT
  METHODS
    init(size: PageCount;
         pager: PagerObject.T := NIL;
         cache: CacheObject.T := NIL;
         name: TEXT := NIL
         ): T RAISES {VMError.E};
     This proc initializes the memory object. If pager is NIL, then the file pager will be newly created. If cache is NIL, then the default cache will be newly created. size specifies the maximum number of pages that this memory object will occupy.
name is used just for debugging.


    request(offset: PageNumber; type: INTEGER;
            VAR frame: PhysAddr.T; VAR prot: Protection.T): BOOLEAN
      RAISES {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 mapping frame onto the faulted address.
type is 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)): T
        RAISES {VMError.E};
     Create a memory object that clones the region from..from+len of 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;
CONST
  Read = MachineTrap.Read;
  Write = MachineTrap.Write;
  Execute = MachineTrap.Execute;
CONST Brand = "MemoryObject-1.0";
PROCEDURE Destroyed(memObj: T);
This is an event. Called when memObj is going to be destroyed. The auth key is the memory object.


The below three are used by the table generic.
PROCEDURE Equal(mo1, mo2: T): BOOLEAN;
PROCEDURE Hash(mo: T): Word.T;
PROCEDURE Compare(mo1, mo2: T): [-1..1];
END MemoryObject.



Last updated: Sun Oct 13 16:36:46 PDT 1996
Yasushi Saito (yasushi@cs.washington.edu)