ASK TITLE 'DMTASK (RSCS) VM/370 - RELEASE 6' 00001000 *. 00002000 * MODULE NAME - 00003000 * 00004000 * DMTASK 00005000 * 00006000 * FUNCTION - 00007000 * 00008000 * THE DMTASK MODULE IS THE SERVICE ROUTINE WHICH 00009000 * CREATES NEW TASKS AND DELETES EXISTING TASKS 00010000 * EXECUTED BY MSUP. THE ENTRY TO DMTASK IS BY MEANS 00011000 * OF A BRANCH AND LINK FROM TASK PROGRAMMING. ANY 00012000 * ENTRY TO DMTASK CAUSES THE CALLING TASK'S 00013000 * EXECUTION TO BE SUSPENDED THROUGH THE FREEZE SVC 00014000 * FUNCTION. 00015000 * 00016000 * ATTRIBUTES - 00017000 * 00018000 * REUSABLE, NON-INTERRUPTABLE 00019000 * 00020000 * ENTRY POINTS - 00021000 * 00022000 * DMTASK - INITIATE TASK, TERMINATE TASK, QUERY TASK STATUS 00023000 * 00024000 * ENTRY CONDITIONS - 00025000 * 00026000 * GPR0 = FOUR BYTE TASK NAME 00027000 * GPR1 = ADDR OF SYS SAVE AREA FOR TASK TO CREATE 00028000 * = X'00' IF QUERY STATUS REQUEST 00029000 * = ANY NEGATIVE VALUE IF DELETE REQUEST 00030000 * GPR14 = RETURN ADDRESS 00031000 * GPR15 = ENTRY ADDRESS (FROM 'TASKREQ') 00032000 * 00033000 * EXIT CONDITIONS - 00034000 * 00035000 * NORMAL - 00036000 * 00037000 * GPR15 = X'00' CREATE OR DELETE SUCCESSFUL, OR TASK 00038000 * EXISTS ON QUERY STATUS 00039000 * 00040000 * ERROR - 00041000 * 00042000 * GPR15 = X'04' DUPLICATE NAME ON CREATE 00043000 * ACTIVE I/O ON DELETE REQUEST 00044000 * 00045000 * = X'08' NO AVAILABLE ID ON CREATE 00046000 * TASK DOES NOT EXIST ON QUERY OR DELETE REQUEST 00047000 * 00048000 * = X'10' (OR HIGHER) ERROR RETURN CODE FROM DMTQRQ 00049000 * 00050000 EJECT 00051000 * 00052000 * CALLS TO OTHER ROUTINES - 00053000 * 00054000 * DMTQRQ - TO RESERVE AND RELEASE SUP QUEUE ELEMENTS 00055000 * 00056000 * EXTERNAL REFERENCES - 00057000 * 00058000 * NONE 00059000 * 00060000 * TABLES / WORKAREAS - 00061000 * 00062000 * DMTVEC - SUPERVISOR COMMON AREA 00063000 * TASK ELEMENT 00064000 * I/O ELEMENT 00065000 * GIVE REQUEST ELEMENT 00066000 * FREE QUEUE ELEMENT 00067000 * 00068000 * REGISTER USAGE - 00069000 * 00070000 * GPR0 = TASK NAME 00071000 * GPR1 = TASK ELEMENT POINTER 00072000 * GPR2 = SCRATCH 00073000 * GPR3 = SCRATCH 00074000 * GPR4 = TASK ELEMENT POINTER 00075000 * GPR5 = SCRATCH 00076000 * GPR6 = I/O ELEMENT POINTER, SCRATCH 00077000 * GPR7 = SCRATCH 00078000 * GPR8 = SCRATCH 00079000 * GPR9 = SCRATCH 00080000 * GPR10 = UNUSED 00081000 * GPR11 = UNUSED 00082000 * GPR12 = DMTASK BASE REGISTER 00083000 * GPR13 = TASK SAVE AREA POINTER 00084000 * GPR14 = LINKAGE RETURN ADDR (INTERNAL AND EXTERNAL) 00085000 * GPR15 = EXTERNAL LINKAGE ENTRY ADDR AND RETURN CODE 00086000 * 00087000 * NOTES - 00088000 * 00089000 * THE DMTASK SUPERVISOR SERVICE ROUTINE IS INTENDED TO 00090000 * USED WITH SUBSTANTIAL ADDITIONAL TASK LEVEL SOFTWARE 00091000 * SUPPORT. 00092000 * 00093000 * OPERATION - 00094000 * 00095000 * ON A REQUEST TO GENERATE A NEW TASK, DMTASK GETS 00096000 * A SUPERVISOR STATUS QUEUE ELEMENT BY A CALL TO 00097000 * DMTQRQ, BUILDS A NEW TASK ELEMENT FROM THE 00098000 * INFORMATION PROVIDED BY THE CALLING TASK, FINDS 00099000 * A ONE BYTE TASK ID WHICH IS NOT IN USE BY ANOTHER 00100000 * TASK, AND ENQUEUES THE NEW TASK ELEMENT. WHEN 00101000 * PROCESSING IS COMPLETE, DMTASK EXITS TO THE MSUP 00102000 * DISPATCHER. SINCE THE NEW TASK IS INITIALIZED 00103000 * DISPATCHABLE, THE NEW TASK CAN RECEIVE CONTROL 00104000 * BEFORE THE CALLING (CREATING) TASK IS REDISPATCHED 00105000 * ON RETURN FROM THE CREATE REQUEST. 00106000 * 00107000 * ON A REQUEST TO TERMINATE A TASK, DMTASK BEGINS 00108000 * BY SETTING THE "LIMBO" FLAG IN THE TASK ELEMENT OF 00109000 * THE TASK TO BE TERMINATED, UNLESS THE TASK TO BE 00110000 * TERMINATED IS THE SAME AS THE CALLING TASK. 00111000 * SETTING OF THE "LIMBO" FLAG MARKS THE TASK AS 00112000 * BEING PERMANENTLY NOT DISPATCHABLE. THE 00113000 * TERMINATION PROCESSING CONTINUES BY THE PURGING OF 00114000 * ALL INACTIVE I/O REQUESTS FOR THE TASK, ALL 00115000 * ASYNCHRONOUS EXIT REQUESTS FOR THE TASK, AND ALL 00116000 * PENDING GIVE REQUESTS FOR THE TASK. ALL PENDING 00117000 * GIVE REQUESTS ADDRESSED TO THE TERMINATING TASK 00118000 * ARE PURGED, AND EACH ASSOCIATED GIVE TABLE IS 00119000 * POSTED WITH A X'FF' CODE. A SEARCH IS MADE FOR 00120000 * ACTIVE I/O PROCESSING WHICH WAS INITIATED BY THE 00121000 * TASK BEING TERMINATED; IF SUCH I/O IS FOUND, 00122000 * PROCESSING IS TERMINATED AND CONTROL IS PASSED TO 00123000 * THE DISPATCHER WITH AN ERROR RETURN CONTROL AND 00124000 * THE TASK TO BE TERMINATED COMPLETELY DISABLED, BUT 00125000 * STILL IN EXISTENCE. (IT IS THE RESPONSIBILITY OF 00126000 * THE CALLING TASK TO CAUSE THE ACTIVE I/O TO BE 00127000 * TERMINATED AND TO RETRY THE TERMINATE REQUEST.) 00128000 * 00129000 * IF NO I/O IS ACTIVE FOR THE TERMINATING TASK, THE 00130000 * MAIN STORAGE RESERVED BY THE TASK IS RELEASED, THE 00131000 * TASK'S TASK ELEMENT IS DEQUEUED AND FREED BY A 00132000 * CALL TO DMTQRQ, AND CONTROL IS RETURNED TO THE 00133000 * DISPATCHER. 00134000 * 00135000 * 00136000 *. 00137000 EJECT 00138000 DMTASK CSECT 00139000 SPACE 00140000 * ENTRY POINT FOR CALL TO DMTASK ROUTINE 00141000 SPACE 00142000 FREEZE SAVE CALLING TASK'S STAT AND GET S/A ADDR 00143000 SPACE 00144000 LR R13,R14 REG.13 = ADDRESS OF CALLER'S TASK SAVE AREA 00145000 USING TAREA,R13 DEFINE TASK SAVE AREA DSECT ADDRESSA 00146000 USING SVECTORS,0 GET SVECTORS ADDRESSABILITY 00147000 USING TASKE,R4 GET TASK ELEMENT ADDRESSABILITY 00148000 SPACE 00149000 LA R12,0(R15) REG.12 = BASE REGISTER FOR TASK ROUTINE 00150000 USING DMTASK,R12 DEFINE DMTASK ADDRESSABILITY 00151000 SPACE 00152000 XC TGREG15(4),TGREG15 SET RETURN CODE TO ZERO FOR NOW 00153000 SR R2,R2 CLEAR ID COUNTER FOR START OF TASK QUEUE SCAN 00154000 LA R3,TASKQ INITIALIZE TASK ELEMENT POINTER 00155000 TASCAN EQU * 00156000 ICM R4,B'1111',TASKNEXT-TASKE(R3) REG 4 = ADDR OF NEXT ELEME 00157000 BZ TAQEND NOPE - WE ARE AT THE END OF THE QUEUE 00158000 CL R0,TASKNAME IS THIS THE REQUESTED NAME? 00159000 BE TAQHIT YES - QUIT SCANNING AND CHECK REQUEST 00160000 LR R3,R4 UPDATE TO NEXT 00161000 B TASCAN AND KEEP ON SCANNING 00162000 DROP R4 00163000 EJECT 00164000 TAQEND EQU * 00165000 USING TASKE,R1 GET TASKE ELEMENT ADDRESSABILTIY 00166000 LTR R5,R1 WHAT KIND OF REQUEST IS THIS, ANYWAY? 00167000 BNP TANOFIND RETURN WITH CODE IF NOT AN INITIALIZE REQUEST 00168000 * 00169000 * GENERATE A NEW ID 00170000 * 00171000 SR R2,R2 CLEAR ID COUNTER 00172000 LA R4,255 SET LIMIT 00173000 TAIDGEN EQU * 00174000 LA R2,1(R2) GENERATE NEXT SEQ ID 00175000 CLR R2,R4 HAVE ALL BEEN TRIED? 00176000 BNL TANOROOM YES - RETURN ERROR 00177000 LA R1,TASKQ INITIALIZE TASK QUEUE PTR 00178000 TAIDSCAN EQU * 00179000 ICM R1,B'1111',TASKNEXT LOOK AT NEXT TASK ELEMENT 00180000 BZ TAMAKE END OF QUEUE - GOT AN ID IN REG.2 00181000 CLM R2,B'0001',TASKID IS ID IN USE HERE? 00182000 BNE TAIDSCAN NOPE - KEEP LOOKING 00183000 B TAIDGEN ID IN USE - TRY NEXT SEQ ID 00184000 SPACE 00185000 TAMAKE EQU * 00186000 SR R1,R1 CLEAR REG.R1 FOR GET CALL TO SUP QUEUE MANAGER 00187000 L R15,QREQ REG.15 = ENTRY ADDRESS FOR SUP QUEUE MANAGER 00188000 BALR R14,R15 GET A FREE QUEUE ELEMENT 00189000 LTR R15,R15 WAS ONE AVAILABLE? 00190000 BNZ TAQERROR NOPE - QUIT NOW 00191000 MVC TASKNEXT(4),TASKNEXT-TASKE(R3) CHAIN NEXT TO NEW ELEMENT 00192000 ST R1,TASKNEXT-TASKE(R3) AND CHAIN NEW TO LAST ELEMENT 00193000 ST R5,TASKSAVE SET TASK SAVE AREA ADDRESS IN NEW ELEMEN 00194000 STC R2,TASKID SET THE NEW TASK ID 00195000 MVI TASKSTAT,X'00' INITIALIZE NEW TASK FLAGS TO ZERO 00196000 ST R0,TASKNAME SET TASK NAME TO REQUESTED VALUE 00197000 ST R2,TGREG0 RETURN NEW TASK ID IN REG.0 SAVE AREA 00198000 ST R1,TGREG13-TAREA(R5) SET NEW TASK'S REG 13 TO ITS TASK T 00199000 SPACE 00200000 TAEXIT EQU * 00201000 L R15,DISPATCH REG.15 = ENTRY ADDRESS FOR DISPATCH 00202000 BALR R14,R15 AND RETURN TO CALLER THROUGH DISPATCHER 00203000 DROP R1 00204000 USING TASKE,R4 GET TASK ELEMENT ADDRESSABILITY 00205000 SPACE 00206000 TAQHIT EQU * 00207000 LTR R5,R1 TEST THE TYPE OF ACTION REQUESTED 00208000 BZ TAEXIT EXIT WITH NORMAL RETURN IF STATUS REQUEST 00209000 BP TADUPNAM RETURN DUPLICATE NAME CODE IF INITIALIZE REQ 00210000 SPACE 00211000 CL R4,ACTIVE IS THIS THE ACTIVE TASK? 00212000 BE TANOSTOP YEP - DON'T TURN OFF HIS DISPATCHING 00213000 OI TASKSTAT,LIMBO SET TASK PERMANENTLY NON-DISPATCHABLE 00214000 TANOSTOP EQU * 00215000 LA R6,MPXIOQ SET UP TO PURGE INACTIVE MULTIPLEXOR I/O 00216000 BAL R14,TAIOPURG PURGE 'EM 00217000 LA R6,SELIOQ SET TO PURGE INACTIVE SELECTOR I/O, TOO 00218000 BAL R14,TAIOPURG DO IT 00219000 LA R6,IOEXITQ SET UP TO PURGE ASYN I/O EXIT REQ ELEMENTS 00220000 BAL R14,TAQPURGE AND DO IT 00221000 LA R6,EXTQ SET UP TO PURGE EXTERNAL EXITS 00222000 BAL R14,TAQPURGE AGAIN 00223000 LA R6,ALERTQ SET UP TO PURGE TASK ALERT EXITS 00224000 BAL R14,TAQPURGE AND AGAIN 00225000 LA R6,GIVEQ SET UP TO PURGE PENDING GIVE REQUESTS 00226000 BAL R14,TAQPURGE AND AGAIN 00227000 EJECT 00228000 * 00229000 * NOW CHECK FOR A POSSIBLE PENDING TAKE RESPONSE FROM THE 00230000 * TASK WHICH IS BEING TERMINATED 00231000 * 00232000 SPACE 00233000 LA R6,GIVEQ INITIALIZE GIVE QUEUE ELEMENT POINTER 00234000 USING GIVEE,R6 GET GIVE ELEMENT ADDRESSABILITY 00235000 TAGPURGE EQU * 00236000 LR R5,R6 MAKE THE CURRENT QUEUE ELEMENT LAST 00237000 ICM R6,B'1111',GIVENEXT-GIVEE(R5) MOVE THE ELEMENT POINTER T 00238000 BZ TAIOCHEK YES - NO PENDING TAKE RESPONSE FOR THIS TASK 00239000 CLC GIVENID(1),TASKID WAS THIS ELEMENT GIVEN TO TASK? 00240000 BNE TAGPURGE NOPE - KEEP LOOKING 00241000 MVC GIVENEXT-GIVEE(4,R5),GIVENEXT UNCHAIN ELEMENT IF SO 00242000 L R1,GIVEADDR REG.1 = ADDR OF GIVER'S SYNCH LOCK 00243000 LA R0,X'FF' SET POST CODE TO TASK TERMINATE CODE 00244000 L R15,POSTREQ REG.15 = ENTRY TO POST ROUTINE 00245000 BALR R14,R15 CALL THE POST ROUTINE TO NOTIFY GIVER 00246000 LR R1,R6 REG.1 = ADDR OF TERMINATED GIVE ELEMENT 00247000 L R15,QREQ REG.15 = ENTRY ADDR TO SUPERVISOR QUEUE MGR 00248000 BALR R14,R15 FREE THE TERMINATED GIVE ELEMENT 00249000 SPACE 00250000 TAIOCHEK EQU * 00251000 LA R6,MPXIOQ SET UP TO SCAN FOR ANY RUNNING I/O 00252000 BAL R14,TAIOSCAN GO LOOK FOR ANY ACTIVE MULTIPLEXOR I/O 00253000 LA R6,SELIOQ SET UP TO SCAN THE SELECTOR I/O QUEUE 00254000 BAL R14,TAIOSCAN LOOK FOR ACTIVE SELECTOR I/O 00255000 SPACE 2 00256000 * 00257000 * IF WE GET TO HERE, THE TASK HAS NO ACTIVE I/O PENDING AND 00258000 * HAS BEEN ENTIRELY PURGED EXCEPT FOR ALLOCATED MAIN STORAGE 00259000 * AND THE TASK QUEUE ELEMENT 00260000 * 00261000 SPACE 00262000 L R5,MAINMAP REG.5 = ADDRESS OF START OF MAIN STORAGE MAP 00263000 BCTR R5,0 BUMP BACK ONE FOR CONVENIENCE 00264000 L R6,MAINSIZE REG.6 = TOTAL NUMBER OF PAGES TO BE CHECKED 00265000 TAFREE EQU * 00266000 LA R5,1(R5) BUMP POINTER TO THE NEXT PAGE ENTRY 00267000 CLC 0(1,R5),TASKID DOES THIS PAGE BELONG TO THE TASK? 00268000 BNE TAFREEOK NOPE - LEAVE IT ALONE 00269000 MVI 0(R5),X'00' FREE THE PAGE IF IT DOES 00270000 TAFREEOK EQU * 00271000 BCT R6,TAFREE SHUFFLE THROUGH THE WHOLE MAP 00272000 SPACE 00273000 MVC TASKNEXT-TASKE(4,R3),TASKNEXT REMOVE TASK ELEMENT FROM Q 00274000 LR R1,R4 SET REG.1 TO ELEMENT ADDRESS FOR FREE 00275000 L R15,QREQ REG.15 = ENTRY ADDRESS FOR SUP QUEUE MANAGER 00276000 BALR R14,R15 FREE THE TERMINATED TASK ELEMENT 00277000 B TAEXIT AND RETURN TO CALLER 00278000 DROP R6 00279000 EJECT 00280000 USING IOE,R6 GET I/O ELEMENT ADDRESSABILITY 00281000 TAIOPURG EQU * SUBROUTINE TO PURGE INACTIVE I/O REQ ELEMENTS 00282000 LR R5,R6 MAKE CURRENT ACTIVE ELEMENT LAST 00283000 ICM R6,B'1111',IONEXT-IOE(R5) REG 6 = ADDR OF NEXT ACTIVE RE 00284000 BCR 8,R14 (BZ) YEP - RETURN TO THE CALLER 00285000 LR R8,R6 OTHERWISE INITIALIZE FOR A SUBQUEUE SCAN 00286000 TASQNEXT EQU * 00287000 LR R7,R8 MAKE THE CURRENT INACTIVE ELEMENT LAST 00288000 L R8,IOSUBQ-IOE(R7) AND MOVE POINTER TO THE NEXT ELEMENT 00289000 TASQTEST EQU * 00290000 LTR R8,R8 IS THIS THE END OF THE INACTIVE SUBQUEUE? 00291000 BZ TAIOPURG YEP - GO LOOK FOR ANOTHER ACTIVE ELEMENT 00292000 CLC IOID-IOE(1,R8),TASKID IS THIS ELEMENT ONE OF 'EM? 00293000 BNE TASQNEXT NOPE - GO TO THE NEXT INACTIVE ELEMENT 00294000 MVC IOSUBQ-IOE(4,R7),IOSUBQ-IOE(R8) DEQUEUE THE TASK'S ELEME 00295000 LR R1,R8 REG.1 = ADDR OF INACTIVE ELEMENT TO BE FREED 00296000 L R8,IOSUBQ-IOE(R8) BUT FIRST, GET THE ADDR OF THE NEXT EL 00297000 LR R9,R14 SAVE THE RETURN ADDRESS IN REG.9 00298000 L R15,QREQ REG.15 = ADDR OF QUEUE MANAGER ENTRY POINT 00299000 BALR R14,R15 FREE THE ELEMENT 00300000 LTR R15,R15 DID IT WORK OUT O.K.? 00301000 BNZ TAQERROR NOPE - QUIT WITH A BAD ERROR 00302000 LR R14,R9 OTHERWISE RESTORE THE RETURN ADDRESS 00303000 B TASQTEST AND CHECK THE NEXT INACTIVE ELEMENT 00304000 SPACE 2 00305000 USING FREEE,R5 GET FREE ELEMENT ADDRESSABILITY 00306000 TAQPURGE EQU * PURGE ALL TASK'S STANDARD FORMAT QUEUE ELEMENTS 00307000 LR R5,R6 MAKE THE CURRENT QUEUE ELEMENT LAST 00308000 L R6,FREENEXT MOVE THE ELEMENT POINTER TO THE NEXT 00309000 TAQPTEST EQU * 00310000 LTR R6,R6 IS THIS THE END OF THE QUEUE? 00311000 BCR 8,R14 (BZ) YEP - RETURN TO THE CALLER 00312000 CLC FREEID-FREEE(1,R6),TASKID IS THIS ELEMENT TO BE PURG 00313000 BNE TAQPURGE NOPE - CHECK THE NEXT ELEMENT IN THE QUEUE 00314000 MVC FREENEXT(4),FREENEXT-FREEE(R6) FIRST DEQUEUE IT 00315000 LR R1,R6 REG.1 = ADDR OF ELEMENT TO BE FREED FOR QUEUE MGR 00316000 L R6,FREENEXT-FREEE(R6) REG 6 = ADDR OF THE NEXT QUEUE ELE 00317000 LR R7,R14 SAVE THE RETURN ADDRESS IN REG.7 00318000 L R15,QREQ REG.15 = QUEUE MANAGER REQUEST ENTRY POINT 00319000 BALR R14,R15 FREE THE ELEMENT 00320000 LTR R15,R15 DID THAT WORK PROPERLY? 00321000 BNZ TAQERROR NOPE - PUNT 00322000 LR R14,R7 OTHERWISE RESTORE THE RETURN ADDRESS 00323000 B TAQPTEST AND CHECK THE NEXT QUEUE ELEMENT 00324000 SPACE 2 00325000 TAIOSCAN EQU * SCAN I/O QUEUES FOR TASK'S ACTIVE I/O 00326000 ICM R6,B'1111',IONEXT REG 6 = NEXT ELEMENT IN THE ACTIVE QUE 00327000 BCR 8,R14 (BZ) YEP - RETURN TO THE CALLER 00328000 CLC IOID(1),TASKID IS THIS ONE OF THE TASK'S ELEMENTS 00329000 BNE TAIOSCAN NOPE - KEEP LOOKING 00330000 B TAIOHOT OTHERWISE EXIT WITH ACTIVE I/O ERROR INDICATION 00331000 EJECT 00332000 TADUPNAM EQU * INIT TASK NAME DUPLICATES AN EXISTING TASK NAME 00333000 TAIOHOT EQU * TERM TASK HAS ACTIVE I/O RUNNING 00334000 LA R15,4 ERROR CODE 4 00335000 B TAEREXIT STORE RETURN CODE AND RETURN TO CALLER 00336000 SPACE 00337000 TANOROOM EQU * INIT FAILED DUE TO EXHAUSTED ID NUMBERS 00338000 TANOFIND EQU * STAT OR TERM TASK NAME WAS NOT FOUND 00339000 LA R15,8 ERROR CODE 8 00340000 SPACE 00341000 TAQERROR EQU * 00342000 * QUEUE MANAGER HAS SET A CODE IN REG 15 00343000 TAEREXIT EQU * 00344000 ST R15,TGREG15 SET THE RETURN CODE IN REG.15 SAVE AREA 00345000 B TAEXIT RETURN TO THE CALLER 00346000 EJECT 00347000 COPY RSSEQU 00348000 EJECT 00349000 COPY SVECTORS 00350000 EJECT 00351000 COPY TAREA 00352000 EJECT 00353000 COPY TASKE 00354000 EJECT 00355000 COPY IOE 00356000 EJECT 00357000 COPY FREEE 00358000 EJECT 00359000 COPY GIVEE 00360000 END 00361000