(LOGO.JPG) Python for OpenVMS

(go to: table of contents, index, list of vms_sys, prev: DLCEFC, next: FILESCAN)


ENQW - Enqueue Lock Request


Note: the 'vms_lckdef' module contains bitmasks and constants that are defined in '$LCKDEF'.

Format:

    dict = vms_sys.enqw ([efn], lkmode, lksb, [flags], [resnam],
                         [parid], [astadr], [astprm], [blkast],
                         [acmode], [rsdm_id])
Returns:
dict
A dictionary that has the following keys:
'status'
The condition value returned from SYS$ENQW. Note that this code only tells whether the system service started successfully. The final status code is in the 'lksb'.
'lksb'
A 'vmsobj_lksb' object that provides storage for the OpenVMS LKSB (LocK Status Block). See the description of 'status' above and the 'lksb' argument below.
Arguments:
efn
Number of the event flag to be set when the lock request has been granted or canceled. If 'None' instead of a number is passed, then EFN 0 is used.
lkmode
Lock mode requested. Constants like LCK_K_NLMODE are available from module 'vms_lckdef'.
lksb
LocK Status Block in which SYS$ENQW writes the final completion status. An LKSB should ALWAYS specified, because this is the only place that contains the status code AFTER the system service completed. 'status', as returned only gives information whether the system service has been started successfully.

The Python interface routine expects a 'vmsobj_lksb' object. If the programmer specifies 'None' for the lksb argument, then the interface routine automatically generates a vmsobj_lksb object, passes the OpenVMS LKSB to SYS$ENQW and returns the object in 'dict'!

Storage for the lock value block (LVB) is always allocated.

flags
for specifying options for the SYS$ENQW operation. Bitmasks like LCK_M_NOQUEUE are available from module 'vms_lckdef'.
resnam
Name of the resource to be locked. This is a Python string.
parid
Lock identification of the parent lock.
astadr
This argument is ignored.
astprm
This argument is ignored.
blkast
This argument is ignored.
acmode
Processor access mode. A Python integer. There is no 'vms_psldef' module. The interface code currently runs in user-mode only. As the access mode is maximized this implies always user-mode.
rsdm_id
Recource domain identification.
This is returned after a call to vms_sys.set_resource_domain().
Examples:
$ set PROCESS /NAME= PY_ENQW_TST
$ python
[...]
>>> import vms_sys, import vms_lckdef
>>> l_lkmode = vms_lckdef.LCK_K_NLMODE
>>> # Note: LKSB will be created automatically -v
>>> dict     = vms_sys.enqw (None, l_lkmode, None, None,
...                          'PY_RESNAM', None, None,
...                          None, None, None, None)
>>> for key in dict.keys():
...   print key, '=', dict.get(key)
... #-for
...
lksb = <vmsobj_lksb, LKSB at 0x00289730>
status = 1        <-- from SYS$ENQW()
>>>
>>> # check status inside LKSB
>>> r_lksb   = dict.get ('lksb')
>>> w_status = r_lksb.W_STATUS
>>> print vms_sys.getmsg (w_status) [0]
%SYSTEM-S-NORMAL, normal successful completion
>>>

-----
From a different process:
$ analyze /SYSTEM

VAX/VMS System analyzer

SDA> set process PY_ENQW_TST
SDA>
SDA> show process /lock
Process index: 0022   Name: PY_ENQW_TST   Extended PID: 000000A2
----------------------------------------------------------------
Lock data:

Lock id:  2100000A   PID:     00020022   Flags:
Par. id:  00000000   SUBLCKs:        0
LKB:      814A7040   BLKAST:  00000000
PRIORTY:      0000

Granted at      NL   00000000-FFFFFFFF

Resource:      414E5345 525F5950    PY_RESNA  Status:
 Length   09   00000000 0000004D    M.......
 User mode     00000000 00000000    ........
 Group   040   00000000 00000000    ........

Local copy

SDA>

-----
>>> w_status = r_lksb.W_STATUS

>>> # release the lock
>>> l_lockid = r_lksb.L_LOCKID
>>> print l_lockid
553648138
>>>
>>> (status, o_valblk) = vms_sys.deq (l_lockid)
>>> print (status, o_valblk)
(1, 0L)
>>> print vms_sys.getmsg (status) [0]
%SYSTEM-S-NORMAL, normal successful completion
>>>

-----

SDA> show process /lock

Process index: 0022   Name: PY_ENQW_TST   Extended PID: 000000A2
----------------------------------------------------------------
%SDA-I-NOPRLOCK, no locks taken out by this process
SDA>

----------------------------------------
@@ more vms_sys.enqw() examples
>>>

(go to: table of contents, index, list of vms_sys, prev: DLCEFC, next: FILESCAN)

18-JUL-1999 ZE.