netw 3005 mass storage (how discs work). notice i was unaware just how much was missing in the...

49
NETW 3005 Mass Storage (How discs work)

Upload: aron-mccormick

Post on 01-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

NETW 3005

Mass Storage(How discs work)

Page 2: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Notice

• I was unaware just how much was missing in the printed notes.

• As a partial remedy for that, the lecture slides will appear on the web within the next week.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 2

Page 3: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Reading

• For this lecture, you should have read Chapter 12 (Sections 1-4).

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 3

Page 4: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Last lecture: I/O systems

• Hardware: ports, buses, controllers

• Application I/O interface

• Kernel I/O services

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 4

Page 5: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

This lecture: How disks work

• The mechanics of disks

• Disk scheduling

• Formatting and booting

• Disk reliability: bad blocks, RAIDs

• Swap space management

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 5

Page 6: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

The mechanics of disks

• A disk drive consists of– a number of platters– with two surfaces each– arranged on a rotating spindle– with a head for each surface.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 6

Page 7: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Some terminology

• A single disk platter has two surfaces.

• Each surface is organised into concentric circles called tracks.

• All tracks of the same radius form a cylinder.

• Each track is divided into sectors.

• A sector is the smallest addressable part of the disk.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 7

Page 8: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

The mechanics of disks

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 8

Page 9: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Addressing

• Information on the disk is referenced by a multi-part address which includes:– drive number,– cylinder number,– surface number and,– sector number.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 9

Cylinders are vertically formed by tracks. In other words, track 12 on platter 0 plus track 12 on platter 1 etc. is cylinder 12. The number of cylinders of a disk drive exactly equals the number of tracks on a single surface in the drive.

Page 10: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Access time has two major components

•Seek time is the time taken to move the heads to the cylinder containing the desired sector.

•Rotational latency is the time taken to rotate the desired sector to the disk head.

Page 11: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

More terminology

• The heads all move together, accessing a cylinder of the disk.

• To access a particular sector, the heads are moved to the appropriate cylinder, the correct head is enabled, and the head waits until the correct sector comes under it.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 11

Page 12: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Disk scheduling

• kernel’s I/O subsystem schedules pool of pending I/O requests .

• Imagine a queue of I/O requests to a given disk.

• Ordering these requests in different ways will result in different head seek times.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 12

Page 13: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Algorithms for disk scheduling• Criteria for evaluating algorithms:

– Seek time

– Fairness (in particular, starvation)

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 13

1. FCFS

2. Shortest seek-time first scheduling

3. SCAN

4. C SCAN

5. C LOOK

Page 14: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

FCFS scheduling

• Treat I/O requests in FCFS order.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 14

Calculation of the seek time for the schedule givenon the next slide(98 - 53) + (183 - 98) + (183 - 37) + (122 - 37) + (122 - 14) + (124 - 14) + (124 - 65) + (67 - 65) = 640 cylinders

Here we do not calculate the time but only the numberof cylinders' the head is moving – that gives us the distancewhich is directly proportional to seek timei.e if the distance is increasing seek time is also increasing

Page 15: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 15

Illustration shows total head movement of 640 cylinders.

Page 16: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Advantages and disadvantages?

• Advantages?– no starvation: every request is serviced – Simple to implement.

• Disadvantages?

– big swing in head seek.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 16

Page 17: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Shortest seek-time first scheduling

• At any moment, choose the request with the shortest distance from the current head position.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 17

Page 18: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 18

Illustration shows total head movement of 236 cylinders.

Page 19: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Advantages and disadvantages?

• Advantages?– You get much shorter seek times this way,

because you’re eliminating the big swings. (At least, you’ll only get them if there’s nothing closer.)

• Disadvantages?– Starvation is a possibility.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 19

Seek time for SSTF is calculated as follows:(65 - 53) + (67 - 65) + (67 - 37) + (37 - 14) + (98 - 14) + (122 - 98) + (124 - 122) + (183 - 124) = 236 this is some many cylinder movements not time

Page 20: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

SCAN scheduling

• Start the disk at one end, and move right to the other end, servicing all the I/O requests you get to on your way. Then start in the other direction.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 20

Page 21: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 21

Illustration shows total head movement of 208 cylinders.

Page 22: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

•(53 - 37) + (37 - 14) + (65 - 14) + (67 - 65) + •(98 - 67) + (122 - 98) + (124 - 122) + (183 - 124)

•= 208

Page 23: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Advantages and disadvantages?

• Advantages?– Avoids starvation

• Disadvantages?– Requests for the middle of the disk are

advantaged over those at the ends.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 23

Page 24: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

C-SCAN scheduling

• Like SCAN, but when the head gets to one end, it goes straight to the other end without servicing any requests.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 24

Page 25: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 25

C-SCAN scheduling

Page 26: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Advantages and disadvantages?

• Advantages?– No region of the disk are favored.

• Disadvantages?

requires one long seek after finished going up

have to go back to the beginning

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 26

C-SCAN scheduling

Page 27: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

C-LOOK scheduling

• Like C-SCAN, except that rather than going to the ends of the disk, we only go as far as the furthest request in each direction.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 27

Page 28: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 28

Page 29: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Advantages and disadvantages?

• Advantages?– No region of the disk are favored

• Disadvantages?

more inclined to serve the middle cylinder requests

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 29

Page 30: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Comparison of Disk Scheduling Algorithms

Page 31: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Priority scheduling

• We might not want to treat all these requests as equal, e.g. page-fault- generated requests might need to be handled first.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 31

Page 32: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Selecting a Disk-Scheduling Algorithm • FCFS- Ideal for LOW Load Disk Schedule.

• SSTF – ideal for Linked and indexed allocation technique to reduce the head seek time.

• SCAN and C-SCAN- ideal for heavy load on the disk.

• C – scan is ideal for contiguous allocation technique

• Either SSTF or LOOK reasonable choice for the default algorithm.

Page 33: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Where should index blocks be stored?

• Near the blocks containing the file’s data.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 33

Where should directories be stored?•In the middle of the partition is a good idea, so you never have more than half the disk to scan.•Or near the FAT.•Best to cache recently-used directory info as well.

Page 34: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Disk formatting• Low-level formatting: normally done in

the factory.

• Creates the sectors on the disk, and fills each with an initial data structure:– A header and trailer, containing information

used by the disk controller - e.g. sector number, error-correcting code (ECC).

– A data area (usually 512 bytes).

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 34

Header

Sector No

Data ( 512 bytes) Trailer( ECC)

Page 35: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Disk formatting

• Partitioning: done by the operating system.

• Logical formatting: making an (empty) file system.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 35

File System

NTFS FAT 32

Page 36: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Bad blocks• A bad sector is a sector on a computer's disk

drive that cannot be used due to permanent damage .

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 36

Bad blocks are blocked in the FAT – table

The Controller maintains list of bad blocks and spare blocks right from Low Level formatting .

Controller can replace each bad sector with one of the spare sector

Page 37: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Problems with sparing?• Sector sparing could invalidate any

optimization by the operating systems disk scheduling algorithm

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 37

•Sector slipping: shuffling all the data on disk to make room for the spare block right next to the one it’s replacing.

•Provision of spare sectors in each cylinders

Page 38: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Error recovery and RAIDs• RAID is the organization of multiple disks

into a large, high performance logical disk.

• Each block of data is broken into sub-blocks, with one sub-block stored on each disk.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 38

Page 39: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

RAIDs

• Mirroring: each disk holds all the data.

• Block interleaved parity. A parity bit for the group of sub-blocks is written to a special parity block. If one of the sub- blocks is lost, it can be recovered from the other sub-blocks plus the parity block.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 39

Page 40: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

10011100 01101100 11110000

11110000 10011100 =01101100

Page 41: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Primary Boot

strap loader

Secondary boot loader

LOADS THE OS INTO THE MAIN

MEMORYLOADS

Booting a system

Page 42: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Swap space management•Swap space holds entire process or page or segment which

Is swapped out to the backing store from main memory

Swap space implementation

File Systemswap space is simply

a large file within file system

Special raw partition swap space

Is Blocks in the raw partition

Navigating takes moreTime

Speed of access is better than file system

•Some OSs can swap in both file space and raw swap partitions, e.g. Solaris 2.

Page 43: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Next Lecture

!Revision!Make sure you come along(Exam hints are possible)

Page 44: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Is SSTF optimal?• No – it is too short-sighted, i.e. no look-

ahead.

• It is possible to develop an optimal algorithm, but the time taken to calculate it means it’s not really worth it.

• For example if the head moves to 37 then 14 and then 65, 67 and so on seek time will be less

• (53 - 37) + (37 - 14) + (65 - 14) + (67 - 65) + (98 - 67) + (122 - 98) + (124 - 122) + (183 - 124) = 208

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 44

Page 45: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

1 xor 1 = 0 1 xor 0 = 1 0 xor 0 = 0 1110 xor 1001 = 0111

Page 46: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

7 bits of data(number of 1s)

8 bits including parity

even odd

0000000 (0) 00000000 10000000

1010001 (3) 11010001 01010001

1101001 (4) 01101001 11101001

1111111 (7) 11111111 01111111

Page 47: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Booting a system

• In fact, the initial program is often very small.

• Often it just loads a bigger bootstrap program, and this program does the rest.

• The program will be stored at a fixed location on the disk, called the boot block.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 47

Page 48: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Swap-space management

• memory management often uses a backing store to hold data from processes being multitasked.

• We could implement swap space simply as a file within a directory structure.

• Problems with this approach?

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 48

Page 49: NETW 3005 Mass Storage (How discs work). Notice I was unaware just how much was missing in the printed notes. As a partial remedy for that, the lecture

Swap-space management

• A more frequent solution is to create a special partition for swap space.

• The disk allocation algorithm on this partition is optimised for speed, rather than memory efficiency.

• Some OSs can swap in both file space and raw swap partitions, e.g. Solaris 2.

NETW3005 (Operating Systems) Lecture 11 - How discs work/44 49