-- File: VMSpecial.mesa
-- Last edited by Levin: 12-Apr-83 11:36:30

DIRECTORY
AltoFile USING [FP],
VMDefs USING [FileHandle, Percentage];

VMSpecial: DEFINITIONS =

BEGIN OPEN VMDefs;

-- This interface is intended for use by specialized clients of the VM
-- package, not by casual users.


-- Global control --

PruneCache: PROCEDURE [CARDINAL] RETURNS [BOOLEAN];
-- Attempts to free the given number of pages from the in-core cache. The return
-- value tells whether it succeeded.

DisableClobberCatcher: PROCEDURE;
-- primarily for carefully simulating Altos on D-machines.


-- Specialized Alto file system procedures --

OpenAltoFileFromFP: PROCEDURE [
fp: AltoFile.FP, writable: BOOLEAN, cacheFraction: Percentage ← 0]
RETURNS [FileHandle];
-- The Alto file identified by ’fp’ (which therefore must already exist) is opened
-- and given the indicated cache proportion.

QuickAndDirtyAltoRename: PROCEDURE [old, new: STRING] RETURNS [BOOLEAN];
-- This procedure "renames" file ’old’ (in SysDir) to be ’new’. In actuality, it
-- works as follows. If ’new’ is already present in the directory, or ’old’ is not
-- present in the directory, FALSE is returned and the directory is unchanged.
-- Otherwise, the entry for ’old’ is deleted and a new entry consisting of ’new’ and
-- the fp formerly associated with ’old’ is inserted in the directory. In this case,
-- the procedure returns TRUE. (The actions actually occur in the opposite order;
-- thus, there will be a short period of time during which entries for both ’old’ and
-- ’new’ will exist in the directory at once.) Note that this is not a true file
-- renaming operation, since the serial number of the file does not change. Note
-- also that if a crash occurs while both entries are in the directory, the Scavenger
-- may do something peculiar.

WaitForAltoDiskSpaceCrunch: PROCEDURE [CARDINAL] RETURNS [BOOLEAN];
-- Returns to its caller with TRUE when the number of free disk pages appears to
-- be less than the given number. This relies on internal hints, and so is not
-- absolutely accurate. Returns FALSE if VMDefs.FinalizeVM is called.

GetAltoDiskSpace: PROCEDURE [wait: BOOLEAN] RETURNS [pages: CARDINAL, ok: BOOLEAN];
-- Returns (a hint of) the number of available disk pages. If wait = TRUE, the return
-- is delayed until the number of free pages changes from its value at the time of the
-- call. ok = TRUE normally; ok = FALSE if VMDefs.FinalizeVM is called.

END.