TITLE QUESER -- ENQUEUE/DEQUEUE SERVICE FACILITY - V146
SUBTTL S. BLOUNT /WRS/PMV 17-APR-90
SEARCH F,S
$RELOC
$HIGH
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED
; OR COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (c) DIGITAL EQUIPMENT CORPORATION
; 1974,1975,1976,1977,1978,1979,1980,1982,1984,1986,1988,1990.
;ALL RIGHTS RESERVED.
.CPYRT<1974,1990>
XP VQUESR,146
ENTRY QUESER ;LOAD THIS MODULE IF NEEDED
QUESER::
;ENQ/DEQ PROVIDES A QUEUEING FACILITY WHICH CAN BE USED
; TO INSURE MUTUAL EXCLUSION OF PROCESSES OPERATING ON
; A COMMON DATA BASE.
SALL

;COME HERE IF AN ENQ REQUEST FAILED FOR SOME REASON
; THE ENTIRE CHAIN OF REQUESTS (IF ANY) MUST
; BE REMOVED FROM THE QUEUES. THE POINTER TO THE
; LAST MEMBER OF THE CHAIN IS KEPT IN THE
; LEFT HALF OF P4.
;
;ON ENTRY, THE ERROR CODE IS IN T1
BACKUP: HLRZ T3,P4 ;GET ADDRESS OF LAST Q'ED ENTRY
JUMPE T3,STOTAC## ;THERE WAS NONE--EXIT
MOVEM T1,NQERRF ;SAVE ERROR CODE
SKIPA T1,T3 ;MOVE THIS ADDRESS TO USE AS PTR
BACK2: MOVE T1,T2 ;GET ADDRESS OF LAST BLOCK
LOAD. T2,.QBLQR,(T1) ;GET PREVIOUS Q-BLOCK'S LOCATION
PUSHJ P,DEQIT ;REMOVE THE CURRENT BLOCK
JFCL ;DON'T CARE IF Q IS FLUSHED
CAIE T2,(T1) ;HAVE WE GONE IN CIRCLE?
JRST BACK2 ;NO
MOVE T1,NQERRF ;YES, GET ERROR CODE
JRST STOTAC## ;GIVE HIM ERROR CODE

SUBTTL ENQC QUEUE CONTROLLER UUO
;THIS UUO HAS FOUR FUNCTIONS:
; 0. RETURN STATUS OF LIST OF RESOURCES
; 1. RETURN USER'S LOCK QUOTA
; 2. SET USER'S LOCK QUOTA (PRIVILEGED)
; 3. DUMP OUT QUEUE STRUCTURE INTO USER BUFFER
;FOR OPTION 0, THREE WORDS ARE RETURNED FOR EACH LOCK SPECIFIED BY THE
; USER. THE 1ST WORD HAS THE FOLLOWING FORMAT:
;
; B0 ERROR BIT
; B1 THIS USER IS THE OWNER OF THE LOCK
; B2 THIS USER HAS ISSUED AN ENQ FOR THE LOCK
; B3 THE OWNER OF THE LOCK HAS EXCLUSIVE ACCESS
; B9-17 LEVEL NUMBER OF RESOURCE
; B18-26 CONTEXT NUMBER OF OWNER
; B27-35 JOB NUMBER OF OWNER/ERROR CODE
; THE JOB NUMBER OF THE OWNER MAY BE
; ONLY ONE OF MANY OWNERS IF THE
; LOCK IS SHARED.
;
;THE SECOND WORD IS A 36-BIT TIME-STAMP WHICH REPRESENTS
; THE TIME AT WHICH THE RESOURCE WAS LAST
; "ALLOCATED". THIS PROVIDES A METHOD OF DETERMINING
; IF A USER HAS HELD THE RESOURCE FOR AN EXCESSIVE
; AMOUNT OF TIME.
;
;THE THIRD WORD HAS THE REQUEST-ID IN THE RIGHT HALF.
;IF BIT 2 IN WORD 1 IS ON, THIS IS THE CALLER'S ID
;OTHERWISE, IT'S THE OWNER'S ID.
;
;IF THE LOCK HAS NO CURRENT OWNER, THE STATUS WORD WILL HAVE
; -1 IN THE RIGHT HALF
UENQC:: PUSHJ P,SAVE4## ;PRESERVE P1-P4
SETZM ENQFLG ;THIS IS NOT AN ENQ.
MOVEM M,SBLOCK ;SAVE ADDRESS OF AC FOR LATER
MOVEI T2,QCMXFC ;SET UP MAX FUNCTION CODE
PUSHJ P,SETUP ;DO STANDARD STUFF
POPJ P, ;ERROR IN FUNCTION CODE
JRST @[EXP QC0,QC1,QC2,QC3](T3)