32
1 Review Fig 5-5 Interrupts Handling Bus

1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

  • View
    215

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

1

Review

Fig 5-5 Interrupts Handling

Bus

Page 2: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

2

Review

Fig 5-11 Logical Position of Device Drivers

Page 3: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

3

Review

Figure 5-16 Layers of I/O Systems

Page 4: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

4

Review

Figure 5-4: Operation of a DMA transfer, the DMA controller has access to the system bus independent of the

CPU

Page 5: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

5

5.4 Disk Hardware

• Disks are characterized by the fact that reads and writes are equally fast, ideal for secondary memory.

• Arrays of disks are used to provide highly-reliable storage.

• Optical disks are important for distribution of programs, data, and movies.

Page 6: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

6

Magnetic Disks

• Some magnetic disks have little electronics and just deliver a simple serial bit stream. On these disks, the controller does most of the work.

• On other disks, particularly IDE (Integrated Drive Electronics) disks, the drive itself contains a microcontroller that does some work and allows the real controller to issue high-level commands.

• Overlapped seeks: A controller does seeks on two or more drives at the same time.– Many controller can read and write on one drive while seeking on

one or more other drives.

– However, only one transfer between the controller and the main memory is possible.

Page 7: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

7

Magnetic Disks

Disk parameters for the original IBM PC floppy disk and a Western Digital WD 18300 hard disk

Page 8: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

8

Structure of a Disc Drive

Page 9: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

9

Disk Hardware

Physical geometry of a disk with two zones (in 18G hard disc (WD18300), there are 162 zones)

32 sectors per track

16 sectors per track

A possible virtual geometry for this disk. Mapping from virtual to real parameters is

needed.

Page 10: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

10

RAID (Redundant Array of Independent Disks)

• Raid levels 0 through 2 (note: no hierarchy among levels)

• Backup and parity drives are shaded

4bit data, 3bit Hamming code

for error correction

Distributing data over multiple drives is called striping.

Disk mirroring

Page 11: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

11

RAID• RAID level 0 works best with large requests, the bigger the better. RAID

level 0 works worst with OS that habitually ask for one sector at a time.– The reliability of RAID level 0 is potentially worse than SLED (Single Large

Expensive Disk).

• RAID level 1 duplicates all the disks.– Write performance is no better, but read performance can be up to twice as

good

• RAID level 2 works on a word basis, even a byte basis. Parity bits of a Hamming code are bits 1, 2, and 4. Imagine the seven drives of Fig 5-19(c) were synchronized on arm position and rotation position.– This only makes sense with a substantial number of drives. (high overhead)

Why?

Page 12: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

12

RAID

• Raid levels 3 through 5• Backup and parity drives are shaded

even or odd parity for 1 bit error correction

Like RAID 0, with strip-for-strip parity written to

an extra drive.

Page 13: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

13

RAID

• RAID level 3 is a simplified version of RAID level 2.

• RAID levels 4 and 5 work with strips again, not individual words with parity, and do not require synchronized drives.

• RAID level 4 performs poorly for small updates. If one sector is changed, it is necessary to read all the drives to recalculate the parity. Slight improvement can be obtained by reading the old user data and old parity data and recompute the new parity from them. Heavy load on the parity drive.

• RAID level 5 distributes the parity bits uniformly over all the drives. However, in the event of a drive crash, reconstructing the contents of the failed drive is complex.

Skip CD-ROMS, .. From p

310 to 315

Page 14: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

14

Disk Formatting

A disk sector after low–level format.

With the overhead of preamble, ECC, intersector gap, spare sectors, often the formatted capacity is 20% less than the unformatted capacity.

Start of sector bit pattern (to recognize the start of the sector), Cylinder number,Sector number

Error correcting

code, about 16 bytes

Before the disk can be used, each platter must receive a low-level format. The format consists of a series of concentric tracks, each containing someNumber of sectors, with short gaps between the sectors.

Page 15: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

15

Disk Formatting

An illustration of cylinder skew, meaning the position of sector 0 on each track is offset from the previous track to accommodate rotation latency

Page 16: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

16

Cylinder skew example

• For a 10,000 rpm (rotations per minute) drive, one rotation takes sec

• If a track contains 300 sectors, a new sector passes under the head every

• If track to track seek time is 800 μsec , then the disk needs a cylinder skew of

• Data rate

3

6010000

1 106

63

1020300

106

4020

800

7

31056.2

106

512300

Page 17: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

17

Disk Formatting

(a) No interleaving To allow time for ECC calculation and transferring data to main memory:

(b) Single interleaving (c) Double interleaving

In many modern controllers, to avoid the need for interleaving, the controller buffers an entire track.

Page 18: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

18

Partition

• Sector 0: (master boot record) containing some boot code plus the partition table at the end, which gives the starting sector and size of each partition. To be able to boot from the hard disk, one partition must be marked as active in the partition table.

• High-level format of each partition: lays down a boot block, the free storage administration (free list or bitmap), root directory, and an empty file system. It also puts a code in the partition table entry telling which file system is used in the partition.

Page 19: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

19

Disk Arm Scheduling Algorithms

• Time required to read or write a disk block determined by 3 factors

1. Seek time

2. Rotational delay

3. Actual transfer time

• Seek time dominates

• Error checking is done by controllers

• Many disk drivers maintain a table, indexed by cylinder number, with all the pending requests for each cylinder chained together in a linked list headed by the table entries.

Page 20: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

20

Disk Arm Scheduling Algorithms

(2) Shortest Seek First (SSF) disk scheduling algorithm: totally 61 cylinders

With a heavily loaded disk, the arm will tend to stay in the middle of the disk most of the time. Not fair.

(1) First Come First Served: With initial position at 11, pending requests at 1, 36, 16, 34, 9, 12, total arm motions are 111 cylinders

Initial

position

Pending requests

Page 21: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

21

Disk Arm Scheduling Algorithms

(3) The elevator algorithm for scheduling disk requests: totally 60 cylinders. The upper bound on the total motion is fixed. (4) Variation of the elevator algorithm: always scan in the same direction to have smaller variance in response time.

Page 22: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

22

Disk Arm Scheduling Algorithms

• If the disk has the property that the seek time is much faster than the rotation delay, then pending requests should be sorted by sector number, and as soon as the next sector is about to pass under the head, the arm should be zipped over to the right track to read/write it.

• Many disk controllers always read and cache multiple sectors in the controller’s cache memory, even when only one is requested. In its simplest mode, the cache is divided into two sections, one for reads and one for writes.

• Disk controller’s cache is independent of the OS’s cache. What is the difference?

• Other issues: myltiple drives, real geometry vs. virtual geometry

Many are not actually read

Page 23: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

23

Error Handling

Bad sectors do not correctly read back the value just written to it. If the defect can not be covered by ECC, the error can not be masked.

Two approaches to bad blocks: deal with them in the controller and deal with them in the OS.

Page 24: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

24

Error Handling

• Controller handling of bad sectors (in initial shipment)

a. A disk track with a bad sector

b. Substituting a spare for the bad sector

c. Shifting all the sectors to bypass the bad one

Page 25: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

25

Error Handling

• Errors can develop after the drive is installed. If ECC cannot handle, the first thing is try the read again. If it is getting repeated errors on a certain sector, it can switch to a spare before the sector has died completely. Usually Fig5-29(b) has to be used.

• OS handling of bad sectors– Must make sure bad sectors do not occur in any

files and do not occur in any free list or bitmap. One way is done by creating a secret file containing all the bad sectors.

Page 26: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

26

Error Handling

• Problems:– Backup: If the disk is backed up sector by sector rather

than file by file, it is difficult to prevent read errors during backup. The only hope is the backup program is smart enough to give up after 10 failed reads and continue with the next sector.

– mechanical problems: When the arm gets to its destination, the controller reads the actual cylinder number from the preamble of the next sector. If the arm is in a wrong place, a seek error has occurred.

• Most hard disk controller correct seek error automatically. Most floppy controllers let the drive handle the error by issuing a recalibrate command, to move the arm as far as it will go and reset the controller’s internal idea of the current cylinder to 0.

Page 27: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

27

Error Handling

– Disk usually has a pin on the chip which forces the controller to forget whatever it was doing and reset itself. If all else failed, the disk driver can set a bit to invoke this signal and reset the controller.

– In systems with real-time constraints, like video or CD-ROM recording, recalibration inserts gaps into the bit stream and are unacceptable. Special drives, which never recalibrate are available for such applications.

Page 28: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

28

Stable Storage

• Stable storage: When a write is issued, the disk either correctly writes the data, or it does nothing, leaving the existing data intact.

• Basic Assumption– When a disk writes a block with error, the error could

be detected on a subsequent read by examining ECC.

– Having the same sector go bad on a second (independent) drive during a reasonable time interval is small enough to ignore.

– CPU can fail, in which case it just stops.

Page 29: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

29

Stable Storage

• Uses a pair of identical disks with the corresponding blocks working together to form one error-free block. In the absence of errors, the corresponding blocks on both drives are the same.

• The following three operations are defined:– Stable writes: first writing the block on drive 1, the reading it

back to verify. If not correctly, retry up to n times until one works. After n consecutive failures, try a spare sector until it succeeds. After the write to disk 1 has succeeded, the corresponding disk on drive 2 is written in the same way.

Page 30: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

30

Stable Storage

– Stable reads: First read from drive 1. If failed with an incorrect ECC, the read is tried again, up to n times. If all failed, the corresponding block is read from drive 2.

– Crash recovery: If a pair of blocks are both good and the same, nothing needs to be done. If one of them has an ECC error, the bad block is overwritten by the other good block. If both are good but different, the block from drive 1 is written onto drive 2.

Page 31: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

31

Stable Storage

Analysis of the influence of crashes on stable writes

Page 32: 1 Review Fig 5-5 Interrupts Handling Bus 2 Review Fig 5-11 Logical Position of Device Drivers

32

Stable Storage

• Improvements:– Keep track of which block was being written in nonvolatile RAM

during a stable write so that only one block has to be checked during recovery. The stable write can put the number of the block it is about to update in nonvolatile RAM before starting the write.

– If nonvolatile RAM is not available, at the start of the stable write, a fixed disk block on drive 1 is overwritten with the number of the block to be stably written. This block is then read back to verify it. After getting it correct, the corresponding block on drive 2 is written and verified.

– Once a day, a complete scan of both disks must be done repairing any damage. Then even if both blocks go bad within a period of a few days, all errors are repaired correctly.