From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,f311a11f95771520 X-Google-Attributes: gidfee84,public From: koehler@eisner.decus.org (Bob Koehler) Subject: Re: DEC Unix equivalent for VMS' SYS$ENQ() Date: 2000/05/09 Message-ID: <1D7Ih3QQRS88@eisner.decus.org>#1/1 X-Deja-AN: 621096268 References: <8evf01$1hde@r02n01.cac.psu.edu> X-Trace: news.decus.org 957876132 16656 KOEHLER [216.44.122.34] Organization: HST Flight Software Reply-To: koehler@eisner.decus.aspm.org Newsgroups: comp.unix.osf.osf1 In article <8evf01$1hde@r02n01.cac.psu.edu>, ewn@psulias.psu.edu (Lee Newman) writes: > Being new to the world of Unix, I have a newbie-style question...is there > anything in Digital Unix equivalent to the VMS system routine SYS$ENQ()? > If there is no comparable system routine, how do people implement that type > of functionality? Thanks in advance... > There is no distributed lock manager in most UNIX, so you can't count on having cluser-wide locks. Tru64 is an exception to this, but I've never seen the API documentation. Somebody who has will proably chime in. A feature of UNIX file systems is that creat() is atomic. This was not orginally documented anywhere but has always been true and so much code depends on it a vendor would be nuts to alter it. Since there are no versions in order to create a file you must be able to delete any existing file by the same name. In UNIX delete is a part of write access. So if you creat() a file with no write access (mode in UNIX-speak) you can use it to represent a lock until you change chmod() to include write, that is further attempts to creat() that file will fail. Programs call creat() specifying no write access, on success this indicates you have the lock. Failure indicates someone else has the lock. When you're done with the lock you chmod() to give write access, then attempt to remove() the file. Ignore failure of remove() as some waiting process may creat() after you chmod() but before you remove(). NFS should honor the atomiticity of creat(). The file system also has advisory locks, implemented by flock() and such. Since they are advisory, it means programs can choose to ignore them. Some UNIX also impliment mandatory locks in their file systems. All file system locks over NFS are advisory. Your mileage will vary, as of course all UNIX are different. When you absolutely positivley have to be sure your data is right you pay someone like Oracle big bucks to provide capabilities UNIX doesn't come with, whether you need all the power of a DBMS or not. If your using SYS$ENQ for non file system related things in VMS, you'll have to change your thinking to survive in UNIX. In UNIX if it isn't a file it can't be important, so many things your used to having in VMS will somehow be done via the file system. ---------------------------------------------------------------------- Bob Koehler | Computer Sciences Corporation Hubble Space Telescope Payload | Federal Sector, Civil Group Flight Software Team | please remove ".aspm" when replying