Docsity

Operating Systems and Hard Disk Drives, Lecture notes of Operating Systems

Toggle sidebar
bg1
TCSS 422: Operating Systems [Spring 2017]
Institute of Technology, UW-Tacoma
06/01/2017
Slides by Wes J. Lloyd L18.1
Hard D isk Dr ive s
Wes J. Ll oyd
Ins titut e o f Tech nolog y
Univer sity of W ash ing ton - Taco ma
TCSS 422: OPERATING SYSTEMS
Cha pte r 37
HDD Inter nals
See k time
Rota tiona l laten cy
Tran sfer sp eed
Cap acity
Sch edulin g algo rithms
June 1, 2017
TCSS422: Operating Systems [Spring 2017]
Institute of Technology, University of Washington -Tacoma
L18.2
OB JECTI VE S
Pri mar y me ans of d ata stor age (per sis tenc e) fo r de cad es
Con sis ts of a larg e nu mber of data se ctor s
Se ctor siz e is 512 -byt es
An n se cto r HD D
can be is a ddr esse d as an arra y of 0.. n-1 sect ors
June 1, 2017
TCSS422: Operating Systems [Spring 2017]
Institute of Technology, University of Washington -Tacoma
L18.3
HARD DI SK DRI VE ( HD D)
Wri ting dis k se ctor s is ato mic (51 2 byt es)
Se ctor writ es a re c omp lete ly su cce ssfu l, o r fa il
Man y fi le s yste ms w ill rea d/wr ite 4 KB a t a time
Linu x ext3 /4 de fault f ilesy stem bl ocksiz e – 40 96
Sam e a s ty pica l me mor y pa ge s ize
June 1, 2017
TCSS422: Operating Systems [Spring 2017]
Institute of Technology, University of Washington -Tacoma
L18.4
HDD INT ER FACE
mke fs.e xt4 -i b ytes -per -ino de
Spe cif y the b ytes /in ode r ati o. mke 2fs c rea tes an i nod e for
eve ry by tes -per -in ode b ytes of s pac e on th e dis k. The
lar ger t he by tes -per -in ode r ati o, the fewe r ino des w ill be
cre ate d. Th is val ue ge ner all y sho uld n't be s mal ler th an
the blo cks ize o f the f ile syst em, s inc e in tha t cas e mor e
ino des w oul d be ma de th an can e ver b e use d. Be wa rne d
tha t it i s not p oss ible to exp and t he num ber of in odes on
a fi les yste m af ter i t is cr eat ed, s o be ca ref ul de cid ing t he
cor re ct val ue fo r thi s pa ram ete r.
June 1, 2017
TCSS422: Operating Systems [Spring 2017]
Institute of Technology, University of Washington -Tacoma
L18.5
BLO CK SIZE IN L INUX EX T4
Hos t ~2 ,00 0,00 0 fi les tota ling 9.5 GB on a ~20 GB
fil esy stem on a clo ud- base d Vi rtua l Ma chin e
Wit h d efau lt in ode rati o (4 096 bloc k si ze) ,
onl y ~4 88, 000 file s wi ll f it
Dr ive l ess tha n ha lf f ull, but fil es w ill not fit !
HD Ds su ppo rt a min imum blo ck s ize of 5 12 b ytes
OS fil esys tems such as ext3 /ex t4 ca n s uppo rt “ fine r
gr aine d” ma nag emen t at the exp ense of a la rger cat alog
siz e
June 1, 2017
TCSS422: Operating Systems [Spring 2017]
Institute of Technology, University of Washington -Tacoma
L18.6
EX AMP LE: USDA S OI L EROSI ON M ODEL
WE B SER VICE ( RU SLE2)
pf3
pf4
pf5

Partial preview of the text

Download Operating Systems and Hard Disk Drives and more Lecture notes Operating Systems in PDF only on Docsity!

Institute of Technology, UW-Tacoma

Hard Disk Drives

Wes J. Lloyd

Institute of Technology

University of Washington - Tacoma

TCSS 422: OPERATING SYSTEMS  Chapter 37  HDD Internals  Seek time  Rotational latency  Transfer speed  Capacity  Scheduling algorithms June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

OBJECTIVES

 Primary means of data storage (persistence) for decades  Consists of a large number of data sectors  Sector size is 512-bytes  An n sector HDD can be is addressed as an array of 0..n-1 sectors June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

HARD DISK DRIVE (HDD)

 Writing disk sectors is atomic (512 bytes)  Sector writes are completely successful, or fail  Many file systems will read/write 4KB at a time  Linux ext3/4 default filesystem blocksize – 4096

 Same as typical memory page size

June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

HDD INTERFACE

 mkefs.ext4 -i bytes-per-inode

Specify the bytes/inode ratio. mke2fs creates an inode for every bytes-per-inode bytes of space on the disk. The larger the bytes-per-inode ratio, the fewer inodes will be created. This value generally shouldn't be smaller than the blocksize of the filesystem, since in that case more inodes would be made than can ever be used. Be warned that it is not possible to expand the number of inodes on a filesystem after it is created, so be careful deciding the correct value for this parameter. June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

BLOCK SIZE IN LINUX EXT

 Host ~2,000,000 files totaling 9.5 GB on a ~20GB filesystem on a cloud-based Virtual Machine  With default inode ratio (4096 block size), only ~488,000 files will fit  Drive less than half full, but files will not fit!  HDDs support a minimum block size of 512 bytes  OS filesystems such as ext3/ext4 can support “finer grained” management at the expense of a larger catalog size June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

EXAMPLE: USDA SOIL EROSION MODEL

WEB SERVICE (RUSLE2)

Institute of Technology, UW-Tacoma

 Free space in bytes (df)

Device total size bytes- used bytes- free usage /dev/vda2 13315844 9556412 3049188 76% /mnt

 Free inodes (df –i) @ 512 bytes / node

Device total inodes used free usage /dev/vda2 3552528 1999823 1552705 57% /mnt June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

EXAMPLE: USDA SOIL EROSION MODEL

WEB SERVICE (RUSLE2) - 2

 Torn write  When OS uses larger block size than HDD  Block writes not atomic - they SPAN multiple HDD sectores  Upon power failure only a portion of the OS block is written  HDD access  Sequential reads of sectors is fastest  Random sector reads are slow  Disk head continuously must jump to different tracks June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

HDD INTERFACE - 2

June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

HDD PLATTER

 Made from aluminum coated with thin magnetic layer  HDD records on both sides of each platter  Data is stored by inducing magnetic changes June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

HDD SPINDLE

 Connected to motor which spins the disk  Speed measures in RPM (rotations per minute)  Typical: 7200-15000 rpm  10000 rpm – 1 rotation in 6ms; 15k rpm 1 rotation in 4ms

 Concentric circle of sectors
 Single side of platter contains 290 K tracks (2008)
 Zones: groups of tracks with same # of sectors

June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

HDD TRACK

Outer tracks have More sectors  Single track disk  Head: one per surface of drive  Arm: moves heads across surface of platters June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

EXAMPLE: SIMPLE DISK DRIVE

Institute of Technology, UW-Tacoma

June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

TRACK SKEW - 2

 Buffer to support caching reads and writes  Improves drive response time  Up to 128 MB, slowly have been growing  Two styles  Writeback cache  Report write complete immediately when data is transferred to HDD cache  Dangerous  Writethrough cache  Reports write complete only when write is physically completed on disk June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

HDD CACHE

 I/O Time  The rate of I/O June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

TRANSFER SPEED

 Random workload: 4KB random read on HDD  Sequential workload: read 100MB contiguous sectors June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

I/O SPEED

There is a huge gap in drive throughput between random and sequential workloads  See sample HDD configurations here:  https://www.hgst.com/products/hard-drives June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

MODERN HDD SPECS

 Disk scheduler: determine how to order I/O requests  Multiple levels - OS and HW  OS: provides ordering  HW: further optimizes using intricate details of physical HDD implementation and state June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

DISK SCHEDULING

Institute of Technology, UW-Tacoma

 Disk scheduling – which I/O request to schedule next  Shortest Seek Time First (SSTF)  Order queue of I/O requests by nearest track June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

SSTF – SHORTEST SEEK TIME FIRST

 Problem 1: HDD abstraction  Drive geometry not available to OS. Nearest-block-first is a comparable alternate algorithm.  Problem 2: Starvation  Steady stream of requests for local tracks may prevent arm from traversing to other side of platter June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

SSTF ISSUES

 SWEEP  Single repeated passes across disk  Issue: if request arrives for a recently visited track it will not be revisited until a full cycle completes  F -SCAN  Freeze request queue during sweep  Cache arriving requests until later  Elevator (C-SCAN) – circular scan  Sweep from outer to inner track and reverse, inner to outer track, etc. June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

DISK SCHEDULING ALGORITHMS

 Determine next
sector to read?
 On which track?
 On which sector?

June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

SHORTEST TIME POSITIONING FIRST

On modern drives, both seek and rotation are roughly equivalent: Thus, SPTF (Shortest Positioning Time First) is useful.

 Group temporary adjacent requests
 Reduce overhead
 Read (memory blocks): 33 8 34
 How long we should wait for I/O?
 When do we know we have waited too long?

June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.

I/O MERGING

QUESTIONS

June 1, 2017 TCSS422: Operating Systems [Spring 2017] Institute of Technology, University of Washington - Tacoma L18.