§5.5 device class characteristics douglas wilhelm harder, m.math. lel department of electrical and...

31
§5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo, Ontario, Canada ece.uwaterloo.ca [email protected] © 2012 by Douglas Wilhelm Harder. Some rights Based in part on Gary Nutt, Operating Systems, 3 rd ed.

Upload: trista-cottier

Post on 29-Mar-2015

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

§5.5 Device Class Characteristics

Douglas Wilhelm Harder, M.Math. LELDepartment of Electrical and Computer Engineering

University of Waterloo

Waterloo, Ontario, Canada

ece.uwaterloo.ca

[email protected]

© 2012 by Douglas Wilhelm Harder. Some rights reserved.Based in part on Gary Nutt, Operating Systems, 3rd ed.

Page 2: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

2

Outline

This topic will look at device class characteristics– Byte versus block oriented– Communication devices– Storage devices

• UART, USB, and IEEE 1394 Firewire

– Asynchronous serial devices– Sequentially Accessed Storage Devices– Randomly Accessed Storage Devices– Magnetic disks and scheduling

Device Class Characteristics

Page 3: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

3

Introduction

We will consider separating devices based on– The amount of data read or written in one operation– The device is for data communication or data storage– For storage devices:

• Is access sequential or random?• Is the storage volatile or non-volatile

Device Class Characteristics

Page 4: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

4

Byte versus Block Oriented

Devices read either individual bytes/words or blocks of data at time– Block-oriented usually work in fixed-sized blocks of data– Usually powers of two on the order of 512, 1024, or 2048 bytes

Device Class Characteristics

Page 5: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

5

Byte Oriented

Processors are byte- or word-oriented– To modify a single bit, it is necessary to load the byte or word

containing the bit, modify the bit, and then save the byte or word

Device Class Characteristics

Page 6: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

6

Block Oriented

Hard drives are block-oriented– To read one byte of a file on a hard drive, it is necessary to load

the entire block containing that byte

Device Class Characteristics

Page 7: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

7

Communication Devices

Communication devices transmit information either to or from the computer– Transmission to another computer– Transmission to another device

• Usually byte-oriented through a serial port, e.g., USB

It is usually not expected that the data would be retrieved identically

Device Class Characteristics

Page 8: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

8

Storage Devices

A storage device is meant to store data for future access

Sequentially accessed storage devices point to a specific location and only allow the controller to advance to either the previous or next location– Tape drives and punch cards

Randomly accessed storage devices allow the controller to access any location in the storage device– Hard drives, main memory

Device Class Characteristics

Page 9: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

9

Storage Devices

A storage device is meant to store data for future access

Volatile storage devices requires a continuous supply of power to maintain the integrity of that data– SDRAM

Non-volatile or persistent storage devices continue to store information even if any power source is removed– ROM, flash memory, magnetic, optical, and punch-card storage

Device Class Characteristics

Page 10: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

10

Communication Devices

Communications devices:– Have byte-oriented transmissions– Send or receive data from devices remote to the bus

The communications device controller will require the use of an interface and a protocol– The most common interface on personal computers is the USB– Previously, we had PS/2, serial, and parallel connections

Device Class Characteristics

Page 11: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

11

Communication Devices

Communications devices may also be attached to external connections– Telephone lines– Coaxial cables– Optical fibres– Radio waves– Free-space optical– Microwave– Twisted pair links

Device Class Characteristics

User: Arj

User: BigRiz

User: Fo0bar

User: Clock twibright

Baran Ivo

Page 12: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

12

Communication Devices

Usually the device is remote and the communications controller must use the appropriate interface and protocol– Exception exist: the voice-band

modem is essentially a glorifiedspeaker and microphone

Device Class Characteristics

Page 13: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

13

Communication Devices

The computer engineer will consider the communications between the controller and the device

The software engineer is focusedon the communication betweenthe driver and the controller

Device Class Characteristics

Page 14: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

14

UART

The Universal Asynchronous Receiver Transmitter (UART) :– Is a serial communications controller– Has built-in microprocessor, RAM and ROM– Uses the RS-232 controller-device interface– Has speeds up to 115 kbit/s

The driver can specify the protocol bywriting the appropriate settings to thecontroller

Device Class Characteristics

User: Myself248

Page 15: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

15

USB

The Universal Serial Bus (USB) :– Is a serial communications controller– Specifies not only the interface but also the protocol

Speeds:USB 1 12 Mbits/s

USB 2 480 Mbit/s

USB 3 5000 Mbit/s

Device Class Characteristics

User: Viljo Viitanen

Page 16: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

16

IEEE 1394 Firewire

Firewire is also a high-speed serial bus– Initiated by Apple in 1986 after Steve Jobs left– Developed into an IEEE standard– More expensive than USB– Initially faster than USB

Device Class Characteristics

User: Jonathan Zander (Digon3)

Mikkel Paulson

Page 17: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

17

Asynchronous Serial Devices

Asynchronous serial communications involves:– Sending a start signal before any word– Sending a stop signal after each word– The sender pauses after each character– The pause must be no shorter than the pause of the receiver– The pause can be arbitrarily long

Device Class Characteristics

Page 18: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

18

Asynchronous Serial Devices

The following must be determined:– The number of data and formatting bits– The order of the bits (endianness)– The possible presence of a parity bit (even or odd)– Full or half duplex– The speed of the communication

Device Class Characteristics

Page 19: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

19

Sequentially Accessed Storage Devices

Sequentially accessed data evolved as:– Punch cards– Paper tape– 7-track and 9-track magnetic tapes– Compact cassettes– DAT

Can use linear or helical scanning

Device Class Characteristics

User: Yaoleilei

User: GRAHAMUK

parity bit

Page 20: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

20

Sequentially Accessed Storage Devices

It is possible to implement rapid scanning– Still linearly scanning

Note that some algorithms can still be efficiently implemented on sequentially storage– Merge sort will run in Q(n ln(n)) time– It will require Q(n) additional memory—another tape just as long

Device Class Characteristics

Page 21: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

21

Randomly Accessed Storage Devices

Most randomly accessed persistent storage is block-oriented– Sequential scanning is potentially difficult– Logical sequential blocks may not be stored physically – File managers will attempt to store such blocks sequentially on

the disk—failure to do this is termed fragmentation

Note that some algorithms can still be efficiently implemented on sequentially storage– Merge sort will run in Q(n ln(n)) time– It will require Q(n) additional memory—another tape just as long

Device Class Characteristics

Page 22: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

22

Magnetic Disks

Magnetic disks work by separating the disk into magnetic domains– Heads either read or magnetize these domains– The circular disks spin at up to 15 000 rpm– There are usually a number of disks in any drive– Each disk is divided into

• Tracks• Sectors

where one track in a sector is thesmallest addressable storage unit

• Usually 512 KiB

– The set of all tracks the same distancefrom the spindle are said to form a cylinder

Device Class Characteristics

Page 23: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

23

Magnetic Disks

The head either reads or magnetizes the domains– It can access all disks in one cylinder simultaneously

Suppose you want to read one sector onone track– The head must be moved into position and the

disk must be rotated– It takes 2 ms on a 15 000 rpm disk, on average,

to reach a sector on a track• Rotational latency

– To move the arm, however, is more expensive:• A seek time of 10 ms

Device Class Characteristics

User: Suit

Page 24: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

24

Magnetic Disk Scheduling

We will now consider our first scheduling issue:– Observation: in 1 ms, any reasonable microprocessor controller

can execute many thousand instructions– Can we use this execution time to optimize disk access time?

Suppose we have a hard drive for a web server– There are numerous requests coming in for different web pages– Each web page is likely to be located elsewhere on the disk– How do we process these requests?

Device Class Characteristics

Page 25: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

25

Magnetic Disk Scheduling

Assumptions:– Rotational latency 2 ms– Tracks per disk 36 000 (30 000 tracks

per inch)– Average seek time 8 ms– Head speed 2 tracks/us– Read time 1 ms

Device Class Characteristics

Page 26: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

26

First In, First Out (FIFO)

Queue the requests and service the requests in order– Fair: the requests are services in the order in which they appear– Problem: the average wait time might be very long

Device Class Characteristics

Page 27: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

27

Shortest Seek-time First (SSTF)

Of all unserviced requests, select as the next that one which is closest– Fast: an optimal algorithm for servicing the highest number of

requests per unit time– Problem: “starvation”

• Requests that are far from the current location of the head may never get serviced

Device Class Characteristics

Page 28: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

28

LOOK

Move from the first track to the last servicing requests as the tracks are passed and then turn back– Reasonably fast and avoids starvation– Problem: potentially a long delay time for processes

Device Class Characteristics

Page 29: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

29

C-LOOK

Circular looking only transits in one direction– Increases the average expected waiting time– Decreases the standard deviation

• All requests take slightly longer but not take extraordinarily longer

– Problem: what happens if there are a large number of requests in one region?

Device Class Characteristics

Page 30: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

30

F-LOOK and N-step LOOK

If too many new requests come in for a particular region, the head might spend a significant time in that region, thus ignoring other requests– Arm stickiness

Solutions:– F-LOOK

• When starting one scan, only serve those requests that have been already made

• All other requests are placed into a queue• When the scan has finished, go through the requests in the queue

Device Class Characteristics

Page 31: §5.5 Device Class Characteristics Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,

31

Summary

This topic looked at characteristics of device classes– Byte versus block oriented– Communication devices– Storage devices

• UART, USB, and IEEE 1394 Firewire

– Asynchronous serial devices– Sequentially Accessed Storage Devices– Randomly Accessed Storage Devices– Magnetic disks and scheduling

Device Class Characteristics