Вы находитесь на странице: 1из 27

Boot Camp Session 1

Module: COS 122


Author: Mr. Werner Hauger
Objectives
• Review the key concepts of Chapter
11:
– Understand the different I/O
techniques.
– Understand the different disk drive
parameters
– Understand the various disk
scheduling algorithms.
– Understand the different RAID levels
COS 122 November 4, 2019 2
I/O Function

I/O Techniques
No Interrupts Use of Interrupts

I/O-to-memory transfer Programmed I/O Interrupt-driven I/O


through processor

Direct I/O-to-memory Direct memory access (DMA)


transfer

COS 122 November 4, 2019 3


DMA I/O Technique
Data
• CPU sends command Count

with the following info: Data Lines Data


Register
1. Read/Write using read
or write control line Address
Address Lines Register
2. Address of I/O device
using data lines Request to DMA
Acknowledge from DMA
Control
3. Starting location of Interrupt
Logic
Read
memory to read/write Write

using data lines


4. Number of words to
read/write via data lines
Figure 11.2 Typical DMA Block Diagram
COS 122 November 4, 2019 4
Disk Layout

Disk Data Layout


COS 122 November 4, 2019 5
Disk Layout cont.

Disk Cylinder
COS 122 November 4, 2019 6
Disk Performance
• Seek time
– Time required for the head to reach the
appropriate track
• Rotational delay
– Time required for the beginning of the
appropriate sector to reach the head
• Access time = seek + rotational delay
• Transfer time
– Time required to transfer requested data
– T = b/(r*N); b -> # bytes to transfer; r ->
rotation speed (rps); N -> # bytes on a track
COS 122 November 4, 2019 7
Exercise 1 – Disk Performance
• Consider the following fixed sector disk: 512
bytes/sector, with 128 sectors/track, 110
tracks per surface, and 8 usable surfaces.
Assume that the disk rotates at 3600 rpm
and has an average seek time of 6ms.
a) What is the average rotational delay (ard) of this
disk?
b) What is the average access time of this disk?
c) What is the transfer time to read 1 MB (1048576
bytes) of data stored sequentially from this disk
(ignore ard)?
d) What is the total time required to read 1 MB of
data from this disk?

COS 122 November 4, 2019 8


Disk Scheduling algorithms
Name Description Remarks
Selection according to requestor
Random Random scheduling For analysis and simulation
FIFO First in first out Fairest of them all
PRI Priority by process Control outside of disk queue
management
LIFO Last in first out Maximize locality and
resource utilization
Selection according to requested item
SSTF Shortest service time first High utilization, small queues
SCAN Back and forth over disk Better service distribution
C-SCAN One way with fast return Lower service variability
N-step-SCAN SCAN of N records at a time Service guarantee
FSCAN N-step-SCAN with N = queue Load sensitive
size at beginning of SCAN
cycle

COS 122 November 4, 2019 9


FIFO Algorithm
• First In, First Out
• Processes I/O requests in sequential order
• Adv: Fair to all processes
• Dis: Approaches random scheduling
performance with many competing
requests
0
25
50
track number

75
100
125
150
175
199
(a) FIFO Time
0 COS 122 November 4, 2019 10
25
SSTF Algorithm
0
25

• Shortest Service Time First


50
track number

75

• Selects the next I/O request that


100
125
150 requires the least movement of the
175
199
disk arm from its current position
• 0 Chooses minimum seek time
(a) FIFO Time

25
50
track number

75
100
125
150
175
199
(b) SSTF Time
0 COS 122 November 4, 2019 11
25
r
SCAN (no LOOK) Algorithm
• Known as the elevator algorithm
• Arm moves in one direction only
– satisfies all outstanding requests until
it reaches the last track in that
direction (0 or max); then the direction
is reversed

COS 122 November 4, 2019 12


SCAN Algorithm
• Improvement of the previous algorithm
• Arm moves in one direction only
– satisfies all outstanding requests until
there are no more requests in that
direction; then the direction is reversed

COS 122 November 4, 2019 13


C-SCAN (no LOOK) Algorithm
• Circular SCAN algorithm
• Restricts scanning to one direction only
– satisfies all outstanding requests until it reaches
the last track in that direction; then arm is returned
to the opposite end of the disk (0 or max) and then
scan begins again at first track in same direction

COS 122 November 4, 2019 14


125

tra
150
175
C-SCAN Algorithm
199
(b) SSTF Time
0
25
• Improvement of the previous algorithm
track number

50
75
• Restricts scanning to one direction only
100
– satisfies all outstanding requests until there are no
125
150
more requests in that direction; then arm is returned
175
199
to the opposite end of the disk and scan begins
again at first I/O request
(c) SCANin same direction Time
0
25
track number

50
75
100
125
150
175
199
(d) C-SCAN Time
COS 122 November 4, 2019 15
Figure 11.7 Comparison of Disk Scheduling Algorithms (see Table 11.3)
Exercise 2 – Disk Scheduling
• Consider a disk drive with 200 tracks, numbered
0 to 199. The request queue has the following
composition:
176, 79, 34, 60, 92, 11, 41, 114
• The current head position is track 50 and the
previous I/O request was served at 40. Compute
the total and average distance (in tracks) that
the disk arm would move using the following
algorithms:
a) FIFO
b) SSTF
c) SCAN
d) C-SCAN
COS 122 November 4, 2019 16
RAID Levels
• Redundant Array of Independent
Disks
• Seven levels: 0 to 6
• 3 common design characteristics:
– Set of physical disks seen as single
logical drive by the OS
– Data is distributed across the physical
disks as strips => striping
– Redundant capacity is used to store
parity information to guarantee
recoverability in case of disk failure

COS 122 November 4, 2019 17


RAID Parity
• Parity calculated using XOR function:
– 0 XOR 0 = 0
– 0 XOR 1 = 1
– 1 XOR 0 = 1
– 1 XOR 1 = 0
• Example with 4 data disks (B0 to B3)
and 1 parity disk P:
a) Parity calculation for ith bit:
– P(i) = B3(i) XOR B2(i) XOR B1(i) XOR B0(i)
b) Recovery calculation for e.g. B1:
– B1(i) = B3(i) XOR B2(i) XOR B0(i) XOR P(i)
COS 122 November 4, 2019 18
RAID Level 0
• Not true RAID because no redundancy
• Data divided into strips distributed
across all disks
• Improve performance with reduced I/O
queue time due to parallel access
strip 0 strip 1 strip 2 strip 3
strip 4 strip 5 strip 6 strip 7
strip 8 strip 9 strip 10 strip 11
strip 12 strip 13 strip 14 strip 15

(a) RAID 0 (non-redundant)


COS 122 November 4, 2019 19
RAID Level 1
• Redundancy by duplication
• Adv: Data can be read from mirror
strip 0 strip 1 strip 2 strip 3
strip 4 strip 5 strip 6 strip 7
disk in case of failure; no write
strip 8 strip 9 strip 10 strip 11
penalty because parallel updates
strip 12 strip 13 strip 14 strip 15

• Dis: Costly in disks (2x)


(a) RAID 0 (non-redundant)

strip 0 strip 1 strip 2 strip 3 strip 0 strip 1 strip 2 strip 3


strip 4 strip 5 strip 6 strip 7 strip 4 strip 5 strip 6 strip 7
strip 8 strip 9 strip 10 strip 11 strip 8 strip 9 strip 10 strip 11
strip 12 strip 13 strip 14 strip 15 strip 12 strip 13 strip 14 strip 15

(b) RAID 1 (mirrored)

COS 122 November 4, 2019 20


strip 8 strip 9 strip 10 strip 11
strip 12 strip 13 strip 14 strip 15

RAID Level 2
(a) RAID 0 (non-redundant)

•stripParallel
0 strip 1
access
strip 2
with smallstripdata
strip 3 0
strips
strip 1 strip 2

•stripHamming
4 strip 5 Code
strip 6 forstripbit
7 error
strip 4correction
strip 5 strip 6
strip 8 strip 9 strip 10 strip 11 strip 8 strip 9 strip 10
•stripMultiple
12 strip 13 parity
strip 14disksstripe.g.
15 HC(7,4)
strip 12 =13 3 disks
strip strip 14

• Dis: Costly in disks; overkill except when


high
(b) RAID number of disk errors
1 (mirrored)

b0 b1 b2 b3 f0(b) f1(b) f2(b)

(c) RAID 2 (redundancy through Hamming code)


COS 122 November 4, 2019 21
Figure 11.8 RAID Levels (page 1 of 2)
RAID Level 3
• Single redundant disk; XOR parity bit
• Parallel access with small strips
• Adv: High data transfer rates
• Dis: Single I/O request at a time

b0 b1 b2 b3 P(b)

(d) RAID 3 (bit-interleaved parity)


COS 122 November 4, 2019 22
RAID Level 4
• Single redundant disk; XOR parity block
• Independent
b 0 b b
access with blarge strips
1 P(b) 2 3

• Dis: Write penalty -> 2 reads + 2 writes;


I/O bottleneck on parity disk
(d) RAID 3 (bit-interleaved parity)

block 0 block 1 block 2 block 3 P(0-3)


block 4 block 5 block 6 block 7 P(4-7)
block 8 block 9 block 10 block 11 P(8-11)
block 12 block 13 block 14 block 15 P(12-15)

(e) RAID 4 (block-level parity)


COS 122 November 4, 2019 23
(d) RAID 3 (bit-interleaved parity)

RAID Level 5
block 0 block 1 block 2 block 3 P(0-3)
block 4 block 5 block 6 block 7 P(4-7)
• Distributed
block 8
parity block
block 9 block 10 block 11 P(8-11)
• Round-robin
block 12 block allocation
13 block 14 block 15 P(12-15)

• Adv: Any single disk failure = no data


loss; no4 (block-level
(e) RAID potential parity) I/O bottleneck

block 0 block 1 block 2 block 3 P(0-3)


block 4 block 5 block 6 P(4-7) block 7
block 8 block 9 P(8-11) block 10 block 11
block 12 P(12-15) block 13 block 14 block 15
P(16-19) block 16 block 17 block 18 block 19

(f) RAID 5 (block-level distributed parity)


COS 122 November 4, 2019 24
(e) RAID 4 (block-level parity)

RAID Level 6
block 0 block 1 block 2 block 3 P(0-3)
block 4 block 5 block 6 P(4-7) block 7
• block
2 8parityblockblocks
9
on different
P(8-11) block 10
disks
block 11
•block
Adv:
12 Extreme
P(12-15) high
block 13 data
block 14availability
block 15

– 3 or more
P(16-19) block 16 block 17
disk failuresblock
= 18data block
loss 19

• Dis: Substantial write penalty


(f) RAID 5 (block-level distributed parity)
– 2 parity algorithms on two disks
block 0 block 1 block 2 block 3 P(0-3) Q(0-3)
block 4 block 5 block 6 P(4-7) Q(4-7) block 7
block 8 block 9 P(8-11) Q(8-11) block 10 block 11
block 12 P(12-15) Q(12-15) block 13 block 14 block 15

(g) RAID 6 (dual redundancy)


COS 122 November 4, 2019 25

Figure 11.8 RAID Levels (page 2 of 2)


Exercise 3 – RAID
a) The following 4 nibbles are to be stored on a 5
disk RAID 3 array:
1111, 1110, 1100, 1000
Calculate the parity bit for each of the nibbles.
b) A single data disk failure has occurred in a 5
disk RAID 4 array. The block size is 1 byte. The
remaining 3 data bytes of the 4 byte blocks are
as follows:
B0 = 10101010, B1 = 11110000,
B3 = 11001100
The corresponding parity byte is: 11111111.
What is the lost byte from the missing disk?

COS 122 November 4, 2019 26


Conclusion
• Bootcamp Session 2:
– Today @ 13:00
• Exam (EO3):
– 9 November 2019
– 12:00
• Supplementary:
– 2 December 2019
– 15:30

Good Luck!
COS 122 November 4, 2019 27

Вам также может понравиться