When VSAM reads or writes a control interval (CI) on DASD, it does not move the data byte by byte from the CPU. Instead, the mainframe uses a channel subsystem: the CPU builds a list of I/O commands—a channel program—and gives it to the channel. The channel and the device (e.g. a 3390 DASD volume) perform the actual data transfer. The CPU can do other work while the I/O is in progress. So the "virtual" in virtual channel programs refers to the fact that the channel program describes the I/O in terms of logical operations (e.g. read this block from this address on the device), and the system may use virtual addressing or logical volumes (e.g. 3390-style). This page explains what channel programs and CCWs are, how they relate to 3390 track access, and how VSAM uses them to move CIs between disk and memory.
A channel program is a sequence of Channel Command Words (CCWs) stored in memory. Each CCW describes one step of the I/O: for example, "seek to this cylinder and head," "read this many bytes into this buffer," or "write this buffer to this location." The program (or the access method, such as VSAM) builds the channel program and then starts the I/O—typically via a Start Subsystem Channel (SSCH) or equivalent. The channel subsystem picks up the channel program, sends the commands to the control unit and device, and the device performs the operations. When the channel program completes (or encounters an error), the channel signals the CPU (e.g. via an I/O interrupt), and the I/O supervisor can POST the ECB so the waiting task can continue. So the channel program is the "script" that tells the hardware what I/O to do; the CPU only builds the script and starts it.
Each CCW is typically 8 bytes (one doubleword). It contains: a command code (e.g. read, write, seek, search), the main-memory address where data is to be read from or written to, a count (number of bytes to transfer), and flag bits. One important flag is "chain to next CCW": when set, the channel continues with the next CCW after completing the current one, so a single channel program can do multiple operations (e.g. seek then read, or read multiple blocks). So a channel program might have a CCW to position the device (seek or search) and a CCW to read or write the data. VSAM builds such sequences to read one or more CIs (or index blocks) from the data or index component. The exact format of the CCW is defined by the architecture; the important point is that the channel, not the CPU, interprets and executes these commands.
| Command type | Description |
|---|---|
| Read | Read data from the device into the specified memory address. Used to read a track, block, or record into a buffer. |
| Write | Write data from memory to the device. Used to write a CI or block to DASD. |
| Seek / Search | Position the device (e.g. seek to cylinder and head, or search for a key). Often used before read/write to position to the correct track or record. |
| Control | Device-specific control operations (e.g. rewind, sense). Used for positioning or status. |
The 3390 is a type of DASD volume used on IBM mainframes. Data is organized on tracks; each track has a fixed capacity. When VSAM allocates space (e.g. in cylinders or tracks), the system assigns extents on the volume. When VSAM needs to read or write a CI, it knows the location of that CI in terms of the volume, extent, and offset (or cylinder/track/record). The channel program is built with the correct device address (e.g. cylinder, head, record number) and the buffer address and length. So the "3390 track access" in the topic name means that the I/O is performed at the level of tracks (or blocks on tracks): the channel program tells the device to read or write a specific location on the 3390 (or a virtual 3390). VSAM does not deal with raw track addresses in your program; it translates logical CI positions to physical (or virtual) locations and builds the channel program accordingly.
"Virtual" can mean a few things. In some contexts it refers to the use of virtual (virtual storage) addresses in the channel program: the addresses in the CCWs may be virtual, and the system resolves them to real addresses when the I/O is started (and may fix the pages so they are not paged out during I/O). In other contexts it refers to virtual (emulated or logical) 3390 devices: the volume may not be a physical 3390 but an emulated one that behaves like a 3390. In either case, the idea is the same: the channel program is a list of commands that describe the I/O; the system and hardware carry it out. VSAM builds these programs when it needs to read or write a CI; the program is built in memory (often in a work area or in the I/O control blocks), and then the access method invokes the I/O driver (e.g. via SVC), which passes the channel program to the channel subsystem.
For every read or write of a control interval, VSAM (or the I/O component it uses) must transfer data between a buffer in memory and a location on the data or index component. The buffer is typically one of the data or index buffers (BUFND/BUFNI). The location on disk is determined by the cluster's allocation and the logical position of the CI (e.g. which extent, which block). VSAM (or the underlying I/O routine) builds a channel program: for example, one CCW to read the block at that location into the buffer, or to write the buffer to that location. If the I/O is to a 3390 (or compatible) volume, the channel program will use the appropriate CCW command and addressing for that device type. The channel program is then started; when the I/O completes, the ECB is posted and the task that was waiting (or the async completion routine) can proceed. So from the application's view you do a GET or PUT; under the covers, VSAM ensures the right CI is in the buffer by building and executing the right channel program.
A key benefit of the channel architecture is that once the channel program is started, the channel and device do the work. The CPU does not move the data; it can be dispatched to run another task. So multiple I/O operations can be in flight (e.g. multiple channel programs for different CIs), and the CPU can be busy with other work. This is why asynchronous I/O and multiple buffers (BUFND, BUFNI) can improve throughput: the program can have several I/O requests outstanding, and the channel and devices can be busy while the program prepares the next set of requests. When the program needs the result, it waits (WAIT/CHECK) on the ECB. So understanding channel programs helps you see why I/O is "asynchronous" from the CPU's perspective and why task synchronization (WAIT/POST) is needed before using the buffer.
Imagine you give a list of instructions to a robot (the channel): "Go to shelf 3, then pick up the box and put it here." The robot follows the list while you do something else. The list is like the channel program; each step is like a CCW. VSAM writes the list (builds the channel program) so the "robot" (the channel and disk) can bring the right box (the CI) to the right place (the buffer). You do not carry the box yourself—the channel does it.
1. What executes the channel program?
2. What is a CCW?
3. Why does VSAM build channel programs?