[an error occurred while processing this directive]

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

Quick Links

» Non-javascript page
» Ask the Wizard
» OpenVMS FAQ

Test Drive OpenVMS

» OpenVMS I64 test drive
» Java test drive

Other information resources available to you include:

» OpenVMS freeware
» ECO kits, software and hardware support, prior version support
» Alpha SRM, ARC, and AlphaBIOS firmware updates
» ENCOMPASS - HP user group
» OpenVMS software downloads, OpenVMS freeware CD-ROM
» OpenVMS firmware locations
» DECconnect passive adaptor charts
» Cables reference guide
» MicroVAX console commands
» OpenVMS student research

Select a topic below to see Questions Frequently Asked by partners

» Using the online documentation library(installing BNU from the asap SDK)
» Global sections(how to create and use.)
» xx$CREATE_BUFOBJ system service(usage)
» Ethernet address(methods of determination)
» Shareable images(cookbook approach to creating one)
» Sharing data/code at absolute addresses(a guide with examples)
» Determining the Alpha microprocessor
» Using GETSYI to get hardware status

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
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.