YggBuffMan.mesa
Copyright © 1987, 1988 by Xerox Corporation. All rights reserved.
Last edited by
Kolling on January 31, 1984 2:53:13 pm PST
Bob Hagmann May 4, 1989 9:38:15 am PDT
Mannage the buffers for Yggdrasil.
Interface based on Alpine's FilePageMgr
DIRECTORY
BasicTime USING[GMT, nullGMT],
Camelot USING[ListOfSegmentDesc, optrT, tidT],
Mach USING[ListOfPorts],
YggDIDMap USING[Run],
YggEnvironment USING[PageRun],
YggFile USING[FileHandle],
YggInternal USING[FileHandle];
YggBuffMan: CEDAR DEFINITIONS =
BEGIN
VMPageSet: TYPE = LIST OF VMPageItem;
VMPageItem: TYPE = RECORD [
buffer: LONG POINTER,
pageRun: YggDIDMap.Run,
refChunk: PRIVATE REF -- Chunk -- ];
Represents a contiguous set of pages from a file. There is no guarantee that each VMPageSet (as seen by the user) will have the same number of pages; the user should use the pageRun.pages field.
nullVMPageSet: VMPageSet = NIL;
Chunk: TYPE = RECORD [
useCount: NAT ← 0,
lastTouchTime: BasicTime.GMT ← BasicTime.nullGMT,
file: YggFile.FileHandle ← NIL, -- informative only
run: YggDIDMap.Run,
startAddress: LONG POINTERNIL,
lruListPrev: REF Chunk ← NIL,
lruListNext: REF Chunk ← NIL,
valid: BOOLFALSE
];
All procs taking a pageRun argument raise PageRunArgIllegal if count = 0, and raise PageRunExtendsPastEof if firstPage+count > GetSize[fileHandle] except that the ReadAhead procedures just stop and return when PageRunExtendsPastEof is encountered. No proc returns a VMPageSet with count = 0.
ReadPages: PROCEDURE [fileHandle: YggInternal.FileHandle, tid: Camelot.tidT, pageRun:
YggEnvironment.PageRun, zeroFill: BOOLFALSE] RETURNS [vMPageSet: VMPageSet];
errors defined in this interface: NoSuchFile, NoSuchVolume, PageRunArgIllegal, PageRunExtendsPastEof, VolumeWentOffline.
The first data page of the file is logical page number 0. Returns a VMPageSet containing the pages [pageRun.firstPage..pageRun.firstPage + n) of the file, where n <= pageRun.count. The choice of n is entirely up to FilePageMgr. vMPageSet.pages points to the data for pageRun.firstPage, and vMPageSet.pageRun indicates what was returned. The caller has read/write access to these pages. Increments the use count of the Chunk returned in the VMPageSet.
ReadAheadPages: PROCEDURE[fileHandle: YggInternal.FileHandle, pageRun:
YggEnvironment.PageRun];
errors defined in this interface: NoSuchFile, NoSuchVolume, PageRunArgIllegal, VolumeWentOffline.
Semantically identical to ReadPages, except that it notifies the file page manager that the indicated pages are likely to be read soon rather than waiting for them now and for its handling of PageRunExtendsPastEof.
UsePages: PROCEDURE [fileHandle: YggInternal.FileHandle, tid: Camelot.tidT, pageRun: YggEnvironment.PageRun] RETURNS [vMPageSet: VMPageSet];
errors defined in this interface: NoSuchFile, NoSuchVolume, PageRunArgIllegal, PageRunExtendsPastEof, VolumeWentOffline.
Semantically identical to ReadPages, except that the contents of the pages given by the PageRun are undefined; the implementation may therefore avoid actually reading the pages.
ShareVMPageSet: PROCEDURE [vMPageSet: VMPageSet];
errors defined in this interface: none.
Increments the use count of the Chunk in the VMPageSet.
WritePages: PROC [fileHandle: YggInternal.FileHandle, tid: Camelot.tidT, to: INT, nPages: INT, from: LONG POINTER];
errors defined in this interface: TopLevelTransactionOnly.
Top level transactions only.
ReleaseVMPageSet: PROCEDURE [vMPageSet: VMPageSet, releaseState: ReleaseState,
keep: BOOLEAN];
errors defined in this interface: none.
ReleaseState: TYPE = {writeIndividualWait, writeBatchedWait, writeIndividualNoWait, writeBatchedNoWait, clean};
DirtyReleaseState: TYPE = ReleaseState[writeIndividualWait..writeBatchedNoWait];
DirtyWaitReleaseState: TYPE = ReleaseState[writeIndividualWait..writeBatchedWait];
DirtyNoWaitReleaseState: TYPE = ReleaseState[writeIndividualNoWait..writeBatchedNoWait];
Indicates that the client is through with the given VMPageSet (decrements use count.) keep is a hint that the FilePageManager should try to keep these pages in its cache, as the client expects them to be reused shortly. The ReleaseState hint means: clean: client has not dirtied this page; writeBatched: will cause IO for some likely disk-contiguous pages to be bunched together; writeIndividual: the client is probably not dealing with disk-contiguous pages. The implementation is optimized for "normal" clients, not mixed modes on a file, etc. Other types of client usage and incorrect hints, such as specifying clean for a dirty page, will not result in data being lost, but are likely to degrade performance. We expect: sequential access clients to release pages with keep = FALSE and (clean or writeBatchedNoWait), random access clients to release pages with keep = TRUE and (clean or writeIndividualNoWait), the log to release pages with various options.
ForceOutVMPageSet: PROCEDURE [vMPageSet: VMPageSet];
errors defined in this interface: none.
Returns when all the dirty pages in the VMPageSet have been written to the disk. Does not alter use count.
ForceOutFile: PROCEDURE [fileHandle: YggInternal.FileHandle];
errors defined in this interface: NoSuchFile, NoSuchVolume, VolumeWentOffline.
Returns when all the dirty pages in this file have been written to the disk.
ForceOutEverything: PROCEDURE;
errors defined in this interface: NoSuchVolume, VolumeWentOffline.
Returns when all the dirty pages under control of the file page manager have been written to the disk.
InitializeFilePageMgr: PROCEDURE[seqDescList: Camelot.ListOfSegmentDesc, seqPortList: Mach.ListOfPorts] RETURNS [firstTime : BOOL ];
errors defined in this interface: none.
RestoreCacheToCleanState: PROCEDURE;
errors defined in this interface: none.
for debugging. Call ForceOutEverything first.
Errors:
InsufficientSpaceOnVolume: -- ABSTRACTION -- ERROR;
VolumeTooFragmented: -- ABSTRACTION -- ERROR;
VolumeWentOffline: -- ABSTRACTION -- ERROR;
NoSuchFile: -- CALLING -- ERROR;
NoSuchVolume: -- CALLING -- ERROR;
PageRunArgIllegal: -- CALLING -- ERROR;
PageRunExtendsPastEof: -- CALLING -- ERROR;
SizeArgIllegal: -- CALLING -- ERROR;
TopLevelTransactionOnly: -- CALLING -- ERROR;
Recovery only
WriteBytes: PROC [optr: Camelot.optrT, value: LONG POINTER, valueCnt: CARD];
Back door for recovery.
END.