 |
» |
|
 |
|
 |

Copyright (c) Digital Equipment Corporation 1988. All rights reserved
LAYERED PRODUCT or COMPONENT: PLI, VERSION 3.1 OP/SYS: VMS, VERSION 5.0
SOURCE: Digital Customer Support Center
OVERVIEW:
This program shows how to call SYS$ENQW to request a lock on a
resource name. SYS$DEQ is then called to release the lock on the resource.
CAUTION: This sample program has been tested using:
PRODUCT: PLI, VERSION 3.1 on OPERATING SYSTEM: VMS, VERSION 5.0
However, we cannot guarantee its effectiveness because of the possibility of
errors in transmitting or implementing it. It is meant to be used as a
template for writing your own program, and it may require modification for use
on your system.
PROGRAM SAMPLE:
enqdeq: proc options(main);
%include SYS$ENQ;
%include SYS$DEQ;
%include $STSDEF;
%include $LCKDEF;
dcl 1 statblk,
2 lock_status fixed bin(31),
2 lock_id fixed bin(31);
/* The lock status block may optionally contain an extension of 16 bytes
called the 'lock value block' whose contents are user defined.
This could be used as a method of communicating between processes.
See System Service Ref. Manual (SSRM) for more details. */
dcl share_item char(8) init('DATABASE');
Put skip list('Enqueueing the lock...');
sts$value = sys$enqw(,
lck$k_prmode, /* lkmode - lock mode. prmode is 'protected read' */
/* caller and others have only read access to the */
/* named resource. write access is denied to all. */
/* This is the traditional 'share lock'. */
statblk, /* lksb - lock status block. see comment above. */
, /* flags - ref SSRM doc for usage. not needed here */
share_item, /* resnam - whatever Resource Name desired. */
,,,,,);
IF ^sts$success
then do;
put skip list('Problems with ENQW');
signal vaxcondition(sts$value);
end;
put skip list('Lock has been granted');
sts$value = sys$deq(lock_id,,,);
IF ^sts$success
then do;
put skip list('Problems with deq');
signal vaxcondition(sts$value);
end;
put skip list('Lock has been dequeued');
end enqdeq;
|
buy online or call 1.800.AT.COMPAQ
|
|