By defining a program to CICS® as
threadsafe, you are specifying only that the application logic is
threadsafe, not that all the EXEC CICS commands
included in the program are threadsafe. CICS can
ensure that EXEC CICS commands
are processed safely by switching to the QR TCB for those commands
not yet converted that still rely on quasi-reentrancy. In order for
your program to run on an open TCB, CICS needs
you to guarantee that your application logic is threadsafe.
The EXEC CICS commands that
are threadsafe, and so do not involve TCB switching, are indicated
in the command descriptions of the CICS API and SPI command topics.
The commands are also listed in Threadsafe
commands and Threadsafe SPI commands.
TCB switching
Threadsafe
programs achieve performance benefits by remaining on an open TCB,
rather than switching between the open TCB and the QR TCB. When a
program is defined as threadsafe and is running on an open TCB, TCB
switching from the open TCB to the QR TCB occurs in the following
circumstances:
- If the program issues any EXEC CICS commands that are
not threadsafe, CICS switches back from the open TCB to the
QR TCB to run the nonthreadsafe code. If the program is defined as
OPENAPI or CONCURRENCY(REQUIRED), CICS then switches back to the open
TCB to continue running the application logic. If the program is not
defined as OPENAPI or CONCURRENCY(REQUIRED), it continues to run on
the QR TCB. For a CICS DB2® application,
if the program is not defined as OPENAPI or CONCURRENCY(REQUIRED)
and does not make any further DB2 requests, the switch back to
the QR TCB is a disadvantage because it increases the usage of your
QR TCB for the time taken to run any remaining application code. However,
if the program makes any further DB2 requests, CICS must
switch back again to the open TCB.
- If the program calls a task-related user exit program
that is not defined as threadsafe, CICS switches
back to the QR TCB and gives control to the task-related user exit
program. When the task-related user exit program completes processing,
the situation is the same as after a nonthreadsafe EXEC CICS command:
an OPENAPI or CONCURRENCY(REQUIRED) program switches back to the open
TCB, and a program not defined as OPENAPI or CONCURRENCY(REQUIRED)
continues to run on the QR TCB.
- When the program issues a threadsafe CICS command
or makes a DB2 request, a global user exit might be invoked
as part of the processing for the command or request. If a global
user exit program is used that is not defined as threadsafe, CICS switches
back to the QR TCB and gives control to the global user exit program.
When the user exit program completes processing, CICS switches
back to the open TCB to continue processing the threadsafe CICS command
or to complete the DB2 request.
- When the program completes, CICS switches
back to the QR TCB for task termination. This switch is always necessary.