Top Banner
Lecture 7b I/O
35

Lecture 7b I/O. I/O devices Device (mechanical hardware) Device controller (electrical hardware) Device driver (software)

Dec 19, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Lecture 7b

I/O

Page 2: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

I/O devices

Device (mechanical hardware) Device controller (electrical hardware) Device driver (software)

Page 3: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Devices and their controllers

Components of a simple personal computer

Monitor

Bus

Page 4: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

How to communicate with a device?

Hardware supports I/O ports or memory mapped I/O for accessing device controller registers and buffers

Page 5: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Wide performance range for I/O

Page 6: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Performance challenges: I/O hardware

How to prevent slow devices from slowing down memory

How to identify I/O addresses without interfering with memory performance

Page 7: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Hardware view of Pentium

Structure of a large Pentium system

Page 8: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Performance challenges: I/O software

How to prevent CPU throughput from being limited by I/O device speed

How to prevent I/O throughput from being limited by CPU speed

How to achieve good utilization of CPU and I/O devices

How to meet the real-time requirements of devices

Page 9: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Programmed I/O

Polling/busy-waiting approach

copy_from_user(buffer,p,count);

for(i=0;i<count;i++){

while (*p_stat_reg != READY);

*p_data_reg = p[i];

}

return();

Page 10: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Interrupt driven I/O

(b)

Page 11: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Interrupt-driven I/O

Asynchronous approach give device data, do something else! resume when device interrupts

copy_from_user(buffer,p,count);enable_interrupts();while (*p_stat_reg != READY);*p_data_reg=p[0];scheduler();

if (count==0){ unblock_user();} else { *p_data_reg = p[i]; count--; i++;}ack_interrupt();return_from_interrupt();

Page 12: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

DMA

Offload all work to a DMA controller avoids using the CPU to do the transfer reduces number of interrupts DMA controller is like a co-processor doing

programmed I/O

copy_from_user(buffer,p,count);set_up_DMA_controller();scheduler();

ack_interrupt();unblock_user();return_from_interrupt();

Page 13: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

DMA

Page 14: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Software engineering-related challenges

How to remove the complexities of I/O handling from application programs

standard I/O APIs (libraries and system calls) generic across different device types

How to support a wide range of device types on a wide range of operating systems

standard interfaces for device drivers standard/published interfaces for access to

kernel facilities

Page 15: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

I/O Software: Device Drivers

Device drivers “connect” devices with the operating system

Typically a nasty assembly-level job• Must deal with hardware changes• Must deal with O.S. changes

Device drivers are typically given kernel privileges

Can bring down O.S.!

Page 16: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

I/O Software design issues

Synchronous vs. asynchronous transfers Blocked transfers vs. interrupt-driven

Buffering Data coming off a device cannot be stored in

final destination

Sharable vs. dedicated devices Disks are sharable Tape drives would not be

Page 17: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

I/O software design issues

Device independence programs can access any I/O device without

specifying device in advance (floppy, hard drive, or CD-ROM)

Uniform naming Name of a file or device a string or an integer

not depending on which machine Shouldn’t depend upon the device

Error handling Handle as close to the hardware as possible

Page 18: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Devices as files

Before mounting, files on floppy are inaccessible

After mounting floppy on b, files on floppy are part of file hierarchy

Page 19: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Spare Slides

Page 20: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Disks

Page 21: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Disk geometry

Disk head, platters, surfaces

cylinder

Track

Sector

Page 22: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Disk geometry

CAV & CLV

Page 23: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

RAID

Page 24: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

RAID

Page 25: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

CD-ROMs

Page 26: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Plastic technology

CDs Approximately 650 Mbytes of data Approximately 74 minutes of audio

DVDs Many types of formats

• DVD-R, DVD-ROM, DVD-Video Single layer vs. multi-layer Single sided vs. double sided Authoring vs. non-authoring

Page 27: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Disk scheduling algorithms

Time required to read or write a disk block determined by 3 factors

Seek time Rotational delay Actual transfer time

Seek time dominates

Error checking is done by controllers

Page 28: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Disk scheduling algorithms

First-come first serve

Shortest seek time first

Scan back and forth to ends of disk

C-Scan only one direction

Look back and forth to last request

C-Look only one direction

Page 29: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Disk scheduling algorithms

Page 30: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Display hardware

PCI graphics card (traditional) Map frame buffer into memory

Page 31: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Display hardware

Intel-based systems

Page 32: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Display hardware

Resolution Determines the amount of pixels displayable

and the # of colors that can be used• 1024*768*24-bit color ~2 MBytes• 1600*1200*24-bit color ~6 Mbytes• 1600*1200*(16 colors) ~1 Mbytes

Usually double-buffered

Data rate Determines refresh rate Monitor must be greater than what the video

card is trying to display

Page 33: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

X-terminals

Page 34: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

X-terminals

Long past X-terminals were great because of limited pixel

depth Good way to share expensive resources

Future Great way to limit maintenance costs Great for basic applications X-terminals are getting killed by multimedia

applications• DVD 740*480*24-bit color 255 Mbps!!

Page 35: Lecture 7b I/O. I/O devices  Device (mechanical hardware)  Device controller (electrical hardware)  Device driver (software)

Summary

Mismash of I/O topics Readings:

5.1 – 5.1.4, 5.2, 5.4 – 5.4.3, 5.7.1

Homework #4 – Due Wed. Dec. 1 Chapter 4:

• Problem # 23, 29 Chapter 5:

• Problem # 24