traditional ibm mainframe operating...

34
343 Traditional IBM Mainframe Operating Principles WHEN YOU FINISH READING THIS CHAPTER YOU SHOULD BE ABLE TO: Distinguish between an absolute address and a relative address. Briefly explain the structure of both address types on a traditional IBM mainframe. Explain how the PSW determines the order in which instructions are executed. Distinguish between the BC mode, the EC mode, and the XA mode PSW. Explain how a traditional IBM mainframe determines the length of its instructions. Explain how I/O is controlled on a traditional IBM mainframe. Explain the significance of privileged instructions. Explain how the interrupt concept is implemented on a traditional IBM mainframe. Name the types of interrupts recognized on a traditional IBM mainframe and describe the source of each. List the permanent storage assignments on a traditional IBM mainframe. Explain why certain types of interrupts must be masked at certain times. Explain a traditional IBM mainframe’s interrupt priority. C H A P T E R 1 7

Upload: phungnguyet

Post on 06-Feb-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

343

Traditional IBMMainframe OperatingPrinciplesWHEN YOU FINISH READING THIS CHAPTER YOU SHOULD BE ABLE TO:

� Distinguish between an absolute address and a relative address. Brieflyexplain the structure of both address types on a traditional IBMmainframe.

� Explain how the PSW determines the order in which instructions areexecuted.

� Distinguish between the BC mode, the EC mode, and the XA modePSW.

� Explain how a traditional IBM mainframe determines the length of itsinstructions.

� Explain how I/O is controlled on a traditional IBM mainframe.

� Explain the significance of privileged instructions.

� Explain how the interrupt concept is implemented on a traditionalIBM mainframe.

� Name the types of interrupts recognized on a traditional IBMmainframe and describe the source of each.

� List the permanent storage assignments on a traditional IBMmainframe.

� Explain why certain types of interrupts must be masked at certaintimes.

� Explain a traditional IBM mainframe’s interrupt priority.

C H A P T E R 1 7

Page 2: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

344 Traditional IBM Mainframe Operating Principles

� The Hardware Environment

An operating system functions within a specific hardware environment; the hardware bothlimits and supports the software. Initially established with the release of System/360 in1964, IBM’s System/370 architecture was IBM’s primary mainframe architecture through-out the 1980s and continues to operate as a virtual machine or virtual environment onIBM’s current mainframes. This chapter introduces the basic operating principles of thisvenerable architecture and is essential for understanding Chapters 18 and 19.

� Addressing Memory

A traditional IBM mainframe is a byte-addressed machine. The bytes are numberedsequentially starting with 0 (Figure 17.1) and grouped to form 16-bit halfwords, 32-bitfullwords, and 64-bit doublewords. The first fullword occupies bytes 0 through 3; the sec-ond, bytes 4 through 7; and so on. A fullword’s address is simply the address of its firstbyte—0, 4, 8, and so on. Note that fullword addresses are evenly divisible by 4.

In addition to memory, a programmer also has access to 16 general-purpose registersnumbered 0 through 15 (0 through F in hexadecimal). Because 15 is 1111 in binary, fourbits are enough to uniquely identify a register.

Memory addresses can appear as operands in an instruction. Absolute addresses aretoo long and too inflexible, so relative addresses are used. Programs are written as thoughthey begin at location zero, and the address of any byte in the program is expressed as adisplacement from this base. When the program is loaded, its absolute entry point address

Doubleword 0

Fullword 0 Fullword 4

Halfword 0 Halfword 2 Halfword 4 Halfword 6

Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7

Figure 17.1

A traditional IBM mainframe’s memory hierarchy.

Page 3: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

is stored in a base register. As it executes, the instruction control unit converts relative base-plus-displacement addresses to absolute form by adding the displacement to the contentsof the base register.

Displacements are 12-bits long. Because the largest possible 12-bit number is equiva-lent to decimal 4095, programs exceeding 4096 bytes (displacements 0 through 4095)require multiple-base registers. To specify a base register (4 bits) and a displacement (12bits) requires 16 bits or 2 bytes. Thus, a relative base-plus-displacement address occupies 2bytes.

Translating relative addresses to absolute form is a hardware function performed bythe processor. Current IBM mainframes incorporate additional dynamic address transla-tion hardware to translate segment/page virtual addresses.

� The Program Status Word

A computer executes one instruction during each machine cycle. The instruction controlunit looks to the instruction counter for the address of its next instruction. An IBM main-frame’s instruction counter is called the program status word, or PSW.

The program status word has three different forms. The basic control (BC) mode(Figure 17.2a) is compatible with the original System/360 architecture, and is used onlywhen the dynamic address translation feature is disabled. The extended control (EC)mode (Figure 17.2b) implies virtual memory; in other words, adding a base register and adisplacement yields a virtual address that must be translated through segment and pagetables. Bit 12 is set to 0 for the basic control mode, and 1 for extended control.

The extended architecture (XA) mode format (Figure 17.2c) resembles EC mode.The primary difference is that the last 31 bits of an XA mode PSW hold the instructionaddress. In BC and EC modes, the instruction address is only 3 bytes or 24 bits long. Thebiggest binary number that can be stored in 24 bits is equivalent to 16,777,215, limitingthe computer to 16 megabytes of memory. With 31 bits, the largest possible address isslightly over 2 billion, yielding up to 2 gigabytes of memory in XA mode. Bit 32 is set to0 in EC mode (indicating a 24-bit address) and 1 in XA mode (indicating a 31-bitaddress).

Executing Instructions

The program status word (actually, a doubleword) occupies a special system register. Itskey function is program control. For example, consider the assembly language programsegment shown in Figure 17.3. It loads binary numbers into registers 3 and 4, adds thenumbers, and stores their sum, eventually repeating the instructions. Variables X, Y, andZ are symbolic memory locations (for simplicity, we’ll work with the source statements

345T H E P R O G R A M S T A T U S W O R D

Page 4: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

346 Traditional IBM Mainframe Operating Principles

rather than their machine language equivalents). The numbers to the left of Figure 17.3are assumed absolute addresses expressed in decimal.

The PSW’s last 24 (or 31) bits (Figure 17.2) contain the address of the instruction tobe executed next. As this program segment begins, the instruction address holds the binary

System mask

0 M W P Interruption code

Instruction addressILC CC

Protec-tionkey

Programmask

MPX

1 2 3 4 5 IO6

EXT

BC mode program status word

0 16 31

32 63Figure 17.2

The program status word has three forms. a. Basic control mode.

System mask

1 M W P 0 0 00000000C C

Instruction address

Protec-tionkey

Programmask

0 R 0 0 0 T IO

EXT

EC mode program status word

0 16 31

32 63

0 0 0 0 0 0 0 0

b. Extended control mode.

Page 5: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

347T H E P R O G R A M S T A T U S W O R D

equivalent of the decimal number 1000. The processor looks at the PSW, gets the addressof the next instruction, and fetches it. Thus, the machine-language equivalent of

GO L 3,X

is copied into the instruction register. While the instruction is moving from memory to theprocessor, the instruction control unit has plenty of time to increment the PSW’s instruc-tion address field by 4 (the length of the load instruction). Thus the PSW points to 1004,the address of the next instruction.

The load instruction’s first operand references register 3. The second operand, X, is asymbolic memory address; it will appear as a base register and a displacement. Before theinstruction can be executed, that relative address must be converted to absolute, so, theinstruction control unit adds the base register and the displacement. If PSW bit 12 is 0,the result is the absolute address. If PSW bit 12 is 1, the dynamic address translation fea-ture is activated, and segment and page tables are used to compute an absolute address.

Note carefully the difference between the instruction address in the PSW and theinstruction’s operand addresses. The PSW holds the absolute address of the instruction.The operands, on the other hand, point to the memory locations that are to participate inthe operation. The operand addresses are relative (and, perhaps, virtual), and must betranslated to absolute form before the instruction can be executed.

Once its operand addresses have been translated, the first instruction is executed andthe value stored at location X is copied into register 3. Now, another instruction cyclebegins. As before, the processor:

System mask

1 M W P 1 0 00000000C C

Instruction address

Protec-tionkey

Programmask

0 R 0 0 0 T IO6

EXT

XC mode program status word

0 16 31

32 63

1

c. Extended architecture mode.

Page 6: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

1. finds the instruction address in the PSW,2. fetches the instruction stored at that address,3. increments the instruction address so it points to the “next” instruction,4. translates the instruction’s operands, and5. executes the instruction.

Thus the second load is fetched, the instruction address is incremented to 1008, and thecontents of memory location Y are copied into register 4.

During the next cycle, the instruction stored at location 1008, is fetched, the instruc-tion address is incremented to 1010, and the contents of registers 3 and 4 are added. Notethat the instruction address was incremented by 2 instead of 4 this time. The “AR” instruc-tion is only 2 bytes long.

The PSW points to address 1010. Thus, during the next cycle, the store instruction isfetched and executed, and the instruction address is incremented by 4. Continuing in itssingle-minded way, the processor executes several other instructions until, finally, theinstruction address is 1050. At this point the instruction

B GO

is fetched. It’s an unconditional branch (a GOTO). The single operand, GO, is a relative(base-plus-displacement) address that must be translated to absolute. When the processor

348 Traditional IBM Mainframe Operating Principles

Address Instruction

1000100410081010

110011041108

XYZ

FFF

DSDSDS

1050

GO

GOB

LLARST

3,X4,Y3,43,Z

Balance of program

Several more instructions

Other data storage areas

Figure 17.3

An assembly languageprogram segment.

Page 7: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

executes an unconditional branch, it replaces the contents of the PSW’s instruction addresswith the address specified in the operand—in this case, with 1000. Thus, the next instruc-tion to be fetched is the one labeled GO.

Instruction Length

In the just-completed example (Figure 17.3), most instructions occupied 4 bytes, but one(the AR) needed only 2. Actually, a traditional IBM mainframe computer supports threedifferent instruction lengths (Figure 17.4). Each instruction contains an operation codeand two operands. The key to the instruction’s length is the number of bytes needed to rep-resent operand addresses. The 16 general-purpose registers are numbered 0 through 15, soa register can be uniquely identified by a 4-bit number. Memory addresses are representedas a base register (4 bits) and a 12-bit displacement, yielding a 16-bit or two-byte relativeaddress.

Some instructions involve two registers. Combining a 1-byte operation code with twohalf-byte register numbers yields a two-byte (halfword) instruction. Other instructionsmove data between memory and a register. The 1-byte operation code combined with ahalf-byte register address, a half-byte index register, and a 2-byte memory address, totals 4bytes. Storage-to-storage instructions include an operation code, two memory addresses,and, frequently, a 1-byte length field, for a total of 6 bytes.

How does the processor know the instruction’s length? The operation code of every 2-byte, register-to-register instruction begins with bit values 00. Instructions referencing aregister and a storage location start with 01 or 10. Storage-to-storage instructions all startwith 11. The processor can determine an instruction’s length by checking its operationcode.

Bits 32 and 33 of a BC mode PSW indicate the length of the instruction currentlybeing executed (Figure 17.2); they are set when the instruction address is incremented. Theprogram status word points to the “next” instruction, not the current one. Using theinstruction length code, it is possible to compute the address of the current instructionshould an error occur. The instruction length code does not appear in an EC mode PSW.

349T H E P R O G R A M S T A T U S W O R D

Op code R2R1

Op code DisplacementXR1 B2

Op code Length DisplacementDisplacement B2B1

Register-to-register instructions (2 bytes)

Register-to-storage instructions (4 bytes)

Storage-to-storage instructions (6 bytes)

Figure 17.4

A traditional IBM mainframecan execute 2-, 4-, and 6-byte instructions.

Page 8: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

The Condition Code

The key to decision logic on a traditional IBM mainframe is a 2-bit condition code in theprogram status word (bits 34 and 35 in BC mode; bits 18 and 19 in EC mode; see Figure17.2). Comparison instructions and certain arithmetic instructions set the condition code.When a conditional branch is executed, the processor checks the condition code and, if itsvalue is correct, replaces the PSW’s instruction address with an operand address.

Memory Protection

On a multiprogramming system, it is possible for one program to destroy the contents ofmemory belonging to another. Thus, most systems include a memory protection feature.On a traditional IBM mainframe, each active program is assigned a 4-bit protection key.The operating system uses 0000; the first program in memory gets 0001, and so on; eachprogram has a different key. Memory is allocated in 2048-byte (2K) blocks. A program’sprotection key is associated with each block of memory space assigned to it. Later, duringprogram execution, the protection key is stored in PSW bits 8 through 12 (Figure 17.2,both modes). Access to any 2K block whose protection key does not match the one in thePSW is a protection exception, and can cause program termination.

� Controlling Physical I/O

One of the most important elements of a computer’s architecture is its link to peripheraldevices. External devices are attached to a traditional IBM mainframe through channels. Achannel is a special-purpose computer. Because it has its own, independent processor, itcan function in parallel with the main processor, and thus free the computer to do otherwork.

Like any computer, a channel executes instructions. Its function is to transfer a certainnumber of bytes from a peripheral device into memory (or vice versa). Thus, it must begiven a byte count and a memory address. The channel program and key control data arestored in the computer’s memory and passed to the channel when the I/O operationbegins.

A channel program consists of one or more channel command words (CCWs)(Figure 17.5). Each CCW contains a command code that specifies the operation to be per-formed (read, write, seek), a data address, a byte count, and several flags. Programmers canwrite their own channel programs, but rarely do. Instead, the channel program is typicallypart of an access method.

If the channel program is stored in the computer’s memory, how does the channel findit? Just before the main processor sends the channel a start I/O command, the operatingsystem places the address of the first CCW in the channel address word (CAW) (Figure17.6). The CAW is always found at memory address 72. When the channel’s processorreceives a start I/O command (1), it copies the channel address word (2) into its own

350 Traditional IBM Mainframe Operating Principles

Page 9: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

instruction counter (Figure 17.7). Then the channel fetches and executes (3) its first chan-nel command word (CCW).

The channel passes status information to the computer through the channel statusword or CSW (Figure 17.8) at memory address 64. The CSW contains the channel pro-gram address, a data address, a byte count, and several flags that indicate the I/O opera-tion’s status. The program’s protection key is found in both the channel address word andthe channel status word. Because the key is in the CAW, the channel can recognize pro-tection exceptions. Following completion of the I/O operation, the operating system usesthe protection key in the CSW to identify the program waiting for I/O.

Most channel programs are found in access methods. The linkage editor creates a loadmodule by grafting access methods and other subroutines onto the main object module.The main program requests a logical I/O operation by calling the access method (Figure17.9a). Using parameters passed to it by the calling routine (for example, a data addressand a logical record length), the access method completes the channel program and trans-fers control to the operating system.

The operating system stores the address of the channel program’s first CCW in thechannel address word (memory address 72), and executes a start I/O instruction (Figure17.9b). The channel responds by copying the channel address word and then fetching thefirst CCW (Figure 17.9c). At this point, the channel has assumed full responsibility for theI/O operation, and the main computer can process instructions in some other program.

351C O N T R O L L I N G P H Y S I C A L I / O

Command code Data address Flags Byte count

Figure 17.5

The format of a channel command word (CCW).

Key CCW address0000

Memory protection key (4 bits)

Address of first CCW in the channel program (24 bits)

Figure 17.6

The format of the channel address word (CAW).

Page 10: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

The channel and the computer are asynchronous; in other words, they function inde-pendently. Consequently, the main processor has no way of knowing when the channel hascompleted its work unless the channel tells it. Thus, when the I/O operation is finished,the channel signals the main processor and reports its status to the operating systemthrough the channel status word (Figure 17.9d). Assuming the CSW indicates successfulcompletion, the operating system can return control to the application program (Figure17.9e).

352 Traditional IBM Mainframe Operating Principles

Main processor

CAW

CCW1CCW2CCW3

Mainmemory

1. SIO

2.

3.

Channel's processor

Instructioncounter

Instructionregister

Figure 17.7

Following an SIO command from the main processor, the channel’s processor looks tothe channel address word to find the first channel command word.

Key Command address Status Byte count

Figure 17.8

The format of the channel status word (CSW).

Page 11: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

Channel

Applicationprogram partition

Primary objectmodule

Operating systemroutine

CSW

CAW

Access method

CCW

Figure 17.9

Controlling I/O on a traditional IBM mainframe. a. The application program calls theaccess method, which completes the channel program and transfers control to theoperating system.

Channel

Applicationprogram partition

Primary objectmodule

Operating systemroutine

CSW

CAW

SIO

Access method

CCW

b. The operating system stores the address of the channel program in the channeladdress word and executes a start I/O (SIO) instruction.

Page 12: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

Privileged Instructions

On a computer running multiple concurrent programs, it is essential that all input andoutput operations be funneled through a single operating-system module. To preventcheating, the instructions that communicate directly with a channel are privileged; in otherwords, they can be executed only by an operating-system routine. The operating system,remember, is assigned protection key 0000. Before executing a privileged instruction, theprocessor checks the protection key in the PSW. If it’s not 0000, a privileged instructionexception is recognized, and the application program is usually terminated. Consequently,to start an I/O operation the programmer must first transfer control to an operating-sys-tem module.

� Interrupts

Because the operating system and an application program have different protection keys,it is illegal to branch to or call an operating-system module. The only way for an applica-tion program to transfer control to the operating system is by issuing an interrupt. Ofcourse, application programs are not the only source of interrupts; they can originate inhardware or software.

A traditional IBM mainframe responds to an interrupt signal by switching PSW’s.Three fields are involved: the current PSW, an old PSW, and a new PSW. The current

354 Traditional IBM Mainframe Operating Principles

Channel

Applicationprogram partition

Primary objectmodule

Operating systemroutine

CSW

CAW

Access method

CCW

c. The channel copies the contents of the channel address word and then fetches thefirst channel command word.

Page 13: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

Channel

Applicationprogram partition

Primary objectmodule

Operating systemroutine

CSW

CAW

Access method

CCW

e. After checking the channel status word, the operating system returns control tothe application program.

Channel

Applicationprogram partition

Primary objectmodule

Operating systemroutine

CSW

CAW

Access method

CCW

d. When the I/O operation is complete, the channel signals the main processor.

Page 14: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

PSW is the special register that holds the address of the next instruction. The old PSW islocated in memory. The new PSW (also found in memory) holds the address of an inter-rupt handling routine in the operating system.

When an interrupt occurs, hardware stores the current program status word in the oldPSW field and then loads the new PSW into the current PSW register (Figure 17.10). Asthe processor begins its next cycle, it fetches the instruction whose address is in the pro-gram status word. Because of the interrupt, the current PSW points to the operating sys-tem’s interrupt handling routine. Note that the old PSW holds the address of the nextinstruction in the original application program. Thus, after the interrupt has beenprocessed, the application program can be resumed.

Sometimes an example helps. Imagine a program loaded at memory location 50,000.The operating system’s interrupt handling routine starts at address 1000. The new PSWhas protection key 0000 and points to instruction address 1000 (Figure 17.11a). The con-tents of the old PSW are unknown. The current PSW points to memory location 50500(an address in the application program). The program’s protection key is 0010.

When an interrupt occurs, hardware stores the current PSW in the old PSW (Figure17.11b). A fraction of a nanosecond later, the new PSW is copied into the current PSW(Figure 17.11c). This completes the interrupt.

Interrupt processing begins with the next machine cycle. The address in the currentPSW is 1000. Thus, the processor fetches the first instruction in the interrupt handlingroutine (Figure 17.11d). Since the protection key is 0000, privileged instructions are legal.Eventually, the old PSW is loaded back into the current PSW and the application programresumes processing (Figure 17.11e).

356 Traditional IBM Mainframe Operating Principles

Current program status word

Old program status word field

New program status word field

1

2

Figure 17.10

A traditional IBM mainframeresponds to an interrupt bystoring the current PSW inthe old PSW field and thenloading the new PSW intothe current PSW register.

Page 15: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

357I N T E R R U P T S

Current PSW

Old PSW

New PSW

0010

0000 1000

50500

?

Applicationprogram

Operating systemroutine

Figure 17.11

An example of PSW switching. a. The current PSW points to an instruction in theapplication program.

Current PSW

Old PSW

New PSW

0010

0000 1000

50500

0010 50500

Applicationprogram

Operating systemroutine

b. When an interrupt occurs, the current PSW is stored in the old PSW field.

Page 16: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

Interrupt Types

Traditional IBM mainframes recognize six different interrupt types. Sources include appli-cation programs, peripheral devices, the operator’s console, the computer’s self-checkingerror circuitry, and other processors.

358 Traditional IBM Mainframe Operating Principles

Current PSW

Old PSW

New PSW

0000

0000 1000

1000

0010 50500

Applicationprogram

Operating systemroutine

c. Then the new PSW is loaded into the current PSW register.

Current PSW

Old PSW

New PSW

0000

0000 1000

1000

0010 50500

Applicationprogram

Operating systemroutine

d. Because the current PSW now points to an operating system routine, the firstinstruction in the interrupt handler is fetched.

Page 17: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

External interrupts come from the operator’s console, another processor, or thetimer. When an external interrupt is sensed, hardware stores the current program statusword at memory address 24 (the old external PSW), and then loads the contents of thedoubleword beginning at address 88 (the new external PSW) into the current PSW regis-ter (Figure 17.12). If the interrupt arrives while the processor is executing an instruction,it is ignored until the instruction is completed; in other words, external interrupts are rec-ognized between instructions.

In BC mode, PSW bits 16 through 31 contain an interruption code (Figure 17.2).By checking these 16 bits, the external interrupt handler routine can determine the exactcause of the interrupt. Under EC mode, the interruption code is stored in a special regis-ter.

A supervisor call (SVC) interrupt starts when a program executes an SVC instruc-tion, such as

SVC 17

The operand requests a particular supervisor module. In response to an SVC instruction,the processor generates an interrupt. Hardware reacts by storing the current program sta-tus word at memory address 32 (the old SVC PSW), loading the doubleword beginning ataddress 96 (the new SVC PSW) into the current PSW, and copying the operand field (the17 in the instruction illustrated above) into the interruption code (Figure 17.13).

An SVC interrupt is generated by a valid instruction. A program interrupt resultsfrom an illegal or invalid instruction. The processor recognizes the error as it occurs andgenerates the interrupt. In response, hardware stores the current PSW into the old program

359I N T E R R U P T S

50500Current PSW

Old PSW

New PSW

0010

0000 1000

0010 50500

Applicationprogram

Operating systemroutine

e. Eventually, the old PSW’s contents are loaded back into the current PSW and theapplication program resumes processing.

Page 18: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

PSW field (address 40), loads the new program PSW (address 104) into the current PSW,and stores the interruption code (Figure 17.14).

360 Traditional IBM Mainframe Operating Principles

Current PSW

88 New external

24 Old externalExternal interrupt

handler

1

2

Figure 17.12

An external interrupt.

Current PSW

96 New SVC PSW

32 Old SVC PSW

SVC interrupthandler

1

2

Figure 17.13

An SVC interrupt.

Page 19: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

A machine check interrupt occurs when the computer’s self-checking circuitrydetects a hardware failure. If an instruction is executing, it is terminated—no sense per-forming computations or logical operations on a computer known to be malfunctioning.Hardware responds to a machine check interrupt by storing the current PSW in the oldmachine check PSW (address 48), loading the new machine check PSW (address 112) intothe current PSW, and dumping the contents of key control fields into the next few hun-dred bytes of memory (Figure 17.15).

Because the channels and the main processor work independently, the channel mustsignal the processor when an I/O operation is completed by sending it an input/output(I/O) interrupt (Figure 17.16). Hardware responds by storing the current PSW in the oldI/O PSW (address 56), loading the new I/O PSW (address 120) into the current PSW, andstoring the channel/ device address of the unit causing the interrupt in the interruptioncode. If the processor is executing an instruction when an I/O interrupt occurs, theinstruction is completed before the interrupt is recognized.

A restart interrupt allows an operator or another processor to start a program. Thisinterrupt type was not available on the original IBM System/360 computers; it was addedafter the basic architecture was established. The new restart PSW is found at memory loca-tion 0; the old restart PSW is at memory location 8.

Permanent Storage Assignments

The old and new PSWs, the channel status word, and the channel address word are storedin fixed memory locations (Figure 17.17); in other words, these key fields are found at the

361I N T E R R U P T S

Current PSW

104 New program

40 Old programProgram interrupt

handler

1

2

Figure 17.14

A program interrupt.

Page 20: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

same addresses on every traditional IBM mainframe. They, along with the computer’s con-trol registers, represent the primary interface between hardware and software.

362 Traditional IBM Mainframe Operating Principles

Current PSW

112 New machine check

48 Old machine check

Machine checkinterrupt handler

1

2

Figure 17.15

A machine check interrupt.

Current PSW

120 New I/O PSW

56 Old I/O PSW I/O interrupthandler

1

2

Figure 17.16

An I/O interrupt.

Page 21: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

Masking Interrupts

A typical mainframe computer supports several channels. The channels operate independ-ently, so it is possible that two or more I/O interrupts might be generated by differentchannels in a very brief time span, perhaps even simultaneously. Consider what might hap-pen if two I/O interrupts were to occur within a few nanoseconds.

An application program is executing. In response to the first I/O interrupt, hardwarecopies the current program status word to the old I/O PSW and loads the new I/O PSWinto the current PSW (Figure 17.18a). Within a single machine cycle, a second interruptarrives. Clearly, the first interrupt is still being processed, but that makes no difference tohardware, which, in its automatic way, drops the current PSW into the old I/O PSW andloads the new I/O PSW (Figure 17.18b). As a result, the link back to the application pro-gram is destroyed. Consequently, the operating system will be unable to restart the appli-cation program, and that is unacceptable.

The solution is masking interrupts. The first eight bits of the BC mode program sta-tus word hold a system mask (Figure 17.19a). The first bit is associated with channel 0. Ifit’s 1, the processor can accept an interrupt from the channel; if it’s 0, the interrupt isignored. (The channel will continue to send the interrupt signal, again and again, until the

363I N T E R R U P T S

AddressDecimal Hexadecimal Length Purpose

08

16243240485664727680848896

104112120

08

10182028303840484C50545860687078

DoublewordDoublewordDoublewordDoublewordDoublewordDoublewordDoublewordDoublewordDoublewordWordWordWordWordDoublewordDoublewordDoublewordDoublewordDoubleword

Restart new PSWRestart old PSWUnusedExternal old PSW Supervisor call old PSWProgram old PSWMachine check old PSWInput/output old PSWChannel status wordChannel address wordUnusedTimerUnusedExternal new PSWSupervisor call new PSWProgram new PSWMachine check new PSWInput/output new PSW

Figure 17.17

Fixed locations in memory.

Page 22: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

Current PSW

Old I/O PSW

New I/O PSW

I/O interrupthandler routine

Program A

Figure 17.18

Two or more interrupts occurring in a brief time span can destroy the trail back to theoriginal program. a. In response to the first interrupt, the link back to the applicationprogram is stored in the old PSW.

Current PSW

Old I/O PSW

New I/O PSW

I/O interrupthandler routine

Program A

b. The second interrupt overlays the link and thus destroys it.

Page 23: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

processor acknowledges it.) Bits 1 through 5 control channels 1 through 5; again, a 1 bitpermits an interrupt from the associated channel, and a 0 bit means the processor willignore interrupts from that channel. Bit 6 controls channels 6 through 255. In an ECmode PSW (Figure 17.19b), a single bit (bit 6) serves to mask I/O interrupts from allchannels.

Normally, the system mask or the I/O interrupt bit is set to 1, so I/O interrupts canbe accepted. In the new I/O PSW, however, these key mask bits are set to 0 (Figure 17.20).Thus, once an I/O interrupt is accepted, subsequent I/O interrupts are ignored until theoperating system changes the PSW.

Bit 7 masks external interrupts in all three PSW modes. Like I/O interrupts, externalinterrupts are generated asynchronously and thus can occur, unexpectedly, at any time.Picture an I/O interrupt, followed closely by an external interrupt, followed closely byanother I/O interrupt. That sequence could destroy the original program’s PSW in the oldI/O PSW field. The same thing could happen with an external, I/O, external sequence.Thus, both I/O and external interrupts are masked when either type is processed.

365I N T E R R U P T S

System mask

0 M W P Interruption code

Instruction addressILC CC

Protec-tionkey

Programmask

MPX

1 2 3 4 5 IO6

EXT

BC mode program status word

Program (1) or supervisor (0) state

Wait (1) or ready (0) state

Machine check mask (1 means interrupt permitted)

Fixed point overflow

Decimal overflow

Exponent underflowSignificance

0 16 31

32 37 40 63

Figure 17.19

Several program status word bits are used to mask interrupts. a. Basic control mode.

Page 24: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

Machine checks can be masked by turning off PSW bit 13 (all modes). Once a hard-ware failure is detected, the error checking circuitry sends an interrupt signal, and contin-ues to send signals until the problem is fixed or the machine is shut down. Thus, if machinecheck interrupts were not masked, hardware, responding to an unending series of interrupt

366 Traditional IBM Mainframe Operating Principles

System mask

1 M W P 0 0 00000000C C

Instruction address

Protec-tionkey

Programmask

0 R 0 0 0 T IO

EXT

EC mode program status word

0 16 31

0 0 0 0 0 0 0 0

Program event recording mask (1 permits program event interrupts)Dynamic address translation (1 means DAT enabled)

I/O interrupt mask (1 means interrupt permitted)External interrupt mask (1 means interrupt permitted)

Machine check mask (1 means interrupt permitted)Wait (1) or ready (0) state

Program (1) or supervisor (0) state

b. Extended control mode. The first 32 bits of an extended-architecture (XA) mode PSW areidentical.

New I/OPSW

Mask0000 0000

Key0000

I/O interrupthandler address

Figure 17.20

In the new I/O PSW, the I/O interrupt mask bits are set to 0. Consequently, when thenew PSW is loaded, all subsequent I/O interrupts are masked while the first one isprocessed.

Page 25: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

signals, would simply load the new machine check PSW over and over again and the sys-tem would be unable to respond to the interrupt.

Closely spaced SVC and program interrupts are not a problem. Both are generated byprogram instructions, and, since the processor can execute only one instruction at a time,simultaneous SVC and program interrupts are impossible. An SVC transfers control to theoperating system, which has no need to issue a subsequent SVC. (Why call the supervisorwhen you’re already there?) A program interrupt also transfers control to the operating sys-tem, which is assumed to be bug free. (In fact, operating-system bugs often lead to a sys-tem crash.)

Following a program interrupt, normal system action is to terminate the offending pro-gram and generate a dump. At times, a programmer may choose to override the standardprocedure, trapping and handling such potential problems as overflows or underflows in aprogram subroutine. Bits 36 through 39 (BC mode) or bits 20 through 23 (EC and XAmodes) allow the programmer to suppress fixed-point overflows, decimal overflows, expo-nent underflows, and significance exceptions.

Interrupt Priority

“If it can possibly happen, it will.” Engineers and programmers recognize the essentialtruth behind that old cliché. Given time, it is almost inevitable that every possible type ofinterrupt will hit the processor at the same instant. Which one goes first? A well-designedsystem anticipates such problems and has procedures for dealing with them.

On a traditional IBM mainframe, machine checks are serviced first—no sense tryingto do anything else on a malfunctioning machine. Once the machine check is out of theway, here’s what happens (Figure 17.21):

1. The program (or SVC) interrupt is accepted, dropping the application program’sPSW into the old program PSW.

2. The external interrupt is accepted, dropping the current PSW (which by now pointsto the program interrupt handling routine) into the old external PSW.

3. The I/O interrupt is accepted, dropping the external interrupt’s program status wordinto the old I/O PSW.

Note that the current PSW points to the I/O interrupt handler. Additional I/O or exter-nal interrupts will be ignored because they are masked. Additional SVC or program inter-rupts can’t possibly happen until another instruction is executed. Thus, the I/O interrupthandler begins processing. When it finishes, the old I/O PSW is made current and theexternal interrupt handler takes over. Finally, the program interrupt handler gets control.

� Program States

The computer, at any given time, is executing either an application program or a supervi-sor routine; in other words, it is either in the problem state or the supervisory state. PSW

367I N T E R R U P T S

Page 26: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

bit 15 (all modes) (Figure 17.19) indicates the computer’s state—1 means problem and 0means supervisory. Privileged instructions can be executed only in supervisory state.Protection exceptions are ignored when the system is in supervisory state.

Additionally, a given program is either ready to resume processing or waiting for thecompletion of some event such as an I/O operation; in other words, it’s either in a readystate or a wait state. A 0 in PSW bit 14 means ready; a 1 means wait. As you’ll see in sub-sequent chapters, this bit is crucial on a multiprogramming system.

Three other EC and XA mode bits deserve mention. Bit 1 is associated with programevent recording (a facility we won’t cover in detail). Bit 5 controls dynamic address trans-lation. If it’s set to 0, addresses are not dynamically translated (which makes sense for oper-ating-system routines in the virtual-equals-real area). If bit 5 is set to 1, addresses aredynamically translated through the segment and page tables. Finally, bit 16 affects dynamicaddress translation. It must be set to 0 in EC mode and to 1 in XA mode.

368 Traditional IBM Mainframe Operating Principles

New external

2

New mach-check

New program

New SVC

New external

Program A

New external

1

New I/O

New mach-check

New program

New SVC

New external

Program A

New program

New I/O

New mach-check

New program

New SVC

New external

Program A

New external

New program

New I/O

New I/O

3

0

8

16

24

32

40

48

56

64

72

80

88

96

104

112

120

Figure 17.21

When simultaneous interrupts occur, hardware accepts the program (or SVC) interrupt first, thenthe external interrupt, and finally the I/O interrupt. They are processed in reverse order.

Page 27: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

� An Example

Perhaps the best way to pull together all these concepts is through an example. Start witha single program in memory (Figure 17.22a). The program needs data and thus executesan SVC. The result is an SVC interrupt (Figure 17.22b), which transfers control to theSVC interrupt handler (Figure 17.22c). Note that the old SVC PSW points to the appli-cation program.

The SVC interrupt handler starts the physical I/O operation (Figure 17.22d) by:

1. storing the address of the first channel command word in the channel address word,and

2. executing a start I/O instruction, which signals the channel.

Before returning control to the initial program, the operating system repeatedly checks thechannel status word (CSW) until the channel reports either a successful or unsuccessfulstart (Figure 17.22e). Assuming success, the channel is now responsible for the I/O oper-ation so the interrupt handler places the application program in a wait state by turning onbit 14.

Next, the operating system tries to start another program. Since there is only oneapplication program in memory, its old PSW is loaded (Figure 17.22f ). Because PSW bit14 is set to 1, the computer is in a wait state, so the processor does nothing for a while.

Eventually, the channel completes the input operation and sends an I/O interrupt tothe processor. Consequently, the current PSW is copied to the old I/O PSW and the newI/O PSW is loaded (Figure 15.22g). The current PSW’s bit 14 is now 0, so the processorcan execute instructions. The first instruction in the I/O interrupt handler routine isfetched. The channel status word is checked, and the application program’s PSW is set toa ready state. Eventually (Figure 17.22h), the application program resumes processing.

With multiprogramming, of course, the problem is a bit more complex. If a programdrops into a wait state, the operating system will attempt to start a different one, and thenew program is likely to generate its own interrupts. Because there is only one old PSWfor each interrupt type, the original program’s PSW must be saved if a return trail is to bepreserved. We’ll consider this problem in the next two chapters.

Summary

Traditional IBM mainframes are byte addressed. The bytes are grouped to form halfwords,fullwords, and doublewords. Memory addresses appearing in instruction operands areexpressed in relative, base-plus-displacement form, and must be translated to absolute formbefore the instruction can be executed.

A traditional IBM mainframe’s instruction counter is called the program status word.It holds the address of the next instruction to be executed. Three forms, the basic control(BC) mode, the extended control (EC) mode, and the extended architecture (XA) mode,

369A N E X A M P L E

Page 28: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

Channel

PSW

Old SVC PSW

New SVC PSW

Old I/O PSW

New I/O PSW

CSW

CAW

Applicationprogram

SVC interrupthandler

I/O interrupthandler

CCWs

Figure 17.22

An example. a. Memory holds a single application program.

Channel

PSW

Old SVC PSW

New SVC PSW

Old I/O PSW

New I/O PSW

CSW

CAW

Applicationprogram

SVC interrupthandler

I/O interrupthandler

CCWs

b. The program issues an SVC.

Page 29: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

Channel

PSW

Old SVC PSW

New SVC PSW

Old I/O PSW

New I/O PSW

CSW

CAW

Applicationprogram

SVC interrupthandler(SIO)

I/O interrupthandler

CCWs

Toprocessor

d. The interrupt handler starts the physical I/O operation by storing the channelprogram address in the channel status word and executing a start I/O instruction.

Channel

PSW

Old SVC PSW

New SVC PSW

Old I/O PSW

New I/O PSW

CSW

CAW

Applicationprogram

SVC interrupthandler

I/O interrupthandler

CCWs

c. The SVC interrupt handler begins executing.

Page 30: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

SVC interrupthandler(SIO)

Channel

PSW

Old SVC PSW

New SVC PSW

Old I/O PSW

New I/O PSW

CSW

CAW

Applicationprogram

I/O interrupthandler

CCWs

e. The SVC interrupt handler then checks the channel status word until the channelreports the I/O operation’s status.

PSW - Wait state

SVC interrupthandler(SIO)

Channel Old SVC PSW

New SVC PSW

Old I/O PSW

New I/O PSW

CSW

CAW

Applicationprogram

I/O interrupthandler

CCWs

f. The application program’s PSW is loaded from the old SVC PSW. Because theapplication program is in a wait state, the processor is in a wait state.

Page 31: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

SVC interrupthandler(SIO)

PSW - Run state

Channel Old SVC PSW

New SVC PSW

Old I/O PSW

New I/O PSW

CSW

CAW

Applicationprogram

I/O interrupthandler

CCWs

h. Eventually, the application program resumes processing.

To processor

Channel

PSW

Old SVC PSW

New SVC PSW

Old I/O PSW

New I/O PSW

CSW

CAW

Applicationprogram

SVC interrupthandler(SIO)

I/O interrupthandler

CCWs

g. Following an I/O interrupt (from the channel), the I/O interrupt handler getscontrol.

Page 32: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

are used. The instruction length code (BC mode only), condition code, and protection keyare all found in the PSW.

An application program starts an I/O operation by calling an access method. Theaccess method completes a channel program (one or more channel command words) andtransfers control to the operating system. The operating system, in turn, stores the addressof the first CCW in the channel address word (CAW) and issues a privileged start I/Oinstruction. When the I/O operation is completed, the channel notifies the processor bysending an interrupt and reporting its status through the channel status word (CSW).

A traditional IBM mainframe responds to an interrupt by storing the current PSW inthe old PSW field, and loading the new PSW into the current PSW. Six types of interruptsare supported: external, I/O, program, SVC, machine check, and restart. Each type has itsown old and new PSW fields. To avoid losing the trail back to the original program, I/Oand external interrupts are masked. Machine check interrupts and selected program inter-rupts can be masked, too. Given simultaneous interrupts, the program (or SVC) interruptis accepted first, then the external interrupt, and, finally, the I/O interrupt. They areprocessed in reverse order.

Other PSW bits identify a program’s state, activate the dynamic address translationfeature, and control program event recording.

The chapter ended with an example. If you haven’t already done so, take the time toread and understand that example.

374 Traditional IBM Mainframe Operating Principles

Page 33: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

� Key Words

� Exercises

1. A traditional IBM mainframe is a byte-addressed machine. Explain.

2. Distinguish between an absolute address and a relative address. Briefly explain the structure ofboth address types on a traditional IBM mainframe.

3. Explain how the PSW determines the order in which instructions are executed.

4. Distinguish between the BC mode, the EC mode, and the XA mode PSWs. When is eachused? How do the PSWs differ?

5. How can a traditional IBM mainframe determine the length of its instructions? Whatdistinguishes 2-byte, 4-byte, and 6-byte instructions?

6. Explain how I/O is controlled on a traditional IBM mainframe. What functions areperformed by the access method, the channel program, the channel command word, thechannel address word, the operating system, and the channel status word.

7. What is a privileged instruction? Why are such instructions important?

8. What is an interrupt? How is the interrupt concept implemented on a traditional IBMmainframe?

9. Name the types of interrupts recognized on a traditional IBM mainframe. Describe thesource of each.

10. What are permanent storage assignments? Why are they necessary on a traditional IBMmainframe?

11. Why must certain types of interrupts be masked at certain times? How are they masked?

12. Explain a traditional IBM mainframe’s interrupt priority.

375E X E R C I S E S

Page 34: Traditional IBM Mainframe Operating Principleswps.aw.com/wps/media/objects/1512/1548870/Davis_CH17.pdf · 344 Traditional IBM Mainframe Operating Principles The Hardware Environment

13. Assume a traditional IBM mainframe is running under basic control mode. The contents ofcertain fixed locations in memory are

Address Contents in Hexadecimal0 FF04 0000 0001 C0008 0000 0000 0000 072016 0000 0000 0000 000024 0055 0082 C002 640032 FF55 0008 C003 142440 FF55 000B C003 F34048 0055 0000 C004 A00056 0055 0003 C004 22FA64 0000 0000 0000 000072 0000 0000 0000 000080 0000 0000 0000 000088 0004 0000 0001 A00096 FF04 0000 0001 7000104 FF04 0000 0001 3000112 0000 0000 0001 1000120 0004 0000 0001 5000

The current PSW holds:

FF04 000B 0001 3000

Sketch a map of memory showing the location of each interrupt handling routine. What kind ofinterrupt has just happened? What is the address of the “bad” instruction? Can an I/O interrupt hap-pen now? How do you know? Can a privileged instruction be executed? How can you tell the com-puter is in basic control (BC) mode?

376 Traditional IBM Mainframe Operating Principles