.TITLE MUTEX - enqueues and dequeues locks for EDTX program .IDENT /V1.1/ ; Externals .EXTERNAL EDTX__INUSE ; Macro library calls $SSDEF $LCKDEF .macro errorck,?l1 blbs r0,l1 $exit_s code=r0 l1: .endm ; Read-Write data program section .PSECT _EDTX_DATA,PIC,USR,CON,REL,LCL,NOSHR,NOEXE,WRT,RD LKSB: .BLKQ 1 RESLEN: .BLKL 1 RESPTR: .BLKL 1 .PSECT _EDTX_CODE,PIC,USR,CON,REL,LCL,SHR,EXE,NOWRT,RD .SHOW BINARY .ENTRY EDTX$ACQUIRE_MUTEX,^M movl 4(AP),reslen ; get descriptor block movl reslen,resptr ; length and address movl @reslen,reslen ; get the length addl #4,resptr ; get buffer pointer movl @resptr,resptr ; and address of buffer cmpw reslen,#31 ; see if a problem with length blequ length_ok ; ... if no problem, skip movw #31,reslen ; ... if too long, shorten length_ok: $enq_s - efn=#1,- ; use event flag 0 lkmode=#LCK$K_EXMODE,- ; lock at exclusive access lksb=LKSB,- ; address of lock status block flags=#LCK$M_NOQUEUE,- resnam=RESLEN ; name of resource to lock cmpl R0,#SS$_NOTQUEUED ; did we get it? beql no_lock ; no, sorry errorck ; check for other errors ret ; yes, return no_lock: pushl #EDTX__INUSE ; file is in-use calls #1,G^LIB$SIGNAL ; signal, and end ret .ENTRY EDTX$RELEASE_MUTEX,^M $deq_s - lkid=LKSB+4 ; the lock id is in lock status block movl #SS$_NORMAL,R0 ret .end