Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 9: CICS DB2 Integration


DB2 Thread

A DB2 thread is the DB2-side agent that executes a CICS task's SQL. Threads are created, reused and terminated as transactions come and go.

What a DB2 thread is

  • When a CICS task issues its first SQL statement, CICS gets a DB2 thread for it through the DFHD2EX1 exit.
  • The thread holds the plan allocation, locks and cursors for that task's unit of work.
  • Creating a thread costs CPU, so CICS reuses threads instead of creating a new one for every transaction.
  • Too few threads means transactions wait. Too many wastes storage. Sizing is the main tuning job.

Thread types

  • Pool threads - shared threads any transaction can use when its own entry threads are exhausted.
  • Protected threads - threads kept alive after a transaction ends, ready for immediate reuse. Controlled by PROTECTNUM.
  • Command threads - threads used for DB2 commands issued from CICS, not for application SQL.
  • Protected threads avoid the create and terminate cost on every transaction, which matters at high volume.

Thread reuse and limits

  • After a transaction commits, its thread can return to the pool or stay protected for the next transaction.
  • THREADLIMIT - on a DB2ENTRY, the maximum threads transactions using that entry may hold at once.
  • THREADWAIT - what a transaction does when the limit is reached: wait, abend, or overflow to pool threads.
  • PROTECTNUM - how many threads stay protected (kept for reuse) for this entry.

Example

  • A DB2ENTRY definition giving one transaction group its own plan, thread limit and protected threads.
  • CREATE DB2ENTRY(CUSTENT) PLAN(CUSTPLAN) THREADLIMIT(25) THREADWAIT(POOL) PROTECTNUM(10)
  • Up to 25 threads may be active for this entry, overflow goes to pool threads, and 10 threads are kept protected for fast reuse.





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant