-- File: VMSpecial.mesa
-- Last edited by Levin:  27-Feb-81 11:38:37

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.


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

  END.