Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!ukma!uflorida!novavax!twwells!bill From: bill@twwells.uucp (T. William Wells) Newsgroups: comp.unix.wizards Subject: Locks for exclusive access to resources Message-ID: <1020@twwells.uucp> Date: 6 Jun 89 11:27:33 GMT Reply-To: bill@twwells.UUCP (T. William Wells) Organization: None, Ft. Lauderdale Lines: 22 Expires: References: Sender: Followup-To: Keywords: 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