Heading:z18697qjk40(635) Alpine lock manager design, version 0z18697y756qjk40 Page Numbers: Yes X: 527 Y: 10.5"z18697qjk40 CSL Notebook Entryz18697l4445y762\f5b To: Alpine designers Date: February 25, 1981z18697l4445d2998e21(0,65535)(1,4445)(5,11684)(6,13653)\f1 3f0t2 1t0 16t6 1f1t0 5f0t7 1t0 From: Mark Brown Location: PARC/CSLz18697l4445d2998y716e25(6,13664)\f1 5f0t2 1t0 10t6 1f1t0 9f0t7 1t0 Subject: Alpine lock manager design, version 0 File: [Ivy]Doc>LockDesign0.bravoz19579l4445d2998e25\f1 8f0t2 1t0 37t6 1f1t0 5f0t7 1f1t0 34f0 XEROX z18697l508y644e14(2116)\f2 5f0 Attributes: informal, technical, Database, Distributed computing, Filingz18697l4896d2999e10(0,4904)(1,65535)(5,65535)(6,65535)\f1 11f0 1g References: [Ivy]Doc>LockConcepts0.bravoz18697l4896d2999e10\f1 11f0 1f1 36f0 Abstract: This memo proposes an interface for the Alpine lock manager.z18697l4896d2999e10j\f1 9f0 z18697e10(2116)\v Introductionz18697e6jk40(635)\bg12B This memo proposes a design for Alpine's Lock interface. Lock will be used by the implementation of FileStore, and also by applications that perform fine-grained locking and recovery.z18697e12jk40\g32G6g Lock: DEFS = BEGINl3351d2998e24k144(0,3352)(1,2998)(2,2998)\f5b6f1 4B3b l3351d2998e1\g LockID: TYPE = RECORD [entity: System.UniversalID, subEntity: SubID];l3351d2998e1\g8f1 4f0 3f1 7f0 9f1 7f0 SubID: TYPE [3];l3351d2998e1\g7f1 4f0 -- A file is a typical entity; a sub entity of a file is a page, the file's length, etc. If consecutive pages are represented as consecutive sub entities, then the lock manager may use a run-encoded representation. An application may use the entity field to encode what it thinks of as types: "database record", "index value", etc. The sub entity field must then be used to encode the name of a specific object of that type: a particular record or index value.l3704d3351e1\g -- Since lock mangers are responsible for locking disjoint sets of entities, there is no need for LockIDs to be unique across lock managers, much less across all space and time. They aren't unique IDs in the strongest sense.l3704d3351e1\g3G221g LockMode: TYPE = { R, U, W, IR, IU, IW, RIU, RIW };l3351d2998e1\g10f1 4f0 -- or something like that ... . R = read, U = update (read and probably convert to write), W = write, I = intention.l3704d3351e1\g Lock: PROC [trans: TransID, lock: LockID, mode: LockMode];l3351d2998e6\b4B2f1 4f0 -- Acquire lock, in lock mode mode, for transaction trans. This means (1) wait until request can be granted, (2) acquire lock in mode, (3) increment count associated with [lock, trans]. The wait, if any, will be performed in the lock manager monitor, hence the client may not wish to call Lock with its own monitors locked; see LockNoWait below.l3704d3351e1\11i4I15i4I18i5I65i4I4i4I39i4I2i5I107b4B35b10B -- l3704d3351e1\289f1 5f0 LockNoWait: PROC [trans: TransID, lock: LockID, mode: LockMode, procToCall: PROC [REF ANY], argForProcToCall: REF ANY] RETURNS [granted: BOOLEAN];l3351d2998e6\b10B2f1 4f0 60f1 4f0 2f1 7f0 21f1 7f0 1f1 8f0 11f1 7f0 -- Same as Lock, but never waits in lock manager. If lock can be granted without waiting, the lock is granted and the procedure returns TRUE. Otherwise the lock request is queued and the procedure returns FALSE. When the lock is probably available or lock manager times out, the lock request is forgotten and the lock manger calls procToCall[argForProcToCall] with no lock manager monitors locked. (If procToCall = NIL then the reqeust is not queued and procToCall is not called. Otherwise, the idea is that procToCall just reenters whatever monitor is causing us not to use Lock, and notifies the condition variable where we are waiting. Upon getting this notification we can retry our call to LockNoWait.)l3704d3351e1\11b4B122f1 4f0 66f1 5f0 207f1 3f0 158b4B117b10B Unlock: PROC [trans: TransID, lock: LockID];l3351d2998e6\b6B2f1 4f0 -- This means (1) error if trans does not hold lock, (2) decrement count associated with [lock, trans], if count becomes zero then release lock (and consider granting a waiting request).l3704d3351e1\27i5I15i4I39i4I2i5I UnlockTrans: PROC [trans: TransID];l3351d2998e6\b11B2f1 4f0 -- This means for all locks held in trans, perform Unlock until count becomes zero (see description of Unlock).l3704d3351e1\36i5I10b6B46b6B DowngradeTrans: PROC [trans: TransID, downgradeFn: PROC [LockMode] REUTRNS [LockMode]];l3351d2998e6\b14B2f1 4f0 31f1 4f0 12f1 7f0 -- This means for all locks l held in trans, if downgradeFn[Mode[l]] # Mode[l], then downgrade l to the specified new mode.l3704d3351e1\38i5I END.--Lockl3351d2998e1\f1b3f0B3f5b4f0B