LOC TITLE 'DMKLOC (CP) VM/370 - RELEASE 6' 00001000
ISEQ 73,80 VALIDATE SEQUENCING OF SYSIN @V200820 00002000
*. 00003000
* MODULE NAME 00004000
* 00005000
* DMKLOCK USER LOCK ROUTINE 00006000
* 00007000
* FUNCTION 00008000
* 00009000
* TO ALLOW A SYSTEM RESOURCE TO BE MARKED AS IN USE 00010000
* OR NOT AVAILABLE, BY A UNIQUE 8 CHARACTER NAME. 00011000
* 00012000
* ATTRIBUTES 00013000
* 00014000
* REENTRANT, BALR CALLED, PAGEABLE 00015000
* 00016000
* ENTRY POINTS 00017000
* 00018000
* DMKLOCK LOCK A NAME 00019000
* DMKLOCKD DEQUEUE A LOCKED NAME 00020000
* DMKLOCKT TEST IF A NAME IS LOCKED 00021000
* DMKLOCKQ QUEUE OR LOCK A NAME 00022000
* 00023000
* ENTRY CONDITIONS 00024000
* 00025000
* R1 = ADDRESS OF THE NAME TO LOCK, TEST, QUEUE 00026000
* OR DEQUEUE. 00027000
* 00028000
* EXIT CONDITIONS 00029000
* 00030000
* DMKLOCK 00031000
* CC = 0 SUCCESSFUL LOCK WAS MADE 00032000
* CC = 1 NAME LOCKED ON ENTRY 00033000
* 00034000
* DMKLOCKD 00035000
* CC = 0 SUCCESSFUL UNLOCK OR DEQUEUE 00036000
* CC = 1 NAME WAS NOT LOCKED 00037000
* 00038000
* DMKLOCKT 00039000
* CC = 0 LOCK IS OFF 00040000
* CC = 1 LOCK IS ON 00041000
* 00042000
* DMKLOCKQ 00043000
* NO CONDITION CODE IS SET. THE ROUTINE WILL NOT 00044000
* RETURN TO THE CALLER UNTIL A SECCESSFUL LOCK IS MADE. 00045000
* IF THE NAME IS LOCKED AT ENTRY THE CALLER WILL BE 00046000
* QUEUED UNTIL DEQUEUED BY THE DMKLOCKD ROUTINE. 00047000
* 00048000
* CALLS TO OTHER ROUTINES 00049000
* 00050000
* DMKFREE - TO GET FREE STORAGE FOR A LOCKBLOK 00051000
* DMKFRET - TO RETURN FREE STORAGE 00052000
* 00053000
EJECT 00054000
* EXTERNAL REFERENCES 00055000
* 00056000
* DMKSYSLB = POINTER TO THE USER DIRECTORY LOCK BLOCK 00057000
* 00058000
* TABLES / WORK AREAS 00059000
* 00060000
* NONE 00061000
* 00062000
* REGISTER USAGE 00063000
* 00064000
* 00065000
* R0 = WORK 00066000
* R1 = POINTER TO NAME FROM USER 00067000
* R2 = FIRST HALF OF NAME FROM USER 00068000
* R3 = SECOND HALF OF NAME FROM USER 00069000
* R4 = POINTER TO L BLOCK 00070000
* R5 = POINTER TO THE NEXT LOCK BLOCK 00071000
* R6 = FIRST HALF OF NAME FROM THE LOCK BLOCK 00072000
* R7 = SECOND HALF OF NAME FROM THE LOCK BLOCK 00073000
* R8 = POINTER TO THE LAST LOCK BLOCK 00074000
* R9 = BRANCH AND LINK REG 00075000
* R10 = POINTER TO DMKSYSLC OR CPEXBLOK. 00076000
* R11 = VMBLOK 00077000
* R12 = BASE A(DMKLOCK) 00078000
* R13 = NOT USED 00079000
* R14 = CALLERS RETURN ADDRESS. 00080000
* R15 = ADDRESS OF THE ENTRY POINT. 00081000
* 00082000
* OPERATION 00083000
* 00084000
* DMKLOCK 00085000
* 00086000
* 1. SCAN LOCK BLOCK LIST 00087000
* 2. IF THE LOCK IS ON EXIT CC = 1. 00088000
* 3. CALL DMKFREE TO GET A LOCK BLOCK. 00089000
* 4. BUILD AND CHAIN IN THE LOCK BLOCK. 00090000
* 5. EXIT CC = 0 00091000
* 00092000
* DMKLOCKD 00093000
* 00094000
* 1. SCAN LOCK BLOCK LIST. 00095000
* 2. IF THE LOCK IS OFF EXIT CC = 1. 00096000
* 3. IF ANY CPEXBLOK'S ARE QUEUED GO TO STEP 7. 00097000
* 4. UNCHAIN THE LOCK BLOCK. 00098000
* 5. CALL DMKFRET TO RETURN THE LOCK BLOCK'S STORAGE. 00099000
* 6. EXIT CC = 0. 00100000
* 7. UNCHAIN THE CPEXBLOK FROM THE LOCK BLOCK AND 00101000
* CALL DMKSTKCP THE CPEXBLOCK. 00102000
* 8. EXIT CC = 0. 00103000
* 00104000
* DMKLOCKT 00105000
* 00106000
* 1. SCAN LOCK BLOCK LIST. 00107000
* 2. EXIT CC = 0 IF LOCK IS OFF. 00108000
* 3. EXIT CC = 1 IF THE LOCK IS ON. 00109000
* 00110000
* DMKLOCKQ 00111000
* 00112000
* 1. SCAN LOCK BLOCK LIST. 00113000
* 2. IF THE LOCK IS NOT ON GO TO THE LOCK ROUTINE 00114000
* STEP 3, ELSE CONTINUE. 00115000
* 3. CALL DMKFREE TO GET A CPEXBLOK. 00116000
* 4. BUILD A CPEXBLOK AND CHAIN IT TO THE END OF 00117000
* THE LOCK BLOCK QUEUE. 00118000
* 5. GO TO DMKDSPCH (WAIT FOR THE NAME TO BE UNLOCKED). 00119000
*. 00120000
SPACE 3 00121000
DMKLOC CSECT 00122000
USING PSA,R0 00123000
* USING LOCKBLOK,R4 00124000
USING SYSLOCS,R10 00125000
USING DMKLOCK,R12 00126000
SPACE 3 00127000
EXTRN DMKSTKMP STACK FOR MY PROCESSOR @V407510 00128100
EXTRN DMKSTKOP STACK FOR OTHER PROCESSOR @V407510 00128200
EJECT 00129000
ENTRY DMKLOCK 00130000
DMKLOCK STM R0,R15,BALRSAVE SAVE THE CALLERS REGISTERS 00131000
LR R12,R15 POINT TO THE START OF THE MODULE 00132000
BAL R9,SCAN LOOK UP NAME 00133000
BC 4,EXITCC1 RETURN CC EQ 1 IF LOCK WAS ON 00134000
LOCKIT LA R0,LOCKSIZE SET UP TO GET CORE 00135000
CALL DMKFREE GET FREE CORE FOR L BLOCK 00136000
USING LOCKBLOK,R1 00137000
ST R5,LOCKNEXT STORE ZERO IN LOCKNEXT 00138000
ST R5,LOCKQUE ZERO THE QUEUE LIST POINTER 00139000
STM R2,R3,LOCKNAME STORE NAME IN NEW L BLOCK 00140000
DROP R1 00141000
USING LOCKBLOK,R4 00142000
ST R1,LOCKNEXT SAVE POINTER IN LAST L BLOCK 00143000
B EXITCC0 RETURN CC EQ 0 00144000
SPACE 2 00145000
ENTRY DMKLOCKD 00146000
USING *,R15 00147000
DMKLOCKD STM R0,R15,BALRSAVE SAVE THE CALLERS REGISTERS 00148000
L R12,=A(DMKLOCK) POINT TO THE START OF THE MODULE 00149000
DROP R15 00150000
BAL R9,SCAN LOOK UP NAME 00151000
BZ EXITCC1 BRANCH IF NAME WAS NOT LOCKED 00152000
ICM R1,15,LOCKQUE POINT TO THE FIRST CPEXBLOK, IF ANY. 00153000
BP DEQUEUE DEQUEUE THE CPEXBLOK IF ANY 00154000
DROP R4 00155000
USING LOCKBLOK,R8 00156000
ST R5,LOCKNEXT SAVE POINTER IN LAST L BLOCK 00157000
LA R0,LOCKSIZE SET UP STORAGE SIZE TO FRET 00158000
LR R1,R4 POINT TO STORAGE TO FRET 00159000
DROP R8 00160000
USING LOCKBLOK,R4 00161000
CALL DMKFRET 00162000
B EXITCC0 RETURN CC EQ 0 00163000
SPACE 00164000
USING CPEXBLOK,R1 00165000
DEQUEUE MVC LOCKQUE(4),CPEXFPNT POINT TO THE NEXT CPEXBLOK 00166000
* NOTE: DMKSTK WILL NOT USE BALR SAVE AREA @V407510 00167100
CLC CPEXPROC,LPUADDR STACK FOR THIS PROCESSOR? @V407510 00167200
BNE STKOTHER NO, STACK FOR OTHER PROCESSOR @V407510 00167300
CALL DMKSTKMP STACK CPEXBLOK FOR THIS PROC @V407510 00167400
B EXITCC0 RETURN CC=0 TO CALLER @V407510 00167500
STKOTHER DS 0H @V407510 00167600
CALL DMKSTKOP STACK CPEXBLOK FOR OTHER PROC @V407510 00167700
B EXITCC0 RETURN CC = 0 TO THE CALLER 00169000
EJECT 00170000
ENTRY DMKLOCKT 00171000
USING *,R15 00172000
DMKLOCKT STM R0,R15,BALRSAVE SAVE THE CALLERS REGISTERS 00173000
L R12,=A(DMKLOCK) POINT TO THE START OF THE MODULE 00174000
DROP R15 00175000
BAL R9,SCAN LOOK UP NAME 00176000
B EXIT RETURN CC EQ 0 LOCK OFF CC EQ 1 LOCK ON 00177000
SPACE 3 00178000
ENTRY DMKLOCKQ 00179000
USING *,R15 00180000
DMKLOCKQ STM R0,R15,BALRSAVE SAVE CALLERS REGISTERS 00181000
L R12,=A(DMKLOCK) POINT TO THE START OF THE MODULE 00182000
DROP R15 00183000
BAL R9,SCAN GO LOOK UP THE NAME; IS IT LOCKED? 00184000
BZ LOCKIT NO- BRANCH TO BUILD A LOCK BLOCK 00185000
LA R0,CPEXSIZE * GET A CPEXBLOK TO QUEUE OFF THE 00186000
CALL DMKFREE * LOCK BLOCK. 00187000
MVC CPEXPROC,LPUADDR INDICATE BLOK TO BE STACKED @V407510 00187100
* FOR THIS PROCESSOR @V407510 00187200
MVC CPEXREGS(16*4),BALRSAVE MOVE ALL 16 REGS IN 00188000
MVC CPEXADD(4),BALR14 AND THE RETURN REG ALSO 00189000
XC CPEXFPNT(4),CPEXFPNT ZERO POINTER TO NEXT CPEXBLOK 00190000
DROP R1 00191000
USING CPEXBLOK,R3 00192000
LA R3,LOCKQUE-(CPEXFPNT-CPEXBLOK) POINT AT POINTER TO *00193000
CHAIN OF CPEXBLOK'S 00194000
LOOP1 ICM R2,15,CPEXFPNT GET NEXT POINTER AND TEST FOR ZERO 00195000
BZ ENDOFQUE IF ZERO BRANCH 00196000
LR R3,R2 POINT TO THE NEXT CPEXBLOK 00197000
B LOOP1 AND LOOP 00198000
ENDOFQUE ST R1,CPEXFPNT CHAIN IN THE NEW CPEXBLOK 00199000
DROP R3 00200000
GOTO DMKDSPCH WAIT FOR SOMEBODY TO UNLOCK THIS NAME!! 00201000
EJECT 00202000
* SCAN SUBROUTINE 00203000
SPACE 00204000
SCAN LM R2,R3,0(R1) PICK UP NAME FROM CALLER 00205000
L R10,ASYSLC POINTER TO SYSLOCS 00206000
LA R4,DMKSYSLB SET UP FOR FIRST TIME 00207000
L R5,DMKSYSLB PICK UP POINTER TO FIRST L BLOCK 00208000
RESCAN LTR R5,R5 IS POINTER 0 00209000
BCR 8,R9 YES- END OF LIST GO BACK TO CALLER 00210000
LR R8,R4 POINT TO THE LAST L BLOCK 00211000
LR R4,R5 SET POINTER TO NEXT L BLOCK 00212000
L R5,LOCKNEXT POINT TO NEXT L BLOCK 00213000
LM R6,R7,LOCKNAME PICK UP L BLOCK NAME 00214000
CLR R2,R6 IS NAME EQ 00215000
BNE RESCAN NO- BRANCH 00216000
CLR R3,R7 IS NAME EQ 00217000
BNE RESCAN NO- BRANCH 00218000
TM *,X'FF' SET CC EQ 1 00219000
BR R9 GO BACK TO CALLER 00220000
SPACE 2 00221000
EXITCC0 SR R0,R0 SET CC = 0 00222000
EXIT LM R0,R15,BALRSAVE RETURN THE CALLERS REG'S 00223000
BR R14 AND GO BACK 00224000
EXITCC1 TM *,X'FF' SET CC EQ 1 00225000
B EXIT RETURN TO CALLER CC = 1 00226000
EXITCC2 CLI *,X'00' SET CC = 2 00227000
B EXIT RETURN TO CALLER CC EQ 0 00228000
SPACE 3 00229000
LTORG 00230000
EJECT 00231000
COPY EQU 00232000
COPY SAVE 00233000
COPY UDIRECT 00234000
SYSLOCS 00235000
PSA 00236000
END DMKLOC 00237000