Top Banner
1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software 5.3 I/O software layers 5.4 Disks 5.5 Clocks 5.6 Character-oriented terminals 5.7 Graphical user interfaces 5.8 Network terminals 5.9 Power management 251 I/O Devices Block devices (e.g., disks) info stored in fixed-size blocks (512-32K bytes) address r/w each block independent of others Character devices (mouse, network interface) accepts/delivers a stream of characters not block-addressable Other types: clocks
16

Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

Mar 22, 2018

Download

Documents

TranAnh
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: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

1

250

Input/Output

Chapter 5

5.1 Principles of I/O hardware5.2 Principles of I/O software5.3 I/O software layers5.4 Disks5.5 Clocks5.6 Character-oriented terminals5.7 Graphical user interfaces5.8 Network terminals5.9 Power management

251

I/O Devices

Block devices (e.g., disks)– info stored in fixed-size blocks (512-32K bytes)

– address r/w each block independent of others

Character devices (mouse, network interface)– accepts/delivers a stream of characters

– not block-addressable

Other types: clocks

Page 2: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

2

252

I/O Devices (2)

Block

253

Principles of I/O Hardware

Some typical device, network, and data base rates

Page 3: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

3

254

Device Controllers/Adapters

• I/O devices have components:– mechanical component– electronic component

• The electronic component is the devicecontroller– may be able to handle multiple devices

• Controller's tasks– convert serial bit stream to block of bytes– perform error correction as necessary– make available to main memory

255

Device Controllers (2)

Printed circuit board on a slot (bus) fromwhich cable goes to actual device

• between controller and device– low-level interface, typically bitstream (ECC)– controller does conversion, error correction

• device driver initializes controller with a fewhigh-level parameters, controller does rest– memory region for data specified

• controller may have its own powerfulprocessor

Page 4: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

4

256

Memory-Mapped I/O (1)

• Separate I/O and memory space• Memory-mapped I/O• Hybrid

257

Communicating w/controllersController has• registers to comm with OS

– deliver data, accept data; switch on/off– examine/report status: ready, busy, done, etc.

• often data buffer (e.g., video ram)How is controller visible to OS?• dedicated I/O port, special machine inst.• memory-mappedLines are “raised” or asserted

Page 5: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

5

258

Communicating w/controllers (2)Memory-mapped pros and cons+ use normal memory access instructions

otherwise some ops require loading, etc.

+ enforce protection via address space- caching a device control register: disaster!- complicated if more than one bus (common)

– send addresses to memory, then devices…

259

Memory-Mapped I/O (2)

(a) A single-bus architecture(b) A dual-bus memory architecture

Page 6: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

6

260

Direct Memory Access (DMA)

• Besides control, need to move data

• Interrupt

261

Direct Memory Access (DMA)

Operation of a DMA transfer

Page 7: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

7

262

Interrupts Revisited

How interrupts happens. Connections between devices andinterrupt controller actually use interrupt lines on the busrather than dedicated wires

263

Principles of I/O SoftwareGoals of I/O Software (1)

• 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

• Error handling– handle as close to the hardware as possible

Page 8: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

8

264

Goals of I/O Software (2)

• 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

265

I/O-related work

• programmed I/OCPU does all the work: polling, busy-waiting

• interrupt-driven I/OCPU interrupted by device when ready

• I/O using DMADMA controller plays CPU’s role

Page 9: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

9

266

Programmed I/O (1)

Steps in printing a string

267

Programmed I/O (2)

Writing a string to the printer usingprogrammed I/O

Page 10: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

10

268

Interrupt-Driven I/O

• Writing a string to the printer using interrupt-driven I/O– Code executed when print system call is made– Interrupt service procedure

269

I/O Using DMA

• Printing a string using DMA– code executed when the print system call is made

– interrupt service procedure

Page 11: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

11

270

I/O Software Layers

Layers of the I/O Software System

271

Interrupt Handlers (1)

• Interrupt handlers are best hidden– have driver starting an I/O operation block until

interrupt notifies of completion

• Interrupt procedure does its task– then unblocks driver that started it

• Steps must be performed in software afterinterrupt completed

1. Save regs not already saved by interrupt hardware2. Set up context for interrupt service procedure

Page 12: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

12

272

Interrupt Handlers (2)

3. Set up stack for interrupt service procedure

4. Ack interrupt controller, reenable interrupts

5. Copy registers from where saved

6. Run service procedure

7. Set up MMU context for process to run next

8. Load new process' registers

9. Start running the new process

273

Device Drivers

Communications between drivers and devicecontrollers goes over the bus

Page 13: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

13

274

Device Drivers (ii)

• Monolithic binary OS– must recompile kernel to add a driver

• PCs, etc., dynamically load driver• Standard interface for block; for character

– driver may service several devices

• Similar general structure– validate input params, if valid translate to phys.– get & exec sequence of instructions– wait for device (block), or not; verify checksum– pass data to device-indep software, return status

275

Device-Independent I/O Software (1)

Functions of the device-independent I/O software

Providing a device-independent block size

Allocating and releasing dedicate devices

Error reporting

Buffering

Uniform interfacing for device drivers

Page 14: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

14

276

Device-Independent I/O Software (2)

(a) Without a standard driver interface

(b) With a standard driver interface

277

Device-Independent I/O Software (3)

(a) Unbuffered input(b) Buffering in user space(c) Buffering in the kernel followed by copying to user space(d) Double buffering in the kernel

Page 15: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

15

278

Device-Independent I/O Software (4)

Networking may involve many copies

279

User-Space I/O Software

• most I/O software within OS but librarieslinked with user programs outside kernel(syscalls effected by library procedures)– real I/O related work: formatting of strings

• spooling: daemon process and spooling dir– printing, email, news (USENET)

Page 16: Chapter 5 Input/Output - Department of Computer Sciencecris/481/481.250inputoutput.pdf · 1 250 Input/Output Chapter 5 5.1 Principles of I/O hardware 5.2 Principles of I/O software

16

280

User-Space I/O Software (2)

Layers of the I/O system and the main functions ofeach layer