I have a control block chain in CSA above the BAR that is updated from multiple 
address spaces with a first and last pointer. The last entry in the chain has a 
next = 0. If there are no entries in the chain the first and last pointer = 0. 
I seem to be adding two entries to the beginning of the chain at the same time 
because rarely one of the control blocks is never freed and it always has a 
next pointer of zero.   

I use the following code to add a control block to the end of the chain (always 
add to the end of the chain):

FIRST       DS     D
LAST        DS     D

DOX378   DS    0H                                                    
         LG    R6,LAST                                           
*C     IF FIRST AND LAST EQ 0                                 
*C         SET FIRST AND LAST = NEW CB ADDRESS            
         XGR   R4,R4                                                 
         XGR   R5,R5                                                 
         LGR   R2,R8    (R8: ADDRESS OF CB)                      
         LGR   R3,R8                                                 
         CDSG  R4,R2,FIRST IF FIRST & LAST 0, STM 2,3,FIRST
         BC    4,ELIFX076                                            
*C       ELSE                                                        
         BC    8,EDOX378                                             
ELIFX076 DS    0H                                                    
*C IF LAST = LAST (R6)                                         
*C   SET LAST = POINTER_TO_NEW_ (R8)                           
*C   SET NEXT.OF.LAST.ONCHAIN= POINTER_TO_NEW_ (R8)            
         STG   R6,OPERAND1            (COMPARISON VALUE)               
         STG   R8,OPERAND1R           (REPLACEMENT VALUE)              
         LA    R0,CSDSTG                                               
         LGR   R3,R8                                                   
         LA    R4,LAST   LAST IS IN CSA                        
         STG   R4,OPERAND6                                             
         DROP  R8                                                      
         USING CB,R6                                               
         LA    R4,NEXT   NEXT IS IN CSA                        
         STG   R4,OPERAND4                                             
         STG   R8,OPERAND3                                             
         STG   R8,OPERAND5                                             
         PLO   0,LAST,0,PL                                         
*  THE FIRST-OPERAND COMPARISON VALUE AND THE SECOND OPERAND ARE       
*  COMPARED.  IF THEY ARE EQUAL, THE FIRST-OPERAND REPLACEMENT VALUE   
*  IS STORED AT THE SECOND-OPERAND LOCATION, AND THE THIRD OPERAND IS  
*  STORED AT THE FOURTH-OPERAND LOCATION. THEN, THE FIFTH OPERAND IS   
*  STORED AT THE SIXTH-OPERAND LOCATION.
EDOX378  DS   0h

Note: I think I could use a CSSTG PLO but this should work and I don’t want to 
break what normally works since this is production code.  I have looked at this 
code until my eyes are falling out. Does anyone see a flaw in this logic?   

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to