home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!paladin.american.edu!gatech!prism!gtd543a
- From: gtd543a@prism.gatech.EDU (death)
- Newsgroups: comp.lang.pascal
- Subject: Re: File locking question
- Message-ID: <79288@hydra.gatech.EDU>
- Date: 6 Jan 93 23:00:04 GMT
- References: <Hendrik.Klompmaker.34.726306175@beheer.zod.wau.nl>
- Organization: Purgatory
- Lines: 39
- X-Newsreader: Tin 1.1 PL5
-
- Hendrik Klompmaker (Hendrik.Klompmaker@beheer.zod.wau.nl) wrote:
- : In article <1993Jan5.220346.24647@csx.cciw.ca> u055@csx.cciw.ca (James Sprenger) writes:
- :
- : >
- : >>
- : >> So my guess is that your program username should:
- : >>
- : >> -be compiled with $I- (no stop on runtime error)
- : >>
- : >> -Repeat
- : >> -try to open the file in mode $11 (Write and deny ALL)
- : >> -Until (IoResult=0) (* nobody else has locked it *)
- : >>
- : >
- : >
- : Indeed it does not work. I came up with the following working solution. I
- : did not find a way to chech if a file was locked useing ioresult or doserror
- : while reset(ing) or append(ing) a file. It does however get set if do the
- : following
- : {$i-}
- : repeat
- : setattr(logf,$20); {Archive bit set}
- : until doserror = 0;
-
- All of these methods are -bad-, B-A-D bad. In network management you
- meet up with something called deadlock. It occurs when one program
- wants file X, and already has open file Y, and when a second program
- wants file Y, and already has open file X. Neither will be satisfied
- until the other releases a file wanted by the other. If you create
- an infinite "repeat until unlocked" loop you foolishly run the risk
- of deadlock, which both eats a lot of resources (repeated requests
- through the network) and locks further progress. Always make a
- timeout or some other default (like max number of retries) failsafe
- into whatever low level locking scheme you use.:
- --
- =========================================================================
- WANTED: Position for experienced Matrix runner. Demanding and ambitious
- positions welcome. Must have support for a FUCHI XNN1-11-22 cyberdeck.
- =========================================================================
-