Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
HP.com home

HP OpenVMS Systems

Ask the Wizard
» 

HP OpenVMS Systems

OpenVMS information

» What's new on our site
» Upcoming events
» Configuration and buying assistance
» Send us your comments

HP OpenVMS systems

» OpenVMS software
» Supported Servers
» OpenVMS virtualization
» OpenVMS solutions and partners
» OpenVMS success stories
» OpenVMS service and support
» OpenVMS resources and information
» OpenVMS documentation
» Education and training

Evolving business value

» Business Systems Evolution
» AlphaServer systems transition planning
» Alpha RetainTrust program

Related links

» HP Integrity servers
» HP Alpha systems
» HP storage
» HP software
» HP products and services
» HP solutions
» HP support
disaster proof
HP Integrity server animation
Content starts here

Ask the Wizard Questions

Language: Enqueue lock from DCL

The Question is:

I want to write a program to be called from DCL to enqueue a lock and
have the lock stay enqueued after the program exits.  At a later point
in the DCL I want to call another program to dequeue the lock.  How do
I get the lock to remain after the first program exits?


The Answer is:

      If your process or the image has CMEXEC privilege, you can enqueue a
    lock which will survive image rundown. To do this you need to execute
    the call to SYS$ENQW in EXECUTIVE mode. If you wish the lock to be
    visible beyond your immediate UIC group, you will also need SYSLCK
    privilege and include the flag LCK$M_SYSTEM in the $ENQ.

      To $DEQ the lock in a later image activation, you first need to
    find the LKID using SYS$GETLKIW. This will also need to be done in
    EXECUTIVE mode. The method I would suggest is to use a wildcard
    search for a lock held by your PID and with the same resource name.

      Beware - exceptions in EXECUTIVE mode will delete your process, and,
    in some instances can crash your system. You also cannot reliably use
    I/O from executive mode, nor can you use DEBUG. A rough outline of
    the code required is:

    To take out the lock:
    ...
    $CMEXEC(EnqRoutine,0)
    ...

    EnqRoutine
      $ENQW(lkmode=LCK$K_mode,lksb=lksb,flags=LCK$M_SYSTEM,
    	resnam='your-resource-name',acmode=PSL$C_EXEC)
    END EnqRoutine

    To release the lock

    Use $GETJPI to determine your own PID => Self
    ...
    $CMEXEC(DeqRoutine,0)
    ...

    DeqRoutine
    init GETLKI item list to return LKI$_RESNAM, LKI$_PID and LKI$_LKID
    LKSB=0 (wildcard)
    REPEAT
      status=$GETLKIW(lkidadr=LKSB,itmlst=itmlst,iosb=iosb)
    UNTIL bad status OR ((PID=Self) AND (RESNAM='your-resource-name')
    IF good status THEN $DEQ(lkid=LKID)
    END DeqRoutine


    Be careful with this stuff, as well as being privileged and difficult
    to debug, it's very easy to deadlock yourself.



 

** About PDF files: The PDF files on this Web site can be read online or printed using Adobe® Acrobat® Reader. If you do not have this software installed on your system, you may download it from the Adobe Web site.
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2008 Hewlett-Packard Development Company, L.P.