CCTL multithread example

This example illustrates the concept of concurrent processing in a multithreading system.

Events in a multithreading system are shown in chronological order from top to bottom in the following example. To illustrate the concept of concurrent processing, the figure is split into two columns.

There are two CCTL threads and two DRA threads in the example. CCTLRTNA is the module name (for this example) of the CCTL routine that builds PAPLs and calls DFSPRRC0 to process DRA requests.

Important: In the following example, only one CCTL TCB is used. However, multiple CCTL TCBs in a single address space can be used to process multiple CCTL threads. CCTL can dispatch each CCTL thread for a different CCTL TCB, and each CCTL TCB can call the DRA Startup/Router routine (DFSPRRC0) to process DRA requests.
Table 1. Example of events in a multithreading system
CCTL TCB events DRA TCB events
Application program1 needs a PSB, so CCTL thread1 is created.  
CCTL thread1 events:  
  • CCTLRTNA builds the SCHED PAPL and calls DFSPRRC0.
 
  • DFSPRRC0 creates a DRA thread, and the thread token (PAPLTTOK) is assigned to DRA thread TCB1.
 
  • DFSPRRC0 activates thread TCB1.
 
  • DFSPRRC0 calls the Suspend exit routine.
 
  • The Suspend exit routine suspends CCTL thread1.
 
  DRA thread TCB1 events:
 
  • The DRA processes the SCHED request and asks IMS DB to perform a schedule process.
 
  • Scheduling is in progress.
CCTL can now dispatch other CCTL threads for the CCTL TCB.  
Application program2 needs a PSB, so CCTL thread2 is created.  
CCTL thread2 events:  
  • CCTLRTNA builds the SCHED PAPL and calls DFSPRRC0.
 
  • DFSPRRC0 creates a DRA thread, and a new thread token (PAPLTTOK) is assigned to DRA thread TCB2.
 
  • DFSPRRC0 activates thread TCB2.
 
  • DFSPRRC0 calls the Suspend exit routine. The Suspend exit routine suspends CCTL thread2.
 
  DRA thread TCB2 events:
 
  • The DRA processes the SCHED request and asks IMS DB to perform a schedule process.
 
  • Scheduling is in progress.
Both threads are now suspended. The CCTL TCB is inactive until one of the threads resumes execution.  
  TCB2 scheduling finishes first.
   
  DRA thread TCB2 events:
 
  • Scheduling completes in IMS DB, and the PAPL is filled in with the results.
 
  • The DRA calls the Resume exit routine and passes the PAPL back to the CCTL.
Thread2 can resume immediately because the CCTL TCB is idle. Execution resumes directly after the point at which the thread was suspended by the Suspend exit routine.
  • The Resume exit routine sees the thread token (PAPLTTOK) and flags CCTL thread2 as 'ready to resume'.
  • The Resume exit routine returns to the DRA, and TCB2 becomes inactive.
  TCB1 scheduling completes.
   
  DRA thread TCB1 events:
 
  • Scheduling completes in IMS DB and the PAPL is filled in with the results.
 
  • The DRA calls the Resume exit routine and passes the PAPL back to the CCTL.
Thread1 must wait until the Resume exit routine is available because thread2 has just resumed.
  • The Resume exit routine sees the thread token (PAPLTTOK) and flags CCTL thread1 as 'ready to resume'.
 
  • The Resume exit routine returns control to the DRA and TCB1 becomes inactive.
CCTL thread2 events:  
  • The Suspend exit routine returns to its caller, DFSPRRC0.
 
  • DFSPRRC0 returns to CCTLRTNA.
 
  • CCTLRTNA gets the results from the SCHED PAPL and gives them to the application program2.
 
  • CCTLRTNA finishes the thread2 SCHED request.
 
After thread2 completes in CCTL TCB, the CCTL can dispatch thread1, which is currently waiting.  
   
CCTL thread1 events:  
  • The Suspend exit routine returns to its caller, DFSPRRC0.
 
  • DFSPRRC0 returns to CCTLRTNA.
 
  • CCTLRTNA gets the results from the SCHED PAPL and gives them to the application program1.
 
  • CCTLRTNA finishes the thread1 SCHED request.
 
   
CCTL thread2 events:  
  • CCTLRTNA builds the DL/I PAPL and calls DFSPRRC0.
 
  • DFSPRRC0 finds the correct DRA thread.
 
  • DFSPRRC0 activates thread TCB2.
 
  • DFSPRRC0 calls the Suspend exit routine.
 
  • The Suspend exit routine suspends CCTL thread2.
 
   
CCTL thread1 events:  
  • CCTLRTNA builds the DL/I PAPL and calls DFSPRRC0.
 
  • DFSPRRC0 finds the correct DRA thread.
 
  • DFSPRRC0 activates thread TCB1.
 
  • DFSPRRC0 calls the Suspend exit routine.
 
  • The Suspend exit routine suspends CCTL thread1.
 
   
Application program2 completes. The CCTL makes sync-point requests to IMS DB to commit the processing of this UOR. The CCTL flags the UOR for application program2 as in-doubt prior to issuing a phase 1 request. The CCTL keeps a record of this in-doubt UOR until the CCTL can make a successful phase 2 call to IMS DB.  
  DRA thread TCB1 events:
 
  • The DL/I call is in progress.
 
  • The DRA processes the DL/I PAPL and asks IMS DB to perform a DL/I process.
   
CCTL thread2 events:  
  • CCTLRTNA issues a PREP request and calls DFSPRRC0.
 
  • DFSPRRC0 activates thread TCB2.
 
  • DFSPRRC0 calls the Suspend exit routine.
 
  • The Suspend exit routine suspends CCTL thread2.
 
  DRA thread TCB2 events:
 
  • The DRA sends the PREP request to IMS DB.
 
  • IMS DB logs Phase 1 complete. This IMS DB UOR is now in-doubt.
 
  • The PREP request completes successfully and calls the Resume exit routine.
The PREP request results are returned to CCTLRTNA (by the PREP PAPL), and thread2 becomes inactive.  
  DRA thread TCB1 events:
 
  • IMS DB detects a DL/I failure. This failure results in termination of this DRA thread and a termination of this thread TCB.
 
  • Since this thread was in a schedule state, the DRA calls the Status exit routine and passes the DL/I PAPL back to the CCTL after putting UPSTOR information in it.
 
  • The Status exit routine associates UPSTOR with a CCTL thread, and the routine passes the PAPL to the DRA.
 
  • The DRA calls the Resume exit routine.
 
  • The DRA takes an SDUMP and terminates thread TCB1.
CCTL thread1 events:  
  • After thread1 has been resumed, control is passed back to CCTLRTNA.
 
  • The CCTL notices that the DL/I request failed (returning PAPLRETC=4) and takes a diagnostic dump that includes UPSTOR.
 
  • The CCTL terminates this CCTL thread and frees UPSTOR because thread1 failed.
 
Before CCTL sends a commit request for thread2, IMS DB fails.  
  DRA TCB events:
 
  • The DRA calls the Control exit routine to notify the CCTL that IMS DB failed.
 
  • The Control exit routine returns a code (PAPLRETC=8) that tells the DRA to reconnect to IMS DB.
 
  • The DRA terminates any existing thread TCBs. If the CCTL makes any subsequent requests to these terminated DRA threads, the DRA will respond with a return code indicating that the request cannot be processed.
 
  • After IMS DB has been restarted, the DRA successfully connects to IMS DB.
 
  • The DRA calls the Control exit routine to notify the CCTL that it successfully connected to IMS DB.
The CCTL creates a new task to resolve this in-doubt status because there is an entry in the resynchronization list for the IMS DB in-doubt UOR.
  • The DRA passes the address of the resynchronization list (PAPLRST) to the CCTL. The list contains one entry for the IMS DB indoubt UOR for CCTL thread2.
 
  • The Control exit routine returns a code (PAPLRETC=0) that tells the DRA to continue running.
 
  • The DRA completes the setup process by creating new DRA thread TCBs
CCTL thread3 events:  
  • The CCTL matches the in-doubt UOR in the re synchronization list with an in-doubt UOR in its own list. The CCTL in-doubt UOR is flagged for commit processing as its Phase 2 action.
 
  • CCTLRTNA issues a RESYNC request to DFSPRRC0 asking for commit processing. RESYNC is a DRA request, not a thread request.
 
  • DFSPRRC0 activates the DRA TCB to process the request and calls the Suspend exit routine.
 
 
  • DRA calls IMS DB to commit its UOR.
 
  • After successful processing, DRA calls the Resume exit routine.
  • After thread3 has been resumed, CCTLRTNA receives a return code of PAPLRETC=0.
 
  • The CCTL discards its indoubt UOR because the RESYNC request was successful.