Locks for exclusive access to resources

T. William Wells bill at twwells.uucp
Tue Jun 6 21:27:33 AEST 1989


I'm looking for information on how to prevent two unrelated
processes from accessing an unspecified resource. The method
should be independent of the kind of UNIX being used and should,
ideally, work even when the processes are running on different
machines attached to the same network.

I only know of four methods that might work.

    1) Opening a lock file with O_EXCL.
    2) Using link, mknod, or mkdir to create the lock.  (But
       aren't there some systems where mkdir isn't atomic?)
    3) Creating a file with permissions 000 (but this won't
       necessarily work if one of the requestors' is root, right?)
    4) Using a server process to handle either the requests or the access.

I'd appreciate hard information about which methods are usable and
the advantages and disadvantages of each.

Please respond via e-mail and I will summarize.

---
Bill                            { uunet | novavax } !twwells!bill



More information about the Comp.unix.wizards mailing list