i/o interfacing a lot of handshaking is required between the cpu and most i/o devices. all i/o...

11
I/O Interfacing • A lot of handshaking is required between the CPU and most I/O devices. • All I/O devices operate asynchronously with respect to the CPU. The events that determine when an input device has data available or when an output device needs data are independent of the CPU.

Upload: horace-george

Post on 03-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU

I/O Interfacing

• A lot of handshaking is required between the CPU and most I/O devices.

• All I/O devices operate asynchronously with respect to the CPU. The events that determine when an input device has data available or when an output device needs data are independent of the CPU.

Page 2: I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU

Three I/O strategies

• Must be capable of data rates fast enough to keep up with the demands of the device, but must not be allowed to transfer data faster than the device can process it.

» Polled waiting loops» Interrupt-driven I/O» Direct memory Access (DMA)

Page 3: I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU

Synchronization

• The CPU must have some way of checking the status of the device and waiting until it is ready to transfer

Page 4: I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU

Transfer Rate

• A measure of the number of bytes per second transferred between the CPU and an external device.

• Maximum transfer rate – a measure of the bandwidth capability of a particular method of doing I/O.

Page 5: I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU

Comparison of transfer rates

• Polled waiting loops provide data rates that are a bit slower, but still quite reasonable.

• Interrupt-driven I/O requires overhead of saving and restoring the machine state (significantly degrades data rates unless more than one byte can be transferred per interrupt.

• DMA has fastest transfer rates (additional hardward complexity needed.

Page 6: I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU

Latency

• Measure of the delay from the instant that the device is ready until the time the first data byte is transferred. Latency is equivalent to the “response time”

Page 7: I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU

Comparison of Latency

• Polled Waiting Loops – latency can be very high (the computer may not even be checking the device for new data when it arrives).

• Interrupt-driven I/O – dramatically lower than polled, but still imposes a software overhead.

• DMA – very low (lower than the others)

Page 8: I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU

Polled Waiting I/O

• Use software to test the status of a device,before transferring each data byte.

• Continuously checking the peripheral’s BUSY/READY flag

• Ties up the CPU – no other tasks can be performed.

Page 9: I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU

Interrupt-Driven I/O• There are different types of interrupts

– Hardware• Generated by the 8259 PIC – signals the CPU to suspend execution of

the current program and process the interrupt (keyboard, serial port)• Occasionally, programs must disable hardware interrupts when

performing sensitive operations on segment registers and the stack. Use CLI (Clear Interrupt flag) to disable interrupts and STI (Set interrupt flag) to enable interrupts.

– Software • Not really an interrupt (INT)

– Internal Interrupts• Divide by zero• Traps

Page 10: I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU

Responding to Interrupts

Normal Processing

Interrupt Occurs

Finish Current Instruction

Normal Processing Resumes

Push flags, CS, and IP (EIP) onto stack

Pop flags, CS, and IP(EIP) from stack

Branch to ISR

Execute ISR

Page 11: I/O Interfacing A lot of handshaking is required between the CPU and most I/O devices. All I/O devices operate asynchronously with respect to the CPU

Hardware Interrupt Pins

• NMI – non-maskable interrupt – it cannot be blocked (the CPU must respond) – reserved for critical system functions.

• INTR – maskable via the IF flag.