Module 2: CICS Architecture
CICS Storage Manager
The storage manager is the Storage Control Program, DFHSM. It hands out dynamic storage with GETMAIN, takes it back with FREEMAIN, and protects CICS from buggy programs.
What is the storage manager
- The storage manager is the Storage Control Program, DFHSM - part of the CICS nucleus.
- It manages all the dynamic storage inside the CICS address space, in the areas called DSAs.
- Application programs ask for storage with EXEC CICS GETMAIN and give it back with EXEC CICS FREEMAIN.
- Task-lifetime storage is freed automatically when the task ends, even if the program forgot the FREEMAIN.
GETMAIN and FREEMAIN
- GETMAIN SET(pointer) FLENGTH(length): CICS gives you a block of storage and puts its address in your pointer.
- INITIMG fills the new storage with a value, for example INITIMG(X'40') clears it to EBCDIC spaces.
- NOSUSPEND returns at once with the NOSTG condition if no storage is free, instead of making the task wait.
- FREEMAIN DATAPOINTER(pointer) gives the storage back. Get into the habit: every GETMAIN gets a FREEMAIN.
- Storage from GETMAIN is addressable only through the pointer - typically a LINKAGE SECTION item.
Storage protection and transaction isolation
- Storage has keys. CICS-key storage (CDSA) holds CICS control blocks. User-key storage (UDSA) holds application data.
- Storage protection stops a buggy application program from overwriting CICS control blocks. The task abends instead of corrupting the region.
- Transaction isolation stops one task from reading or changing another task's storage.
- Both are switched on with SIT parameters (STGPROT and TRANISO). Keep them on in production.
Short on storage (SOS)
- SOS means a DSA is nearly full. New GETMAIN requests wait or fail with NOSTG.
- Message DFHSM0131 is written to the console when CICS goes short on storage.
- Common causes: programs that GETMAIN in a loop and never FREEMAIN, or EDSALIM set too small for the workload.
- Fix the leak first. Raising EDSALIM without fixing the leak only delays the next SOS.
Example - GETMAIN and FREEMAIN in COBOL
- Get 500 bytes of working storage, cleared to spaces, use it, then free it.
- * Get 500 bytes of storage, cleared to EBCDIC spaces EXEC CICS GETMAIN SET(ADDRESS OF WS-DYN-AREA) FLENGTH(500) INITIMG(X'40') END-EXEC ... * Give the storage back when done EXEC CICS FREEMAIN DATAPOINTER(ADDRESS OF WS-DYN-AREA) END-EXEC
- WS-DYN-AREA is defined in the LINKAGE SECTION. The ADDRESS OF it is the pointer CICS fills in.
- Always handle the NOSTG condition (or use NOSUSPEND) so a storage shortage does not abend the task unexpectedly.
