lecture 15 device management

Upload: kishor0786

Post on 08-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Lecture 15 Device Management

    1/38

    Device Management

  • 8/6/2019 Lecture 15 Device Management

    2/38

    So far

    We have c o vered CPU and mem o rymanagement

    Co mputing is n o t interesting with o ut I/OsDevice management: the O S co mp o nentthat manages hardware devices

    Pr o vides a unif o rm interface t o access deviceswith different physical characteristicsOptimize the perf o rmance o f individual devices

  • 8/6/2019 Lecture 15 Device Management

    3/38

    I/O hardware

    I/O device hardwareMany varieties

    Device c o ntr o ller Co nversi o n a bl o ck o f bytes and I/O o perati o nsPerf o rms err o r c o rrecti o n if necessaryExp o se hardware registers t o co ntr o l the deviceTypically have f o ur registers:

    Data-in register t o be read t o get inputData- o ut register t o be written t o send o utputS tatus register (all o ws the status o f the device t o bechecked)Co ntr o l register (c o ntr o ls the c o mmand the deviceperf o rms)

  • 8/6/2019 Lecture 15 Device Management

    4/38

    Device Addressing

    Ho w the CPU addresses the deviceregisters?Tw o appr o aches

    Dedicated range o f device addresses in thephysical mem o ry

    Requires special hardware instructi o ns ass o ciated withindividual devices

    M emory-mapped I/O: makes no

    distinctio

    nbetween device addresses and mem o ry addressesDevices can be accessed the same way as n o rmalmem o ry, with the same set o f hardware instructi o ns

  • 8/6/2019 Lecture 15 Device Management

    5/38

    Device Addressing Illustrated

    Primarymem o ry

    Device 1

    Device 2

    Mem o ryaddresses

    Mem o ry-mapped I/Os

    Primarymem o ry

    Deviceaddresses

    S eparate deviceaddresses

  • 8/6/2019 Lecture 15 Device Management

    6/38

    Ways t o Access a Device

    Ho w to input and o utput data t o and fr o man I/O device?

    P olling: a CPU repeatedly checks thestatus o f a device f o r exchanging data+ S imple- Busy-waiting

  • 8/6/2019 Lecture 15 Device Management

    7/38

    Ways t o Access a Device

    Interrupt-driven I/Os: A device c o ntr o ller no tifies the c o rresp o nding device driver

    when the device is available+ Mo re efficient use o f CPU cycles- Data c o pying and m o vements- S lo w f o r character devices (i.e., o ne interrupt

    per keyb o ard input)

  • 8/6/2019 Lecture 15 Device Management

    8/38

    Ways t o Access a Device

    Direct memory access (D MA): uses anadditi o nal c o ntr o ller t o perf o rm datamo vements+ CPU is n o t inv o lved in c o pying data- I/O device is much m o re c o mplicated (need t o

    have the ability t o access mem o ry).

    - A pr o cess cann o t access in-transit data

  • 8/6/2019 Lecture 15 Device Management

    9/38

    Ways t o Access a Device

    Double buffering: uses tw o buffers.While o ne is being used, the o ther is beingfilled.

    Anal o gy: pipeliningExtensively used f o r graphics and animati o n

    So a viewer d o es n o t see the line-by-line scanning

  • 8/6/2019 Lecture 15 Device Management

    10/38

    Device Driver

    An O S co mp o nent that is resp o nsible f o r hiding the c o mplexity o f an I/O device

    So that the O S can access vari o usdevices in a unif o rm manner

  • 8/6/2019 Lecture 15 Device Management

    11/38

    Types o f IO devices

    Tw o categ o ries A block device st o res inf o rmati o n in fixed-size bl o cks, eacho ne with its o wn address

    e.g., disks

    A character device deliverso

    r accepts a streamo

    f characters, and individual characters are n o t addressablee.g., keyb o ards, printers, netw o rk cards

    Device driver pr o vides interface f o r these tw o types o f devices

    Other O S co mp o nents see bl o ck devices and character devices, but n o t the details o f the devices.Ho w to effectively utilize the device is the resp o nsibility o f thedevice driver

  • 8/6/2019 Lecture 15 Device Management

    12/38

    Device Driver Illustrated

    User applicati o nsVari o us O S co mp o nents

    Device drivers

    Device c o ntr o llers

    I/O devices

    User level

    OS level

    Hardware level

  • 8/6/2019 Lecture 15 Device Management

    13/38

    Disk as An Example Device

    30-year- o ld st o rage techn o lo gyIncredibly c o mplicated

    A m o dern drive250,000 lines o f micr o co de

  • 8/6/2019 Lecture 15 Device Management

    14/38

    Disk Characteristics

    Disk platters: co ated with magneticmaterials f o r rec o rding

    Diskplatters

  • 8/6/2019 Lecture 15 Device Management

    15/38

    Disk Characteristics

    Disk arm: mo ves a c o mb o f disk headsOnly o ne disk head is active f o r reading/writing

    Diskplatters

    Disk arm

    Disk heads

  • 8/6/2019 Lecture 15 Device Management

    16/38

    Hard Disk Trivia

    Aer o dynamically designed t o fly As cl o se t o the surface as p o ssibleNo r oo m f o r air m o lecules

    Theref o re, hard drives are filled withspecial inert gasIf head t o uches the surface

    Head crashS crapes o ff magnetic inf o rmati o n

  • 8/6/2019 Lecture 15 Device Management

    17/38

    Disk Characteristics

    Each disk platter is divided int o co ncentrictracks

    Diskplatters

    Disk arm

    Disk heads

    Track

  • 8/6/2019 Lecture 15 Device Management

    18/38

    Disk Characteristics

    A track is further divided int o sectors. Asect o r is the smallest unit o f disk st o rage

    Diskplatters

    Disk arm

    Disk heads

    Track

    S ect o r

  • 8/6/2019 Lecture 15 Device Management

    19/38

    Disk Characteristics

    A cylinder co nsists o f all tracks with agiven disk arm p o sitio n

    Diskplatters

    Disk arm

    Disk heads

    Track

    S ect o r

    Cylinder

  • 8/6/2019 Lecture 15 Device Management

    20/38

    Disk Characteristics

    Cylinders are further divided int o z ones

    Diskplatters

    Disk arm

    Disk heads

    Track

    S ect o r

    Cylinder

    Zo nes

  • 8/6/2019 Lecture 15 Device Management

    21/38

    Disk Characteristics

    Z one-bit recording : z o nes near the edgeo f a disk st o re m o re inf o rmati o n (higher bandwidth)

    Diskplatters

    Disk arm

    Disk heads

    Track

    S ect o r

    Cylinder

    Zo nes

  • 8/6/2019 Lecture 15 Device Management

    22/38

    Mo re Ab o ut Hard Drives Than Y o u Ever Want t o Kno w

    T rack skew : starting p o sitio n o f each track isslightly skewed

    Minimize r o tati o nal delay when sequentially transferring

    bytes acr o ss tracksT hermo-calibrations: peri o dically perf o rmed t o acc o unt f o r changes o f disk radius due t o temperature changesTypically 100 t o 1,000 bits are inserted betweensect o rs t o acc o unt f o r min o r inaccuracies

  • 8/6/2019 Lecture 15 Device Management

    23/38

    Disk Access Time

    S eek time: the time t o po sitio n diskheads (~8 msec o n average)R

    otational latency: the time to

    r o

    tate thetarget sect o r to underneath the head Assume 7,200 r o tati o ns per minute (RPM)7,200 / 60 = 120 r o tati o ns per sec o nd1/120 = ~8 msec per r o tati o n

    Average r o tati o nal delay is ~4 msec

  • 8/6/2019 Lecture 15 Device Management

    24/38

    Disk Access Time

    T ransfer time: the time t o transfer bytes Assumpti o ns:

    58 Mbytes/sec4-Kbyte disk bl o cks

    Time t o transfer a bl o ck takes 0.07 msec

    Disk access timeS eek time + r o tati o nal delay + transfer time

  • 8/6/2019 Lecture 15 Device Management

    25/38

    Disk Perf o rmance Metrics

    L atency S eek time + r o tati o nal delay

    BandwidthBytes transferred / disk access time

  • 8/6/2019 Lecture 15 Device Management

    26/38

    Examples o f Disk Access Times

    If disk bl o cks are rand o mly accessed Average disk access time = ~12 msec Assume 4-Kbyte bl o cks4 Kbyte / 12 msec = ~340 Kbyte/sec

    If disk bl o cks o f the same cylinder arerand o mly accessed with o ut disk seeks

    Average disk access time = ~4 msec4 Kbyte / 4 msec = ~ 1 Mbyte/sec

  • 8/6/2019 Lecture 15 Device Management

    27/38

    Examples o f Disk Access Times

    If disk bl o cks are accessed sequentiallyWith o ut seeks and r o tati o nal delaysBandwidth: 58 Mbytes/sec

    Key t o goo d disk perf o rmanceMinimize seek time and r o tati o nal latency

  • 8/6/2019 Lecture 15 Device Management

    28/38

    Disk Trade o ffs

    Larger sect o r size better bandwidth

    Wasteful if o nly 1 byte o ut o f 1 Mbyte isneeded

    S ect o r size S pace utilizati o n Transfer rate

    1 byte 8 bits/1008 bits (0.8%) 80 bytes/sec (1 byte / 12 msec)

    4 Kbytes 4096 bytes/4221 bytes (97%) 340 Kbytes/sec (4 Kbytes / 12 msec)1 Mbyte (~100%) 58 Mbytes/sec (peak bandwidth)

  • 8/6/2019 Lecture 15 Device Management

    29/38

    Disk C o ntr o ller

    Few p o pular standardsIDE (integrated device electr o nics)

    ATA (AT attachment interface)S CS I (small c o mputer systems interface)

    DifferencesPerf o rmanceParallelism

  • 8/6/2019 Lecture 15 Device Management

    30/38

    Disk Device Driver

    Majo r g o al: reduce seek time f o r diskaccesses

    S chedule disk request t o minimize disk armmo vements

  • 8/6/2019 Lecture 15 Device Management

    31/38

    Disk Arm S cheduling P o licies

    F irst come, first serve ( FCFS ): requestsare served in the o rder o f arrival+ Fair am o ng requesters- P oo r f o r accesses t o rand o m disk bl o cks

    S hortest seek time first ( SSTF ): picksthe request that is cl o sest t o the current

    disk arm po

    sitio

    n+ G oo d at reducing seeks- May result in starvati o n

  • 8/6/2019 Lecture 15 Device Management

    32/38

    Disk Arm S cheduling P o licies

    SC AN : takes the cl o sest request in thedirecti o n o f travel (an example o f elevat o r alg o rithm)+ n o starvati o n- a new request can wait f o r alm o st tw o fullscans o f the disk

  • 8/6/2019 Lecture 15 Device Management

    33/38

    Disk Arm S cheduling P o licies

    C ircular SC AN ( C - SC AN) : disk armalways serves requests by scanning ino ne directi o n.

    Once the arm finishes scanning f o r o nedirecti o nReturns t o the 0 th track f o r the next r o und o f

    scanning

  • 8/6/2019 Lecture 15 Device Management

    34/38

    First C o me, First S erve

    Request queue: 3, 6, 1, 0, 7Head start p o sitio n: 2

    To tal seek distance: 1 + 3 + 5 + 1 + 7 =17

    Tracks

    0

    5

    43

    2

    1

    6

    7

    Time

  • 8/6/2019 Lecture 15 Device Management

    35/38

    S ho rtest S eek Distance First

    Request queue: 3, 6, 1, 0, 7Head start p o sitio n: 2

    To tal seek distance: 1 + 2 + 1 + 6 + 1 =10

    Tracks

    0

    5

    43

    2

    1

    6

    7

    Time

  • 8/6/2019 Lecture 15 Device Management

    36/38

    S CAN

    Request queue: 3, 6, 1, 0, 7Head start p o sitio n: 2

    To tal seek distance: 1 + 1 + 3 + 3 + 1 = 9

    Time

    Tracks

    0

    5

    43

    2

    1

    6

    7

  • 8/6/2019 Lecture 15 Device Management

    37/38

    C- S CAN

    Request queue: 3, 6, 1, 0, 7Head start p o sitio n: 2

    To tal seek distance: 1 + 3 + 1 + 7 + 1 =13

    Time

    Tracks

    0

    5

    43

    2

    1

    6

    7

  • 8/6/2019 Lecture 15 Device Management

    38/38

    Loo k and C-L oo k

    S imilar t o S CAN and C- S CANthe arm g o es o nly as far as the final request in

    each directi o n, then turns ar o undLoo k f o r a request bef o re c o ntinuing t o m o ve in a

    given directi o n.