.title attach_qe attach queue with exit handler ;.begin.doc ************************** begin.doc ; ; .c ;MODULE ; .c ;^&ATTACH_QE\& ; .nf ; .x ATTACH_QE>Defined ; Source:SSDISP.MAR ; Designer :EARL LAKIA ; Author :EARL LAKIA ; Inland Steel ; Process Automation Department ; 3210 Watling St. MS 2-465 ; East Chicago, IN 46312 ; ; Date of last update: 19-FEB-1987 ; Revision level :1.0 ; ; .C ;Formal Parameter List ; ; ; QBX RECORD/QEXDEF/ ; QBX WILL CONTAIN THE START ADDRESS FOR P0 ; (QBX.Q_BLOCK(1)), THE ENDING ADDRESS FOR ; P0 (QBX.Q_BLOCK(2)), AND THE EXIT HANDLER ; BLOCK (QBX.EXIT). ; ; Q_NAME CHARACTER*16 ; GLOBAL SECTION NAME (OPTIONAL). This parameter ; IF SPECIFIED, IDENTIFIES THE GLOBAL SECTION TO ; BE ATTACHED. IF NOT SPECIFIED, THE DEFAULT ; GLOBAL SECTION IS ATTACHED AS SPECIFIED BY ; EITHER THE NAME "MA_Q_NAME" OR THE LOGICAL NAME ; "GBL$MA_Q_NAME". ; ; MID_COUNT INTEGER*2 (OPTIONAL) ; MAXIMUM NUMBER OF MESSAGE IDS THE CALLER WILL ; ATTTACH TO. IF NOT SPECIFIED, THE DEFAULT IS ; USED. ; ; Returns: ; ; ATTACH_QE INTEGER*4 ; THIS IS THE RETURN CODE AS DESCRIBED BY THE VMS ; STANDARDS AND THE QUESRV STANDARDS. ; ; Accesses common(s): ; ; Accesses file(s): ; ; Other modules referenced: ; .SK ; .fill ; .SK ; Description: ; .sk ; ; ; This routine expands P0 space to get a working area. ; The global section is then attached, with the information being stored ; in the P0 work space. A null lock is created to ; be used for accessing the global section. Some Process information ; is obtained and stored in the working area. ; An exit handler is setup in supervisor mode. ; This entry is different from the ATTACH_Q entry in that it ; will also set up a user mode exit handler (pointing to within ; this service) that will attempt to do a DETACH_Q for the caller. ; This is important when a process is ran via DCL as the process ; rundown will not occurr (and therefore the supervisor mode ; exit handler). If the supervisor mode exit handler does not get ; executed, the queue will not be detached nor will the message ids ; be disconnected. Subsequent runs of the process will return the ; error code QUE_ALRATT or QUE_MIDATTACHED. ; ; Note: Since this subroutine stores a exit block for the caller, ; any destruction of the QBX structure may result in strange ; exits and faults. ; ; This routines expects the parameters to be valid, if not an ; appropriate return code is returned to the caller. ; ; .tp 27 ; .nofill ; .SKIP ; INCLUDE 'MA_Q$DEF:QUEUE.TLB(QUECONST)' ; INCLUDE 'MA_Q$DEF:QUEUE.TLB(QEXDEF)' ; RECORD/QBXDEF/QBX ; INTEGER*2 MID_COUNT ; CHARACTER Q_NAME*(*) ; PARAMETER (Q_NAME = 'MY_OWN_QUEUE') ; MID_COUNT = 7 ; ... ; STATUS = ATTACH_QE (QBX) ; OR ; STATUS = ATTACH_QE (QBX, Q_NAME) ; OR ; STATUS = ATTACH_QE (QBX, Q_NAME, MID_COUNT) ; OR ; STATUS = ATTACH_QE (QBX, , MID_COUNT) ; ; NOTE: ; When calling the subsequent routines, the parameter ; for the Q_BLOCK is simply: QBX.Q_BLOCK. ; ; POSSIBLE ERRORS: ; .SK ; .list 1,' ' ; .LE;QUE_INSFARG - Insufficient arguments ; .X QUE_INSFARG ; .LE;QUE_INVARG - Invalid arguments ; .X QUE_INVARG ; .LE;QUE_GTRMAX - Number specified is greater than allowed maximum number of MIDs ; .X QUE_GTRMAX ; .LE;QUE_NOCHK - Checkpoint process is not available ; .X QUE_NOCHK ; .LE;QUE_ALRATT- Queue already attached ; .x QUE_ALRATT ; .ELS ; ; .fill ; end.doc ****************************** end.doc .LIBRARY "SYS$LIBRARY:LIB.MLB" ; Macro library for system structure ; definitions .LIBRARYR "MA_Q$DEF:QUEUE.MLB" ; Queue macro library .list meb QEXDEF .NLIST MEB .page .ENTRY ATTACH_QE,^M ; ; Check the passed parameters ; CMPB (AP), #1 ; enough arguments? BGEQ 30$ ; YES MOVL #QUE_INSFARG ,R0 ; NO, return status RET 20$: MOVL #QUE_INVARG,R0 ; QEX is not writeable RET ; 30$: MOVL 4(AP),R5 ; Get the QBX address IFNOWRT #QEX$K_SIZ,(R5),20$ ; insure QBX writeable ; ; Go attach the queue ; MOVL AP,R3 ; Address of argument stack CALLG (R3),ATTACH_Q ; Go attach the queue with user list BLBC R0,50$ ; Something didn't work ; ; Set up a user mode exit handler and store into the structure ; MOVL #2,QEX$C_DESBLK+8(R5) ; Number of arguments (ie: 2) MOVAB #DETACH_EXIT,QEX$C_DESBLK+4(R5) ; Exit handler address MOVL R5,QEX$C_DESBLK+16(R5) ; Address of our Q_block ( second ; ; parameter) $DCLEXH_S DESBLK=QEX$C_DESBLK)R5) ; Address of exit ; descriptor block 50$: RET .PAGE .SBTTL USER ATTACH_QE EXIT HANDLER ; ; This subroutine is called in user mode when the process ; exits. This will simply call detach_Q and return. ; 0(AP)= number of arguments (2) ; 4(AP)= Exit reason ; 8(AP)= QEX structure address ; .PSECT DETACH_EXIT,LONG,NOWRT,EXE .ENTRY DETACH_EXIT ; Nothing to save PUSHL 8(AP) ; Push the Q_BLOCK address CALLS #1,DETACH_Q ; Detach the queue RET .END