Download - Device Controller
![Page 1: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/1.jpg)
1
Device Controller
I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller
or adapter. Interface between controller and device is
a very low level interface. Example:
Disk controller converts the serial bit stream, coming off the drive into a block of bytes, and performs error correction.
![Page 2: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/2.jpg)
2
Input/ Output Problems Wide variety of peripherals
Delivering different amounts of data At different speeds In different formats All slower than CPU and RAM
External devices are not generally connected directly into the computer bus structure
Need I/ O modules Interface to CPU and Memory Interface to one or more peripherals
![Page 3: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/3.jpg)
3
External Devices
Human readable Screen, printer, keyboard
Machine-readable Monitoring and control
Communication Modem Network Interface Card (NIC)
![Page 4: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/4.jpg)
4
I/ O Module Function
Control & Timing CPU Communication Device Communication Data Buffering Error Detection
![Page 5: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/5.jpg)
5
I/O Steps
CPU checks I/O module device status I/O module returns status If ready, CPU requests data transfer I/O module gets data from device I/O module transfers data to CPU Variations for output, DMA, etc.
![Page 6: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/6.jpg)
6
I/ O Module Decisions
Hide or reveal device properties to CPU
Support multiple or single device Control device functions or leave
for CPU
![Page 7: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/7.jpg)
7
Input Output Techniques
Programmed Interrupt driven Direct Memory Access (DMA)
![Page 8: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/8.jpg)
8
Programmed I/O
CPU requests I/O operation I/O module performs operation I/O module sets status bits CPU checks status bits periodically I/O module does not inform CPU
directly I/O module does not interrupt CPU CPU must wait
![Page 9: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/9.jpg)
9
I/ O Commands CPU issues address
Identifies module (& device if >1 per module) CPU issues command
Control - telling module what to do e. g. spin up disk
Test - check status e. g. power? Error?
Read/ Write Module transfers data via buffer from/ to device
CPU is in direct control of the operation
![Page 10: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/10.jpg)
10
I/O Addressing
To give a command to an I/O device, the processor must be able to address the device and supply commands
Two Methods are used to address the device Memory mapped I/O Isolated I/O
![Page 11: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/11.jpg)
11
Memory Mapped I/O Portions of the address space are assigned
to I/O devices i.e I/O devices and memory share a single
address space Processor treats the status and data
registers of I/O module as memory locations
Reads and Writes to these locations (Registers) are interpreted as commands to the I/O device
![Page 12: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/12.jpg)
12
Memory-Mapped I/O (1)
(a) Separate I/O and memory space(b) Memory-mapped I/O(c) Hybrid
![Page 13: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/13.jpg)
13
Memory-Mapped I/O (2)
(a) A single-bus architecture(b) A dual-bus memory architecture
![Page 14: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/14.jpg)
14
CPU Viewpoint
Issue read command Do other work Check for interrupt at end of each
instruction cycle If interrupted: -
Save context (registers) Process interrupt
Fetch data & store
![Page 15: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/15.jpg)
15
Isolated I/O If the system bus is equipped with
separate memory read and write, and input and output command lines, then
Command line specifies whether the address on the bus is related to a memory location or an I/O device Can have as many I/O devices as memory
locations Because address space for I/O is isolated
from memory , this approach is know as Isolated I/O
![Page 16: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/16.jpg)
16
Programmed I/O: Adv. & Disadv.
Advantages of Programmed I/O Simple to implement Requires very little special software or hardware
Disadvantages: Speed difference between CPU and the
peripheral devices -- orders of magnitude: programmed I/O wastes an enormous amount of CPU cycles
Very inefficient CPU slowed to the speed of the peripheral
![Page 17: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/17.jpg)
17
Interrupt Driven I/O
Basic Operation CPU issues read command I/O module gets data from peripheral
whilst CPU does other work I/O module interrupts CPU CPU requests data I/O module transfers data
![Page 18: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/18.jpg)
18
Interrupts
Connections between devices and interrupt controller actually use interrupt lines on the bus rather than dedicated wires
![Page 19: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/19.jpg)
19
Host-controller interface: Interrupts
CPU hardware has the interrupt report line that the CPU senses after executing every instruction
device raises an interrupt CPU catches the interrupt and saves the state (e.g.,
Instruction pointer) CPU dispatches the interrupt handler interrupt handler determines cause, services the device
and clears the interrupt Why interrupts? Real life analogy for interrupt
An alarm sets off when the food/laundry is ready So you can do other things in between
![Page 20: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/20.jpg)
20
Support for Interrupts
Need the ability to defer interrupt handling during critical processing
Need efficient way to dispatch the proper device Interrupt comes with an address (offset in
interrupt vector) that selects a specific interrupt handling
Need multilevel interrupts - interrupt priority level
![Page 21: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/21.jpg)
21
Interrupt Handler
At boot time, OS probes the hardware buses to
determine what devices are present
install corresponding interrupt handlers into the interrupt vector
During I/O interrupt, controller signals that device is ready
![Page 22: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/22.jpg)
22
Direct Memory Access Interrupt driven and programmed I/ O
require active CPU intervention Transfer rate is limited CPU is tied up
DMA is the answer DMA takes the CPU out of the I/ O task
except for initialization Large amounts of data can be transferred
between memory and the peripheral without severely impacting CPU performance
![Page 23: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/23.jpg)
23
Function and Operation DMA Function
Additional Module (hardware) on bus DMA controller takes over from CPU for I/ O
DMA Operation CPU tells DMA controller: -
Read/ Write Device address Starting address of memory block for data Amount of data to be transferred
CPU carries on with other work DMA controller deals with transfer DMA controller sends interrupt when finished
![Page 24: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/24.jpg)
24
DMA Transfer - Cycle Stealing DMA controller takes over bus for a cycle Transfer of one word of data Not an interrupt
CPU does not switch context CPU suspended just before it accesses bus
i. e. before an operand or data fetch or a data write
Slows down CPU but not as much as CPU doing transfer
![Page 25: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/25.jpg)
25
DMA Configurations (1)
Single Bus, Detached DMA controller Each transfer uses bus twice
I/O to DMA then DMA to memory CPU is suspended twice
CPUDMAController
I/ODevice
I/ODevice
Main Memory
![Page 26: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/26.jpg)
26
DMA Configurations (2)
Single Bus, Integrated DMA controller Controller may support >1 device Each transfer uses bus once
DMA to memory CPU is suspended once
CPUDMAController
I/ODevice
I/ODevice
Main Memory
DMAController
I/ODevice
![Page 27: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/27.jpg)
27
DMA Configurations (3)
Separate I/O Bus Bus supports all DMA enabled devices Each transfer uses bus once
DMA to memory CPU is suspended once
CPU DMAController
I/ODevice
I/ODevice
Main Memory
I/ODevice
I/ODevice
![Page 28: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/28.jpg)
28
Direct Memory Access (DMA)
Direct memory access (DMA) Assists in exchange of data between CPU
and I/O controller CPU can request data from I/O controller byte
by byte – but this might be inefficient (e.g. for disk data transfer)
Uses a special purpose processor, called a DMA controller
![Page 29: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/29.jpg)
29
DMA-CPU Protocol
Use disk DMA as an example CPU programs DMA controller, sets registers to
specify source/destination addresses, byte count and control information (e.g., read/write) and goes on with other work
DMA controller proceeds to operate the memory bus directly without help of main CPU – request from I/O controller to move data to memory
Disk controller transfers data to main memory Disk controller acks transfer to DMA controller
![Page 30: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/30.jpg)
30
Direct Memory Access (DMA)
Operation of a DMA transfer
![Page 31: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/31.jpg)
31
DMA Issues
Handshaking between DMA controller and the device controller
Cycle stealing DMA controller takes away CPU cycles
when it uses CPU memory bus, hence blocks the CPU from accessing the memory
In general DMA controller improves the total system performance
![Page 32: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/32.jpg)
32
Discussion
Tradeoffs between Programmed I/O Interrupt-driven I/O I/O using DMA
Which one is the fastest for a single I/O request?
Which one gives the highest throughput?
![Page 33: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/33.jpg)
33
![Page 34: Device Controller](https://reader035.vdocuments.net/reader035/viewer/2022070404/56813b21550346895da3d848/html5/thumbnails/34.jpg)
34