Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method...

28
Explanation Interrupts System Interconnections

description

Short I/O – the I/O operation is completed within the time it takes to execute instructions in the program that occur before the next I/O command. The processor is kept busy the whole time. Long I/O - The ‘next’ I/O command comes before first I/O has completed. Processor still needs to wait. Some time is saved ! Benefits of Interrupts

Transcript of Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method...

Page 1: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Explanation

InterruptsSystem Interconnections

Page 2: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

InterruptsA computer system must provide a method for allowing mechanisms to interrupt the normal processing.Interrupts improve processor efficiencyMost external devices are much slower than the processor and ‘busy waiting’ takes up too many resources.Examples:

External interrupts:Timing device, Circuit monitoring the power supply, I/O device requesting data or completed data transfer etc. Timeout errors.

Internal interrupts (caused by an exception condition). Illegal use of an instruction or data (traps)example: register overflow, attempt to divide by zero, invalid op code, stack overflow etcTimer: OS system can perform operations on a regular basis.

Software Interrupts – Special call instruction that behaves like an interrupt.

Page 3: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

WRITE

1

WRITE

WRITE

I/O Command

4

END

5

WRITE

1

WRITE

WRITE

I/O Command

4

END

Interrupt Handler2

33a

2a

2b5

3b

1 4 5 2 4 5 3

1 4 5 2b 42a 5 3b3a

1 4 5 42 53

No Interrupts

Interrupts -Short I/O wait.

Interrupts -Long I/O wait. (More realistic!)

No Interrupts Interrupts -Short I/O wait.

Short I/O – the I/O operation is completed within the time it takes to execute instructions in the program that occur before the next I/O command. The processor is kept busy the whole time.

Long I/O - The ‘next’ I/O command comes before first I/O has completed. Processor still needs to wait. Some time is saved !

Benefits of Interrupts

Page 4: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

An exampleBusy Wait:

Consider a computer that can execute two instructions that read the status register and check the flag in 1 µs.

Input device transfers data at an average rate of 100 bytes per second – equivalent to one byte every 10,000 µs.

The CPU will check the flag 10,000 times between each transfer.

Interrupt Driven:

CPU could use this time to perform other useful processing.

Page 5: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Interrupt CycleThe interrupt cycle is added to the instruction cycle.Processor checks for interrupt indicated by an interrupt flag.If there is NO interrupt Fetch next instructionIf there is an interrupt:

Suspend operation of the programSave its contextSet PC to start address of the interrupt handlerProcess the interruptRestore the context of the original program and continue its execution.

Page 6: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Instruction Cycle with Interrupts

Following each execute cycle:Check for interruptsHandle active interrupts

Page 7: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Instruction Cycle with InterruptsDisable interrupts

Processor will ignore further interrupts whilst processing one interruptInterrupts remain pending and are checked after first interrupt has been processedInterrupts handled in sequence as they occur

Define prioritiesLow priority interrupts can be interrupted by higher priority interruptsWhen higher priority interrupt has been processed, processor returns to previous interrupt

Page 8: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Handling Multiple Interrupts

Sequential approach – once an interrupt handler has been started it runs to completion(+) Simpler(-) Does not handle priority interrupts well

Example: Incoming data might be lost.

Nested approach – a higher priority device can interrupt a lower priority one.(+) More complex(-) Interrupts get handled in

order of priority.

Page 9: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Priority InterruptsPolling• One common branch address for all interrupts. • Interrupt sources polled in priority sequence. • If an interrupt signal is ‘on’, control branches to a service routine for

this source.• (-) Time overhead to handle many interrupts can be excessive.• The operation can be sped up with a hardware priority-interrupt unit.

Daisy-Chain Priority• Hardware solution• Serial connection of all devices that request interrupts.• Device with the highest priority takes first position, 2nd highest takes

2nd position etc.• Interrupt request line shared by all devices.

Page 10: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Daisy-chain Priority InterruptA Serial Approach

CPU

Device 1 Device 2 Device 3PI P0 PI PIP0 P0

INT

INTACK

Interrupt Request

Interrupt Acknowledge

Processor data busVAD 1 VAD 2 VAD 3

Page 11: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

One stage of the daisy-chain Priority Arrangement

PI RF PO Enable

0 0 0 00 1 0 01 0 1 01 1 0 1

S

R

Q

Vector Address

Delay

.

. .Priority InPI

Interrupt request from device

Open-collector inverter

Interrupt request to CPU

Priority OutPORF

From: Computer System Architecture, Morris Mano

Page 12: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Parallel Priority InterruptUses a register – whose bits are set separately by the interrupt signal from each device.Priority established according to the position of bits in the interrupt register.A mask register is used to control the status of each interrupt request. Mask bits set programmatically.Priority encoder generates low order bits of the VAD, which is transferred to the CPU.Encoder sets an interrupt status flip-flop IST whenever a non-masked interrupt occurs.Interrupt enable flip-flop provides overall control over the interrupt system.

Page 13: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Parallel Priority Interrupt Hardware

0

1

2

3

I0

I1

I2

I3

Prio

rity

Enco

der0

1

2

3

yx000000ISTIEN

Disk

Printer

Reader

Keyboard

Enable

Interrupt to CPU

INTACK from CPU

Interrupt Register

MaskRegisterFr

om:

Com

pute

r Sys

tem

Arc

hite

ctur

e, M

orris

Man

o

Page 14: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Priority EncoderCircuit that implements the priority function.Logic – if two or more inputs arrive at the same time, the input having the highest priority will take precedence.

Boolean functions X = I’0I’1 Y = I’0I1 + I’0I’2 IST = I0 + I1 + I2 + I3

Inputs OutputsI0 I1 I2 I3 d Y IST

1 d d d 0 0 10 1 d d 0 1 10 0 1 d 1 0 10 0 0 1 1 1 10 0 0 0 d d 0

Page 15: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Interrupt CycleThe Interrupt enable flip-flop (IEN) can be set or cleared by program instructions.A programmer can therefore allow interrupts (clear IEN) or disallow interrupts (set IEN)At the end of each instruction cycle the CPU checks IEN and IST. If either is equal to zero, control continues with the next instruction. If both = 1, the interrupt is handled.Interrupt micro-operations:SPSP – 1 (Decrement stack pointer)M[SP] PCc Push PC onto stackINTACK 1 Enable interrupt acknowledgePC VAD Transfer vector address to PCIEN 0 Disable further interruptsGo to fetch next instruction

Page 16: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Software Routines for handling InterruptsSoftware routines used to service interrupt requests and control interrupt hardware registers.Each device has its own service program reached through a jump instruction stored at the assigned vector address.Example: Keyboard sets interrupt bit whilst CPU is executing instruction at location 749.At the end of the instruction, 750 is pushed onto the stack, the VAD for the keyboard is taken off the bus and placed into the PC.Control is passed to the keyboard routine.Once completed, PC is replaced with original address of next instruction (750)

JMP DISK

JMP PRINTER

JMP READER

JMP KEYBOARD

Main program

Stack

Program to service magnetic disk.

Program to service line printer.

Program to service character reader.

Program to service Keyboard.

Page 17: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Interconnection StructuresMemory: Outputs data. Inputs read, write, and timing signals, addresses, and data.

I/O Module. Outputs data & interrupt signals. Inputs control signals, data, and addresses.

CPU: Outputs address, control signals, and data. Inputs instructions data, and interrupt signals.

Page 18: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Bus InterconnectionCommunication pathway connecting two or more devices.Shared transmission medium - usually broadcast.Typically 50 – 100s of separate lines divided into three functional groups:

Data lines• At this level ‘data’ and ‘instruction’ are synonymous.• Width is a key determinant of performance.

(Example: 32 bit words, data bus 16 bits 2 cycles to transmit one word).

Address lines• Identify source or destination of data (ie address in memory)• Width determines maximum memory capacity of system (ie 8080 has

16 bit address 64K address space). Control linesControl lines

• Control and timing signals (read, write, ack, clock)

Page 19: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Bus Interconnection

– Parallel lines on circuit boards– Ribbon cables– Strip connectors on mother boards– Sets of wires

Page 20: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Single Bus ProblemsLots of devices on one bus leads to:

Propagation delaysLong data paths mean that co-ordination of bus use can adversely affect performanceIf aggregate data transfer approaches bus capacity

Most modern systems have at least 4 busses to solve this problem:

Processor bus Cache busDedicated bus for accessing system cache.Local I/O busHigh speed I/O bus for connecting performance critical peripherals such as high-speed networks, disk storage devices.Standard I/O bus Connects slower peripherals such as mouse & modems etc.

Page 21: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Traditional ISA (with Cache)

Page 22: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

High Performance Architecture

Page 23: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Elements of Bus DesignType

Dedicated vs. MultiplexedDedicated by functionality ie address vs. data or dedication to a physical subset of components.

Arbitration MethodOnly one module can have control of the bus at any one time.Centralized vs. Distributed

TimingSynchronous vs. Asynchronous

Bus WidthAddressData

Data Transfer TypeRead, Write, Read-modify-write, Read-after-write, Block

Page 24: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Bus ArbitrationHardware arbitration

Serial arbitration – daisy chainParallel arbitration

Dynamic arbitration algorithmsSystem can change the priority of the devices during normal operation.

Time slice – fixed length time slice of bus time offered sequentially to each processor in round robin fashion.Polling – address of each device in turn placed on polling lines. A device may activate bus busy if it is being polled.LRU – Least recently used.FIFO – First in first out.Rotating Daisy-chain – dynamic extension of the daisy chain.

Bus arbiter 1

Bus arbiter 2

Bus arbiter 3

Bus arbiter 4

Priority Encoder

2 X 4 Decoder

Hardware for parallel arbitrationBu

s Rea

dy

Page 25: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Synchronous TimingOccurrence of events on the bus coordinated by a clock.Bus includes a clock line.Clock transmits alternating 1s and 0s of equal duration.A single 1-0 transmission = 1 clock cycle.All events start at the beginning of a clock cycle.

Page 26: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Timing of Synchronous Bus Operations

Stable Address

Place stable address on the line during first clock signal.Once the address stabilizes an address enable signal is issued.Read: Read enable signal activated at start of next cycle.Memory module recognizes address and after 1 cycle places data on bus.Write is similar but address + data is placed on the bus early.

Valid Data In

Valid Data Out

Page 27: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Timing of Asynchronous Bus Operations

Occurrence of one event follows the occurrence of a previous event.For read – place status and address on the line.Once stabilized, place a read signal on the bus.Memory decodes address, and places data on the bus.Processor sends and “ACK” – all lines can then be dropped.

Page 28: Explanation Interrupts System Interconnections. Interrupts A computer system must provide a method for allowing mechanisms to interrupt the normal processing.

Data Transfer Type

Bus supports various data transfer typesWrite (Master to slave)Read (Slave to master)

Multiplexed address/data bus Write (Cycle 1 : Address, Cycle 2 : Data)Read (Cycle 1 : Address, Delay, Cycle ?: Data)

Non-multiplexed address/data busWrite (Address & Data both sent in same cycle).Read (Address followed by data once address is stabilized)

Other types of transfer include:Read after writeBlock data transfer (Address + multiple blocks of data)