§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 © 2012 by Douglas Wilhelm Harder. Some rights reserved. Based in part on Gary Nutt, Operating Systems, 3 rd ed.
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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11 User: Arj User: BigRiz User: Fo0bar User: Clock twibright Baran Ivo
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 glorified speaker and microphone Device Class Characteristics 12
Communication Devices The computer engineer will consider the communications between the controller and the device The software engineer is focused on the communication between the driver and the controller Device Class Characteristics 13
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 by writing the appropriate settings to the controller Device Class Characteristics 14 User: Myself248
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 Mbit/s USB Mbit/s Device Class Characteristics 15 User: Viljo Viitanen
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 16 User: Jonathan Zander (Digon3) Mikkel Paulson
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 17
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 18
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 19 User: Yaoleilei User: GRAHAMUK parity bit
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 (n ln(n)) time –It will require (n) additional memoryanother tape just as long Device Class Characteristics 20
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 diskfailure to do this is termed fragmentation Note that some algorithms can still be efficiently implemented on sequentially storage –Merge sort will run in (n ln(n)) time –It will require (n) additional memoryanother tape just as long Device Class Characteristics 21
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 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 the smallest addressable storage unit Usually 512 KiB –The set of all tracks the same distance from the spindle are said to form a cylinder Device Class Characteristics 22
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 on one track –The head must be moved into position and the disk must be rotated –It takes 2 ms on a 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 23 User: Suit
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 24
Magnetic Disk Scheduling Assumptions: –Rotational latency2 ms –Tracks per disk36 000( tracks per inch) –Average seek time8 ms –Head speed2 tracks/us –Read time1 ms Device Class Characteristics 25
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 26
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 27
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 28
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 29
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 30
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 31