Professional Documents
Culture Documents
Introduction
CPU
SYSTEM BUS
I/O
I/O DEV
I/O
DEV DEV I/O I/O
DEV DEV
I/O I/O
DEV DEV
I/O BUS I/O I/O
DEV DEV
I/O I/O I/O
DEV DEV DEV
3. Device Interface:
• Device specific Interface with the I/O device
• Possibly as per an I/O bus standard.
Typical I/O Interface
SYSTEM BUS
I/O
o o o
Data Register INTERFACE Address I/O INTERFACE
Decoder
Status Register
Command Register
Control
Logic
Device Interface
I/O BUS
I/O Device
Status Register
I/O Address Space I/O Address Space
0 DIC Data Register
1 DIC Address Register
The collection of the addresses of 2 DIC Command Register
the registers in the I/O interfaces 3 DIC Status Register
constitutes the I/O Address
4 NIC Data Register
Space.
5 NIC Address Register
6 NIC Command Register
7 NIC Status Register
. .
The I/O address space is . .
organized in one of the two ways- . .
1. Memory Mapped I/O
2. Isolated I/O PIC Data Register
PIC Address Register
PIC Command Register
P-1 PIC Status Register
I/O Address Space
0
An Input/Output routine
running on the processor No Printer
carries out the Ready?
Data Transfer
Complete? No
Yes
Return
Program Controlled I/O
➢ Example I/O Routine:
data_start 1000 ; Data block start address in memory
data_size 500 ; Size of the data block
ready_mask 01 ; Ready bit mask
printer_sr 10 ; Printer interface status register address
printer_dr 11 ; Printer interface data register address
mov #data_start, R0 ; Initialize Memory Buffer Pointer
mov #data_size, R1 ; Initialize Byte Counter
print_loop: tst #ready_mask, @printer_sr ; Busy Wait Loop
bz print_loop
mov (R0)+, @printer_dr ; Transfer data to printer data register
dec R1 " tst " performs
bnz print_loop bitwise AND
operation
return PwrOn Ready
Bit Bit
printer_sr
Disadvantages of Program Controlled I/O
Busy-Wait Loop
➢ I/O devices are normally much slower than the processor.
➢ Busy Wait Loop can be pretty long drawn – for some
devices the loop may have to be executed 100s or even
1000s of times.
➢ The processor remains busy checking the I/O interface
status, not doing anything useful.
➢ Highly inefficient.
Questions?
Interrupt Driven I/O
▪ Interrupt Driven I/O tries to overcome the “Busy Wait”
problem of Program Controlled I/O.
▪ After a unit of data transfer to the I/O interface the processor,
instead of continuing to check whether the interface has
become ready to receive the next unit of data, it goes onto
carry other pending tasks.
▪ When the interface becomes ready, it calls attention of the
processor by raising an “Interrupt” signal.
▪ On receiving the Interrupt signal the processor puts on hold
the task it is busy with at that moment and goes back to
transfer the next unit of data to the I/O interface.
▪ The wastage of time by the processor in the Busy Wait loop is
avoided.
Interrupt Mechanism
The basic interrupt mechanism in a computer typically consists of
the following:
• There is an Interrupt Request (IRQ) signal line on the bus that allows
an I/O interface to raise an interrupt request.
• There is an Interrupt Acknowledgement (INTA) signal line using which
the processor indicates acceptance of to the interrupt request.
• The processor interrupts the program currently under execution,
saves the current PC & PS in the stack and transfers control to the
Interrupt Service Routine (ISR) meant for the I/O device concerned.
• After completion of execution of the ISR the processor restores the
saves PC & PS so as to resume execution of the interrupted program.
IRQ
Processor I/O I/O Device
Interface
INTA
Interrupt Mechanism
Multiple Interfaces with Interrupt Capability:
To allow more than one interface in the computer system to have interrupt
capability there are different possibilities:
1. Provide one IRQ signal line for each interface,
2. Let multiple interfaces share one IRQ signal line.
Processor Processor
IRQ Line
IRQ Lines
I/O Interface I/O Interface I/O Interface I/O Interface I/O Interface I/O Interface
Interrupt identification:
1. Polling
2. Vectored Interrupt
• interrupt vector (PC & PS)
• Interrupt Vector Table (IV Table)
Multiple Interfaces with Interrupt Capability:
Interrupt identification:
1. Polling
2. Vectored Interrupt
• interrupt vector (PC & PS)
• Interrupt Vector Table (IV Table)
Processor Processor
IRQ Line
IRQ Lines
I/O Interface I/O Interface I/O Interface I/O Interface I/O Interface I/O Interface
V-1
Simultaneous Interrupts/ Interrupt Priority Mechanisms
• If there are multiple I/O interfaces capable of raising interrupt
request there is possibility that more than one interface raise
interrupt request at the same time.
• The processor has to decide which interface it will service first. While
one interface is serviced the other ones have to wait for their turn.
• There is a question of priority that comes up.
• There is need for an Interrupt Priority mechanism.
IRQ1
INTA1
I/O Interface
Processor
IRQ2
INTA2 I/O Interface
IRQ3
INTA3
I/O Interface
Some of the possible mechanisms
1. Priority Levels:
• In case there are different interrupt request lines each interrupt request
line is assigned a priority level.
• When more than one interface raises interrupt requests simultaneously the
processor compares the priority levels of the corresponding interrupt
request lines.
• Response is sent to the interface using the IRQ with higher priority by
sending INTA to that interface.
IRQ1
INTA1
I/O Interface
Processor
IRQ2
INTA2 I/O Interface
PSR P P P C C C
IRQ3
INTA3 PSR
I/O Interface
Interrupt Priority Mechanisms
Priority Levels (contd.):
Further,
• The priority level of the currently executing process is specified by the
Priority Bits in the PSR.
• On receiving an IRQ signal the processor compares the priority of the
device with the priority of the current process
• Processor responds to an IRQ only if its priority is higher than that of the
current process.
IRQ1
INTA1
I/O Interface
Processor
IRQ2
INTA2 I/O Interface
P P P C C C
PSR
IRQ3 PSR
INTA3
I/O Interface
Interrupt Priority Mechanisms
IRQ
Processor
INTA
Interface1 Interface2 Interface3
Interface
I R
Status Register
Daisy Chaining of Interrupt Acknowledgement (INTA)
• When more than one interfaces share an IRQ signal line they
also share the same INTA signal line.
• The INTA signal line is daisy chained through the interfaces.
• i.e., the INTA signal line enters one interface, goes through its
logic circuits, comes out to enter the next interface .
• The INTA signal can therefore propagate through the interfaces.
• An interface does not allow the signal to propagate through it if
it is one of the interfaces raising interrupt request.
• The first interface in the chain among the interfaces raising IRQ
receives the INTA signal and gets the chance to place its
identification code on the data bus to obtain service from the
processor while the rest have to wait for their turn.
• Hence the sequence of the interfaces in the daisy chain defines
the interrupt priority among the interfaces sharing the IRQ, INTA
pair. The interface nearest to the processor has the highest
priority.
General Interrupts Structure
Processor
IRQ1
INTA1
Interface1 Interface2 Interface3
IRQ2
INTA2
Interface1 Interface2 Interface3
IRQk
INTAk
Interface1 Interface2 Interface3
Steps involved in the process of interrupts
(with Vectored Interrupt)
1. The I/O interface raises the IRQ
2. The processor starts interrupt processing by comparing the priority level of
the IRQ with the priority level of the current process (i.e. the priority level
in PSR). If the priority level of the IRQ is found to be higher then it
interrupts the current process, saves its PC and PS in the stack and issues
the appropriate INTA.
3. Else the interrupt processing is deferred until the priority level in PSR is
modified.
4. In response to the INTA the interrupting interface places its identification
code on the data bus and removed the IRQ.
5. The processor reads identification code from the bus, extracts the
interrupt vector from the IV-table, modifies PC and PSR accordingly to
transfer control to the IRS of the I/O device.
6. The ISR is executed to provide the required service to the device.
7. On completion of execution of the ISR the saved PC, PS values are restored
so that execution of the interrupted process is resumed.
Questions ?
Provision for Interrupts in the Instruction Execution Loop
Processor
Pr Pr P P P C C C C C
SYSTEM BUS
I/O I/O
I/O INTERFACE o o o I/O INTERFACE
INTERFACE INTERFACE
without DMA with DMA
I/O
I/O DEV
I/O
DEV DEV I/O I/O
DEV DEV
I/O I/O
DEV DEV
I/O BUS I/O I/O
DEV DEV
I/O I/O I/O
DEV DEV DEV
Requirements for DMA
• For DMA the I/O interface needs to access the memory unit by
itself.
• Requires the capability of driving the bus.
• Be able to become a bus master,
• Be able to generate a memory address and place it on the bus,
• Be able to issue read/ write command to the memory unit.
• A DMA interface typically has the following:
• a start address register,
• a word/ byte count register,
• an address counter, and
• the normal set of I/O interface registers, namely,
• data register,
• command register,
• status register
CPU Memory
SYSTEM BUS
Status Register
I/O BUS