DIRECTORY Rope USING [ROPE], TEditDocument USING [TEditDocumentData], Tioga USING [Node]; TEditLocks: CEDAR DEFINITIONS ~ BEGIN LockRef: TYPE = REF LockRecord; LockRecord: TYPE = MONITORED RECORD [ waitingForWrite: INTEGER ฌ 0, -- number of processes waiting for write access count, maxCount: [0..255] ฌ 0, -- number of times have entered this lock process: PROCESS ฌ NIL, -- the unique process which has write access to this document whoLast, whoFirst: Rope.ROPE, -- provided by the lockers unlocked: CONDITION -- raised when the lock is freed ]; Access: TYPE = { read, write }; Lock: PROC [doc: Tioga.Node, who: Rope.ROPE, access: Access ฌ write] RETURNS [LockRef]; LockBoth: PROC [doc1, doc2: Tioga.Node, who: Rope.ROPE, access1, access2: Access ฌ write] RETURNS [lock1, lock2: LockRef]; LockOrder: PROC [doc1, doc2: Tioga.Node] RETURNS [BOOL]; Unlock: PROC [doc: Tioga.Node]; LockDocAndTdd: PROC [tdd: TEditDocument.TEditDocumentData, who: Rope.ROPE, access: Access ฌ write, interrupt, defer: BOOL ฌ FALSE] RETURNS [LockRef]; UnlockDocAndTdd: PROC [tdd: TEditDocument.TEditDocumentData]; WaitingForWrite: PROC [lock: LockRef] RETURNS [BOOL]; END.  TEditLocks.mesa Copyright ำ 1985, 1986, 1991, 1992 by Xerox Corporation. All rights reserved. Edited by Paxton on October 20, 1982 7:35 am Last Edited by: Maxwell, January 6, 1983 10:32 am Michael Plass, March 21, 1985 3:06:58 pm PST Doug Wyatt, January 30, 1992 6:43 pm PST Can only lock a document if (1) it is unlocked, or (2) current process has a write lock on it already If neither holds, then waits until it can lock it. Note that cannot convert a read lock into a write lock. (Implementation limitation.) Many processes can have read locks; only one can have a write lock. When a write lock is released, all viewers for the document have their tdd.dirty bit set true. Like two calls on Lock, but orders the calls according to LockOrder. Returns true if ok to lock doc1 before doc2. Reduces the lock count for the document. access is for locking the document; interrupt and defer are for locking the tdd if defer and don't get the tdd lock, then returns nil. Returns true iff some process is waiting to get a write lock for the document. ส$•NewlineDelimiter –(cedarcode) style™codešœ™Kšœ ฯeœC™NKšœ,™,Kšœ1™1K™,K™(—K˜šฯk ˜ Kšœžœžœ˜Kšœžœ˜(Kšœžœ˜—K˜šฯn œžœž œž˜%K˜Kšœ žœžœ ˜šœ žœž œžœ˜%Kšœžœฯc/˜MKšœ )˜HKšœ žœžœ =˜UKšœžœ ˜9Kšœ ž œ  ˜4K˜K˜—Kšœžœ˜K˜K˜šŸœžœžœžœ ˜W™K™K™2—K™2K™UK™CK™^—K˜šŸœžœ$žœ#˜YKšžœ˜ KšœD™D—K™šŸ œžœžœžœ˜8K™,—K˜šŸœžœ˜K™(—K˜šŸ œžœ'˜:Kš œ žœ,žœžœžœ ˜ZKšœO™OK™6—K˜KšŸœžœ(˜=K˜šŸœžœžœžœ˜5K™N—K˜—K˜Kšžœ˜—…—Ž า