Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 alpha 4/3/85; site ukma.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!ihnp4!cbosgd!ukma!david From: david@ukma.UUCP (David Herron, NPR Lover) Newsgroups: net.database Subject: Re: locks Message-ID: <2170@ukma.UUCP> Date: Thu, 12-Sep-85 23:27:19 EDT Article-I.D.: ukma.2170 Posted: Thu Sep 12 23:27:19 1985 Date-Received: Sat, 14-Sep-85 05:39:02 EDT References: <10185@ucbvax.ARPA> <5909@utzoo.UUCP> <10233@ucbvax.ARPA> <341@harvard.ARPA> Reply-To: david@ukma.UUCP (David Herron, NPR Lover) Organization: Univ. of KY Mathematical Sciences Lines: 26 In article <341@harvard.ARPA> sasaki@harvard.UUCP (Marty sasaki) writes: >VMS (no flames please) has such a lock manager. The idea is that locks >are named when they are created. There are primities to lock, unlock, >and wait on locks. All that is required is that users agree on a >naming scheme for the locks. Seems to me that Unix already has something that comes very very close to this. Here's the method. Create a Well-Known-Directory (say, /locks) that's mode 777. To make a lock (you need a Well-Known-Name for the lock) you creat() it, and specify exclusive open at the same time. You keep the fd to the lock file open for as long as you're wanting the lock kept open. Then you unlink() it. Only problem is waiting on the lock. (well, you could do a work around with alarm() and a signal() handler). Does System V and friends have exclusive opens? -- --- David Herron --- ARPA-> ukma!david@ANL-MCS.ARPA --- UUCP-> {ucbvax,unmvax,boulder,oddjob}!anlams!ukma!david --- {ihnp4,decvax,ucbvax}!cbosgd!ukma!david Hackin's in me blood. My mother was known as Miss Hacker before she married!