[Info-vax] Ken Coar's OpenVMS Lock utility sources are available on Sourceforge.

Jon Pinkley jon.pinkley at gmail.com
Fri Nov 6 05:21:42 EST 2020


On Friday, November 6, 2020 at 12:34:30 AM UTC-5, Dave Froble wrote:
> On 11/6/2020 12:32 AM, Jon Pinkley wrote:
> > On Thursday, November 5, 2020 at 3:03:03 AM UTC-5, Jon Pinkley wrote:
> >> In 1998, Ken Coar submitted the LOCK utility to the DECUS VAXSIG tape.
> >
> > That was a typo.  It was on the VAX86C and VAX87A tapes.  1998 is when I built the version I am running now.
> >
> 
> What does this utility do?

The LOCK utility is nothing more than a DCL interface to the distributed lock manager system services SYS$ENQ and SYS$DEQ. LOCK uses supervisor mode locks, so the locks granted to the process don't disappear with image rundown.

It allows you to use the OpenVMS distributed lock manager from DCL.  So you can use it to do things the VMS DLM allows, but from DCL.  That can be for synchronizing access to some object that can't be shared safely, or to enforce FIFO, to detect/prevent a multi-step job from running concurrently, to allow failover to another node in the cluster (with finer granularity than autostart queues).

Or perhaps you have a poorly designed program that uses fixed filenames, so you can't run multiple instances concurrently without problems.  With LOCK you can avoid the problem by forcing single threading as long as you can make everyone use your wrapper to use the program.

Or if you have a single concurrent use compiler license, and you don't want jobs to fail halfway through a build when someone else compiles something.

You can also implement "door bell" request, to wake a process up when there is new work to be done.  This can be done by requesting a lock with /surrender, which causes LOCL to request a blocking AST if there is an request that forces another request to wait.

It is quite general in purpose, and you can specify the lock mode (and scope, by default group resource domain, but you can specify /scope=system which means cluster wide.

It doesn't prevent access, it just gives your the ability to have e

It does not support sublocks, or resource domains, 64 byte value blocks, or "system owned locks" (but those are not for general use anyway).

You need to understand the lock manager, and how the different modes interact.

It is a good way to learn how the lock manager works, i.e. that a new lock that is compatible with the current lock won't be granted if there are other locks waiting to convert, even if the new lock is NULL.  In some version old version of VMS (v5?) the LCK$M_EXPEDITE and LCK$M_QUECVT flags were added. With LCK$M_EXPEDITE you can always get a new NULL lock, and then you can convert the granted NULL lock to another mode, and if that mode is compatible, it will be granted immediately.

You and also specify /nowait and if the lock can't be granted synchronously, lock will return a fatal status, which you can see with $status or $severity.  If you specify /nowait, no blocking AST will be sent, that is just the way the DLM works.

All described in the Programming Concepts manual.

It is a bit like ethernet vlans, if you don't know you need them, you probably won't miss them.  But once you see how useful they can be, you will miss them if you need them but don't have a vlan-aware switch.

Here's an example showing two processes one with prompt "P1$ " and one with prompt "P2$ ".  Pasting from two terminal sessions with a blank line between.

P2$ lock abc
%LOCK-S-OBTAINED,  6-NOV-2020 05:11:10.64, obtained EXCLUSIVE lock on ABC
P2$ show symbol $status
  $STATUS == "%X1AB78001"
P2$

P1$ lock abc      
%LOCK-I-LOCKED,  6-NOV-2020 05:11:55.25, resource ABC locked by another user, waiting

P2$ lock abc/mod=null
%LOCK-S-CONVERTED,  6-NOV-2020 05:12:09.72, EXCLUSIVE lock on ABC converted to NULL
P2$

%LOCK-S-OBTAINED,  6-NOV-2020 05:12:09.72, obtained EXCLUSIVE lock on ABC
P1$ show symbol $status
  $STATUS == "%X1AB79003"
P1$ 

P2$ lock abc/nowait ! note default /mode is EXCLUSIVE
%LOCK-F-LOCKED,  6-NOV-2020 05:12:47.98, resource ABC locked by another user, aborting
P2$ show symbol $status
  $STATUS == "%X1AB7C004"
P2$



More information about the Info-vax mailing list