FileLock.mesa
Lock operations specialized to files
Last edited by:
Taft on April 6, 1983 4:58 pm
DIRECTORY
AlpineEnvironment,
FileInstance,
TransactionMap;
FileLock: DEFINITIONS =
BEGIN
LockMode: TYPE = AlpineEnvironment.LockMode;
LockOption: TYPE = AlpineEnvironment.LockOption;
PageNumber: TYPE = AlpineEnvironment.PageNumber;
Property: TYPE = AlpineEnvironment.Property;
PageRun: TYPE = AlpineEnvironment.PageRun;
AssertedPageLock: TYPE = LockMode [read..write]; -- subranges of LockMode as applied to files
AssertedFileLock: TYPE = LockMode [read..readIntendWrite];
IntentionFileLock: TYPE = LockMode [intendRead..intendWrite];
AcquireFileLock: PROCEDURE [fileInstance: FileInstance.Handle, requested: LockOption, minimum: LockMode];
! Lock.Failed, Lock.TransAborting;
Acquires the MAX of requested.mode and minimum for the file.
ReleaseFileLock: PROCEDURE [fileInstance: FileInstance.Handle];
! Lock.Error {unknown};
Releases a file lock previously set by AcquireFileLock. Note that locks are reference-counted and are not removed (or downgraded) until one Release has been done for each Acquire. A file lock of any strength may be released; it is the client's responsibility to ensure consistency. Attempts to release nonexistent locks are ignored.
AcquirePageLocks: PROCEDURE [fileInstance: FileInstance.Handle, pageRun: PageRun, requested: LockOption,
minimum: AssertedPageLock];
! Lock.Failed, Lock.TransAborting;
Acquires the MAX of requested.mode and minimum for the specified page(s), and upgrades the file lock if necessary. Does not acquire page locks already subsumed by a whole-file lock. Lock.Failed may be raised after some of the pages have already been locked, and those locks may not have been released.
ReleasePageLocks: PROCEDURE [fileInstance: FileInstance.Handle, pageRun: PageRun, mode: LockMode ← read];
Releases page lock(s) previously set by AcquirePageLocks iff they are currently locked in the specified mode. (A non-default mode should not be passed unless you know what you are doing.) Note that locks are reference-counted and are not removed (or downgraded) until one Release has been done for each Acquire. Attempts to release locks other than mode are ignored without error indication, as are attempts to release nonexistent locks. File intention locks that were set while acquiring the page lock(s) are NOT released.
AcquirePropertyLock: PROCEDURE [fileInstance: FileInstance.Handle, property: Property, requested: LockOption, minimum: AssertedPageLock];
! Lock.Failed, Lock.TransAborting;
Acquires the MAX of requested.mode and minimum for the specified property, and upgrades the file lock if necessary. Does not acquire property locks already subsumed by a whole-file lock. Initial version treats all properties except version together with respect to locking.
ReleasePropertyLock: PROCEDURE [fileInstance: FileInstance.Handle, property: Property, mode: LockMode ← read];
Releases property lock previously set by AcquirePropertyLocks iff it is currently locked in the specified mode. (A non-default mode should not be passed unless you know what you are doing.) Note that locks are reference-counted and are not removed (or downgraded) until one Release has been done for each Acquire. Attempts to release locks other than mode are ignored without error indication, as are attempts to release nonexistent locks. File intention locks that were set while acquiring the property lock are NOT released.
AcquireSizeLock: PROCEDURE [fileInstance: FileInstance.Handle, requested: LockOption, minimum: AssertedPageLock];
! Lock.Failed, Lock.TransAborting;
Acquires the MAX of requested.mode and minimum for the file's size.
AcquireVolumeGroupLock: PROCEDURE [volumeGroupID: AlpineEnvironment.VolumeGroupID, trans: TransactionMap.Handle, requested: LockOption, minimum: AssertedPageLock];
! Lock.Failed, Lock.TransAborting;
Acquires the MAX of requested.mode and minimum for the volume group.
END.