Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uunet!mcsun!unido!mcshh!frimp From: frimp@mcshh.hanse.de (Frank Heinzius) Newsgroups: comp.lang.pascal Subject: Re: File Locking In Turbo Pascal v6.0 Message-ID: <9110@mcshh.hanse.de> Date: 29 Apr 91 08:07:42 GMT References: <1991Apr26.032900.24012@cs.odu.edu> <27400@hydra.gatech.EDU> Lines: 28 In <27400@hydra.gatech.EDU> gt0652b@prism.gatech.EDU (I don't know man, he was just here) writes: ]Forgive me for being stupid but I haven't ever had the need to write a ]file locking program. Wouldn't this be all that was necessary? ]type ] LockedRecType = record ] Locked: Boolean ] Data: DataType ] end; ]Var ] File: LockRecType; ]begin ] if File.Locked then ] writeln('It's locked stupid') At this point another process could set the locked-flag, because your if...then-construct is no *atomic* instruction. there are some possibilities to avoid this. one is to embed the if...then-construct in CLI/STI-commands or to implement semaphores with inline-assembler. ] else ] AccessFile(File) ]end -- Real : Frank Heinzius Voice: +49 40 814 416 Smart: frimp@mcshh.hanse.de Blah : 2B or not 2B, that's FF