CacheModel.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Russ Atkinson, July 19, 1984 10:46:06 pm PDT
Last Edited by: Sweet, March 19, 1985 10:19:44 am PST
DIRECTORY
DragOpsCross USING [Word];
CacheModel: CEDAR DEFINITIONS = BEGIN
Word: TYPE = DragOpsCross.Word;
wordsPerPage: CARDINAL = 1024;
CacheBase: TYPE = REF CacheBaseRep;
CacheBaseRep:
TYPE =
RECORD [
private: REF ← NIL, -- private data to the cache implementation
fetch: CacheFetchProc ← NIL, -- this hook allows the user to intercept cache accesses
store: CacheStoreProc ← NIL, -- this hook allows the user to intercept cache accesses
data: REF ← NIL, -- private data for clients intercepting fetch & store
stats: CacheStats ← [] -- maintained by the default fetch and store routines
];
CacheFetchProc:
TYPE =
PROC
[base: CacheBase, addr: Word, fromJump: BOOL ← FALSE];
CacheStoreProc:
TYPE =
PROC
[base: CacheBase, addr: Word];
CacheStats:
TYPE =
RECORD [
probes: INT ← 0,
chunkMisses: INT ← 0,
lineMisses: INT ← 0,
jumpMisses: INT ← 0,
mapMisses: INT ← 0,
dirtyWrites: INT ← 0
];
NewCache:
PROC [lines: [0..4096), quadsPerLine: [0..8), lru:
BOOL ←
FALSE]
RETURNS [CacheBase];
Creates a new cache on the specified shared memory. If lines = 0, then the default # of lines is used.
ResetCache:
PROC [cache: CacheBase];
Resets the given cache to its initial state.
FlushCache:
PROC [cache: CacheBase];
Forget everything it knows, but don't effect stats.
Fetch:
PROC [base: CacheBase, addr: Word, afterJump:
BOOL ←
FALSE] =
INLINE {
base.fetch[base, addr, afterJump]};
Store:
PROC [base: CacheBase, addr: Word] =
INLINE {base.store[base, addr]};
END.