From: koehler@eisner.decus.org (Bob Koehler)
Subject: Re: DEC Unix equivalent for VMS' SYS$ENQ()
Date: 2000/05/09 [thread overview]
Message-ID: <1D7Ih3QQRS88@eisner.decus.org> (raw)
In-Reply-To: 8evf01$1hde@r02n01.cac.psu.edu
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
prev parent reply other threads:[~2000-05-09 4:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-05-05 4:00 DEC Unix equivalent for VMS' SYS$ENQ() Lee Newman
2000-05-06 4:00 ` Adam Price
2000-05-09 4:00 ` Bob Koehler [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox