popkin@cs.odu.edu (Brian N. Popkin) (04/26/91)
In the magazine "Inside Turbo Pascal" - Special Issue 1991 has a very nice article on file locking, share.exe, and file sharing. I have a copy of the magazine.. mail any questions or if you would like to copy it.. Brian *-----------------------------------------------------------------------------* * * * Brian Popkin * * Computer Science Major - Systems Programing * * Old Dominion University * * Norfolk, Virginia USA * * * * Others Areas Of Interest: Artificial Intelligence, Expert Systems, * * Networks, And Telecommunications * * * * Email Address: popkin@cs.odu.edu * * popkin@xanth.cs.odu.edu * * popkin@gnu.ai.mit.edu * * * *-----------------------------------------------------------------------------*
gt0652b@prism.gatech.EDU (I don't know man, he was just here) (04/26/91)
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') else AccessFile(File) end -- ***************************************************************************** * Joshua I. Guttman "I'm a lookin' for the man that * * gt0652b@prism.gatech.edu shot my paw!" - The Three Legged * * (404)355-3908 Home/(404)355-0001 Work Outlaw Dog. *
frimp@mcshh.hanse.de (Frank Heinzius) (04/29/91)
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