HP OpenVMS Systems

ask the wizard
Content starts here

OpenVMS Lock Manager and Locking?

» close window

The Question is:

Im writing a linker library (in C) that contains misc OS dependant routines.
 This library should be used on both unix and vms. A part of this library is
 lock functions. On unix semaphores are used and on vms I use the sys$enq
 system service. Since shared
semaphore sets on unix ain't removed when the last process stops using them Ive
 added an argument to my "allocate lock function" that lets you specify if the
 lock should be created if it doesn't exist and in my "free lock" function Ive
 got an argument tha
t lets you specify if the lock should be removed from the system or just freed.
 The big question is: Can I accomplish something similar on VMS? Ive been
 thinking bout using sys$getlkiw to get information on how many processes that
 has qued the resource bu
t since I have to do a sys$enq() before I call sys$getlkiw() (to get the
 lockid...or is there another way?) there might be other processes doing the
 same thing at that time and....well....

The Answer is :

  OpenVMS automatically creates the requested lock, if it does not exist.
  OpenVMS cleans up process-level locks automatically as part of process
  rundown processing, unless the individual locks are marked as system-owned
  locks (as differentiated from system-wide locks).
  OpenVMS locks can be formed into trees of locks, such that each semaphore
  set could be implemented as a tree of locks.
  If you are operating across UIC groups, you will want to use system-wide
  locks, and potentially a lock resource domain.  (By default, process-level
  locks and lock resources are maintained separately for each UIC group.)

answer written or last revised on ( 11-OCT-2000 )

» close window