Module 1: CICS Introduction
CICS Tasks
When ten users run the same transaction at the same time, CICS runs ten tasks. The task is CICS's way of keeping every user's work separate, safe and moving forward.
What is a task
- A task is one execution - one instance - of a transaction.
- When a user types a transid, CICS attaches a task for that user.
- Each task gets a unique task number, so CICS can tell users apart.
- Many tasks of the same transaction can run concurrently, each with its own data.
- The task ends when the program issues EXEC CICS RETURN (or the task abends).
Transaction vs task vs program
- Transaction - the definition of the work (transid MNT1 and its first program).
- Task - one live execution of that transaction by one user (task number 12345).
- Program - the code the task runs (CUSTMNT1). One program copy can serve many tasks.
- Simple memory hook: transaction is the recipe, task is one cooking, program is the cook.
How CICS controls tasks
- The CICS dispatcher decides which task runs at each moment, switching at EXEC CICS commands.
- Tasks have priorities, so important work can go first.
- A task that loops without EXEC CICS commands gets an AICA abend (runaway task) so it cannot hang the region.
- Hung tasks can be removed with CEMT SET TASK(nnnnn) PURGE - use with care, as purging can leave data inconsistent.
- A task can pause itself politely with EXEC CICS DELAY or wait for an event with EXEC CICS SUSPEND.
Passing control between programs
- A task often runs several programs. CICS gives three ways to pass control:-EXEC CICS LINK PROGRAM('CALCINT') COMMAREA(WS-DATA) LENGTH(100) END-EXEC.
- LINK - call a program and come back (like a subroutine call). Shown above.
- XCTL - transfer control to another program with no return.
- RETURN - end the program; with TRANSID option it starts the next transaction.
- Note:- LINK and XCTL can pass data through COMMAREA, so the called program knows what to do.
