Accounting for processor usage in a CICS DB2 environment
Information about processor time consumption is provided in the DB2® accounting and statistics trace records. You can use these records to calculate the total processor time used in CICS® and DB2.
The DB2 accounting trace can be started with CLASS 1, CLASS 2, or CLASS 3. However, CLASS 1 must always be active to externalize the information collected by activating CLASS 2, CLASS 3, or both classes.
The processor times reported in the DB2 accounting records are the TCB time for the thread TCB running code in CICS or in the DB2 address space, using cross-memory services; and the SRB time for work scheduled in CICS.
CLASS 1 (the default) results in accounting data being accumulated by several DB2 components during normal execution. This data is then collected to write the DB2 accounting record. The data collection does not involve any overhead of individual event tracing.
CLASS 2 and CLASS 3 activate many additional trace points. Every occurrence of these events is traced internally, but is not written to an external destination. Rather, the accounting facility uses these traces to compute the additional total statistics that appear in the accounting record when CLASS 2 or CLASS 3 is activated. Accounting CLASS 1 must be active to externalize the information.
CLASS 2 collects the delta elapsed and processor times spent 'IN DB2' and records this in the accounting record.
CLASS 3 collects the I/O elapsed time and lock and latch suspension time spent 'IN DB2' and records this in the accounting record.
CLASS 7 and CLASS 8 in DB2 collect package level accounting in DB2 and package level accounting wait in DB2. For information on package level accounting, refer to the DB2 for z/OS: Application Programming Guide and Reference for Java.
- Time under a DB2 address space TCB running asynchronous of the CICS address space. Examples of this are the DB2 log and writes from the buffer pools.
- Time under SRBs scheduled under the DB2 address spaces. An example is the asynchronous read engine for sequential prefetch.
- Database manager address space
- System services address space
- IRLM.
DB2 accounting records are produced when a thread is terminated or signon occurs. This means that the period reported in the DB2 accounting record is the time between thread start or user signon (if reusing a thread previously used by another user) and thread termination or another signon. If several different transactions are specified for the same DB2ENTRY, and they use the same CICS transaction ID and the same DB2 authorization ID to sign on to the thread, then the DB2 accounting record for this thread can include data for more than one transaction. Also, if a transaction releases its DB2 thread at syncpoint, and the thread is terminated or re-used by another transaction, then the original transaction has to use a different thread. A single transaction can therefore be associated with multiple DB2 threads during the life of its execution. As DB2 produces accounting records for each thread, this can mean that multiple accounting records are produced for the transaction. See Controlling the relationship between DB2 accounting records and CICS performance class records for information on how you can determine the transactions that are included in each DB2 accounting record.
The processor time is accurately obtainable by authorization ID within the transaction by aggregating all the accounting records for this authorization ID and transaction. Note, however, that the elapsed times associated with the accounting record would be of little value in this case, because the sum of the elapsed times does not include the time from one commit point to the first SQL call in the next UOW. The elapsed time for a thread is associated with the thread and not with the transaction.
Figure 1 and Figure 2 show each period of processor time that is reported by CICS and DB2, and where it takes place. The location of processing differs depending on whether or not the application accessing DB2 is threadsafe. This is because when CICS is connected to DB2, and is exploiting the open transaction environment, the CICS DB2 attachment facility uses CICS-managed open TCBs rather than CICS DB2 subtask TCBs.

This picture shows the environment when CICS is connected
to DB2 when the application
accessing DB2 is not threadsafe.
Times 3 + 6 + 9 are reported as CLASS 1 processor time
(time spent under the thread TCB)
Times 2 + 5 + 8 are reported as CLASS 2 processor time
(time spent in DB2)
Times 1 + 4 + 7 + 10 are reported as CICS processor time
(time spent on the CICS main TCB)
- Time 1: The application starts on the CICS main TCB. At the end of Time 1, the application issues an EXEC SQL request.
- Time 2: DB2 is fulfilling the application's request. This processor time is spent in the DB2 address space. At the end of Time 2, DB2 passes its response to the CICS DB2 attachment facility.
- Time 3: The CICS DB2 attachment facility is carrying out processing on the thread TCB. This covers both the processing needed for the application to access DB2, and the processing needed to pass DB2's response back to the application. It also includes the processor time taken for DB2 to fulfil the request and respond. Time 2 is therefore nested within Time 3. At the end of Time 3, DB2's response is passed to the application, and the access to DB2 is complete.
- Time 4: The application has finished with DB2 for the moment. The application code runs on the CICS main TCB, until the application needs to access DB2 again. At the end of Time 4, the application issues a second EXEC SQL request.
- Time 5: As for Time 2, DB2 is fulfilling the second request from the application.
- Time 6: The CICS DB2 attachment facility is carrying out processing on the thread TCB related to this second request, or waiting for a response from DB2.
- Time 7: The application code runs again on the CICS main TCB. It issues a third EXEC SQL request.
- Time 8: As for Time 2, DB2 is fulfilling a third request from the application.
- Time 9: The CICS DB2 attachment facility is carrying out processing on the thread TCB related to this third request, or waiting for a response from DB2.
- Time 10: The application has now made all its EXEC SQL requests. The application code continues to run on the CICS main TCB until it terminates.

This picture shows the environment when CICS is connected to DB2,
and when the application accessing DB2 is threadsafe.
Times 3 + 4 + 6 + 7 + 9 + 10 are reported as CLASS 1 processor time
(time spent under the open TCB, processing access to DB2
and running application code)
Times 2 + 5 + 8 are reported as CLASS 2 processor time
(time spent in DB2)
Times 1 + 11 are reported as CICS processor time
(time spent on the CICS main TCB)
- Time 1: The application starts on the CICS main TCB. At the end of Time 1, the application issues an EXEC SQL request.
- Time 2: DB2 is fulfilling the application's request. This processor time is spent in the DB2 address space. At the end of Time 2, DB2 passes its response to the CICS DB2 attachment facility.
- Time 3: The CICS DB2 attachment facility is carrying out processing on the thread TCB. This covers both the processing needed for the application to access DB2, and the processing needed to pass DB2's response back to the application. It also includes the processor time taken for DB2 to fulfil the request and respond. Time 2 is therefore nested within Time 3. At the end of Time 3, DB2's response is passed to the application, and the access to DB2 is complete.
- Time 4: The application has finished with DB2 for the moment. As the application is threadsafe, the application code now runs on the thread TCB (the open TCB). At the end of Time 4, the application issues a second EXEC SQL request.
- Time 5: As for Time 2, DB2 is fulfilling the second request from the application.
- Time 6: The CICS DB2 attachment facility is carrying out processing on the thread TCB related to this second request, or waiting for a response from DB2.
- Time 7: The application code runs again on the thread TCB. It issues a third EXEC SQL request.
- Time 8: As for Time 2, DB2 is fulfilling a third request from the application.
- Time 9: The CICS DB2 attachment facility is carrying out processing on the thread TCB related to this third request, or waiting for a response from DB2.
- Time 10: The application has now made all its EXEC SQL requests. The application code runs again on the thread TCB.
- Time 11: The application has completed its processing. The application terminates, and processing returns to the CICS main TCB.