Download - CH11-IOawf Management and Disk Scheduling
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
1/21
C h a p t e r
1 1
I / O M
a n a g e m
e n t
a n
d D i s k S c h e d u l i n g
E i g h t h
E d i t i o n
B y W i l l i a m
S t a l l i n g s
O p e r a t i n g
S y s t e m s :
I n t e r n a
l s
a n d D e s i g n
P r i n c i p l e s
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
2/21
E x t e r n a l d e v i c e s t h a t e n g a g e i n I / O w i t h c o m
p u t e r
s y s t e m s
c a n b e g r o u p e d i n
t o t h r e e c a t e g o r i e s
:
• s u i t a b l e
f o r c o m m u n i c a t i n g w i t h t h e c o m p u t e r u s e r
• p r i n t e r s , t e r m i n a l s , v i d e o d i s p l a y , k e y b o a r d , m o u s e
H u m a n r e a d a b l e
• s u i t a b l e
f o r c o m m u n i c a t i n g w i t h e
l e c t r o n i c e q u i p m e n t
• d i s k d r i v
e s , U S B k e y s , s e n s o r s , c o n t r o l l e r s
M a c h i n e
r e a d a b l e
• s u i t a b l e
f o r c o m m u n i c a t i n g w i t h r e m o t e d e v i c e s
• m o d e m s , d i g i t a l l i n e d r i v e r s
C o m m u n
i c a t i o n
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
3/21
D e v i c e s
d i f f e r i n a n u m b e r o f a r e a s :
D a t a R a t e
• t h e r e m a y b e d i f f e r e n c e s o f m a g n i t u d e b e t w e e
n t h e d a t a t r a n s f e r r a t e s
A p p l i c a
t i o n
• t h e u s e t o w h i c h a d e v i c e i s p u t h a s a n i n f l u e n c e o n t h e s o f t w a r e
C o m p l e x i t y o f C o n t r o l
• t h
e e f f e c t o n t h e o p e r a t i n g s y s t e m i s f i l t e r e d b y t h e c o m p l e x i t y
o f t h e I / O m o d u l e t h a t c o n t r o l s t h e d e v i c e
U n i t o f T r a n s f e r
• d a t a m a y b e t r a n s f e r r e d a
s a s t r e a m o f b y t e s o r c h a r a c t e r s o r i n l a r g e r b l o c k s
D a t a R e p r e s e n t a
t i o n
• d i f f e r e n t d a t a e n c o d i n g s c h e m e s a r e u s e d b y d i f f e r e n t d e v i c e s
E r r o r C o n d i t i o n s
• t h e n a t u r e o f e r r o r s , t h e w a y i n w h i c h t h e y a r e r e p o r t e d , t h e i r c o n s e q u
e n c e s , a n d
t h e
a v a i l a
b l e r a n g e o f r e s p o n s e s d i f f e r s f r o m o n e d e v i c e t o a n o t h e r
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
4/21
K e y b o a r d 1 0
1
1 0 2
1 0 3
1 0 4
1 0 5
D a t a R a t e ( b p s )
1 0 6
1 0 7
1 0 8
1 0 9
M o u s e
M o d e m
E t h e r n e t
H a r d d i s k
G r a p h i c s d i s p l a y
G i g a b i t E t h e r n e t
F l o p p y d i s k
L a s e r p r i n t e r
S c a n n e r
O p t i c a l d i s k
F i g u r e 1 1 . 1 T y p i c a l I / O D e v i c e D a t a R a t e s
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
5/21
T h r e e t e c h n i q u e s f o r p e r f o
r m i n g I / O a r e :
P r o g r a m m
e d I / O
t h e p r o c e s s o r i s s u e s a n I / O c o
m m a n d o n b e h a l f o f
a p r o c e s s t o a n I / O m
o d u l e ;
t h a t p r o c
e s s t h e n b u s y w a i t s f o
r t h e o p e r a t i o n t o b e
c o m p l e t e d b e f o r e p r o
c e e d i n g
I n t e r r u p t - d r i v e n I / O
t h e p r o c e s s o r i s s u e s a n I / O c o
m m a n d o n b e h a l f o f
a p r o c e s s
i f n o n
- b l o c k i n g – p r o c e s s o r c o n t i n u e s t o e x e c u t e
i n s t r u c t i o n s f r o m t h e
p r o c e s s
t h a t i s s u e d t h e I / O c o m m a
n d
i f b l o c k i n g – t h e n e x t i n s t r u c t i o n t h e p r o c e s s o r e
x e c u t e s i s f r o m t h e O S , w h i c h
w i l l p
u t t h e c u r r e n t p r o c e s s i n a b l o c k e d s t a t e a n d s c h e d u l e a n o t h e r p r o c e s s
D i r e c t M e m o r y A c c e s s ( D M
A )
a D M
A m o d u l e c o n t r o l s t h
e e x c h a n g e o f d a t a b e t w e e n m a i n m e m o r y
a n d a n
I / O m
o d u l e
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
6/21
N o I n t
e r r u p t s
U s e o f I n t e r r u p t s
I / O - t o - m e m o r y
t r a n s f e r
t h r o u g h p r o c e s s o r
P r o g r a m m e d I / O
I n t e r r u p t - d r i v e n I / O
D i r e c t I / O - t o - m
e m o r y
t r a n s f e r
D i r e c t m e m o r y a c c e s s
( D M A )
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
7/21
1
• P r o c e s
s o r d i r e c t l y c o n t r o l s a
p e r i p h e r a l d e v i c e
2
• A c o n t r o l l e r o r I / O m o d u l e
i s a d d e d
3
• S a m e c o n f i g u r a t i o n a s s t e p 2 , b u t n o w i n t e r r u p t s
a r e e m p l o y e d
4
• T h e I /
O m o d u l e i s g i v e n d i r e c t c o n t r o l o f m e m o r y v i a D M A
5
• T h e I /
O m o d u l e i s e n h a n c e
d t o b e c o m e a s e p a r a t e p r o c e s s o r , w i t h
a s p e c i a l i z e d i n s t r u c t i o n s e t
t a i l o r e d f o r I / O
6
• T h e I /
O m o d u l e h a s a l o c a l m e m o r y o f i t s o w n a
n d i s , i n f a c t , a
c o m p u
t e r i n i t s o w n r i g h t
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
8/21
A d d r e s s
R e g i s t e r
C o n t r o l
L o g i c
D a t a
R e g i s t e r
F i g u r e 1 1 . 2 T y p i c a l D M A B l o c k D i a g r a m
D a t a
C o u n t
D a t a L i n e s
A d d r e s s L i n e s
R e q u e s t t o D M A
A c k n o w l e d g e f r o m D M A
I n
t e r r u p t
R e a d
W r i t e
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
9/21
P r o c e s s o r
D M A
( a ) S i n g l e - b u s , d e t a c h e d D M A
( b ) S i n g l e - b u s , I n t e g r a t e d D M A - I / O
( c ) I / O b u s
F i g u r e 1 1 . 3 A l t e r n a t i v e D M A C o n f i g u r a t i o n s
I / O b u s
S y s t e m b u s
I / O
I / O
M e m o r y
P r o c e s s o r
D M A
M e m o r y
I / O
I / O
I / O
P r o c e s s o r
D M A
D M A
I / O
I / O
I / O
M e m o r y
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
10/21
E
f f i c i e n c y
M a j o r e f f o r t i n I / O d e s i g n
I m p o r t a n
t b e c a u s e I / O
o p e r a t i o n
s o f t e n f o r m a
b o t t l e n e c k
M o s t I / O
d e v i c e s a r e e x t r e m e l y
s l o w c o m
p a r e d w i t h m a i n
m e m o r y a n d t h e p r o c e s s o r
T h e a r e a
t h a t h a s r e c e i v e d t h e
m o s t a t t e
n t i o n i s d i s k I / O
G e n e r a l i t y
D e s i r a
b l e t o h a n d l e a l l d e v
i c e s i n
a u n i f o r m m a n n e r
A p p l i e s t o t h e w a y p r o c e s s
e s v i e w
I / O d e v i c e s a n d t h e w a y t h e
o p e r a t i n g s y s t e m m a n a g e s
I / O
d e v i c e
s a n d o p e r a t i o n s
D i v e r s i t y o f d e v i c e s m a k e s i t
d i f f i c u
l t t o a c h i e v e t r u e g e n e r a l i t y
U s e a
h i e r a r c h i c a l , m o d u l a r
a p p r o a c h t o t h e d e s i g n o f t h e I / O
f u n c t i o n
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
11/21
F u n c t i o n s o f t h e o p e r a t i n g s y s t e m s h o u l d b e s
e p a r a t e d a c c o r d i n g t o
t h e i r c o m
p l e x i t y , t h e i r c h a r a c t e r i s t i c t i m e s c a l e , a n d t h e i r l e v e l o f
a b s t r a c t i o
n
L e a d s t o a n o r g a n i z a t i o n o f
t h e o p e r a t i n g s y s t e m i n t o a s e r i e s o f
l a y e r s
E a c h l a y e
r p e r f o r m s a r e l a t e d s u b s e t o f t h e f u n c t i o n s r e q u i r e d o f t h e
o p e r a t i n g
s y s t e m
L a y e r s s h o u l d b e d e f i n e d s o
t h a t c h a n g e s i n o n e l a y e r d o n o t r e q
u i r e
c h a n g e s i n o t h e r l a y e r s
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
12/21
U s e r
P r o c e s s e s
C o m m u n i c a t i o n
A r c h i t e c t u r e
D e v i c e
I / O
S c h e d u l i n g
& C o n t r o l
( b ) C o m m u n i c a t i o n s p o r t
F i g u r e 1 1
. 4 A M o d e l o f I / O O r g a n
i z a t i o n
H a r d w a r e
U s e r
P r o c e s s e s
L o g i c a l
I / O
D e v i c e
I / O
S c h e d u l i n g
& C o n t r o l
( a ) L o c a l p e r i p h e r a l d e v i c e
H a r d w a r e
U s e r
P r o c e s s e s
D i r e c t o r y
M a n a g e m e n t
F i l e
S y s t e m
P h y s i c a l
O r g a n i z a t i o n
D e v i c e
I / O
S c h e d u l i n g
& C o n t r o l
( c ) F i l e s y s t e m
H a r d w a r e
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
13/21
P e r f o r m i n p u t t r a n s f e r s i n a d v a n c e o f r e q u e s t s b e i n g m a d e a n d p e r f o r m
o u t p u t t r a
n s f e r s s o m e t i m e a f t
e r t h e r e q u e s t i s m a d
e
B l o c k - o r i e n t e d d e v i c
e
• s t o r e s i n f o r m a t i o n i n
b l o c k s t h a t a r e u s u a l l y o f
f i x e
d s i z e
• t r a n
s f e r s a r e m a d e o n e
b l o c k a t a t i m e
• p o s s i b l e t o r e f e r e n c e d
a t a
b y i t s b l o c k n u m b e r
• d i s k s a n d U S B k e y s a r e
e x a m p l e s
S t r e a
m - o r i e n t e d d e v i c e
• t r a n s f e r s d a t a i n a n d o u
t
a s a s
t r e a m o f b y t e s
• n o b l o c k s t r u c t u r e
• t e r m i n a l s , p r i n t e r s ,
c o m m
u n i c a t i o n s p o r t s ,
a n d m
o s t o t h e r d e v i c e s
t h a t a
r e n o t s e c o n d a r y
s t o r a g e a r e e x a m p l e s
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
14/21
N o
B u f f e r
W i t h
o u t a b u f f e r , t h e O
S
d i r e c t l y a c c e s s e s t h e d e
v i c e
w h e n i t n e e d s
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
15/21
S i n g l e B u f f e
r
O p
e r a t i n g s y s t e m a s s i g n s a
b u f f e r i n m a i n m e m o r y f o r
a n
I / O r e q u e s t
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
16/21
I n p u t t r a n
s f e r s a r e m a d e t o t h e s y s t e m b u f f e r
R e a d i n g a h e a d / a n t i c i p a t e d
i n p u t
i s d o
n e i n t h e e x p e c t a t i o n t h a t t h e b l o c k w i l l e v e n t u a l l y b e n e e d e d
w h e n t h e t r a n s f e r i s c o m p l e t e , t h e p r o c e s s m o v e s t h e b l o c k i n t o u s e r
s p a c e a n d i m m e d i a t e l y r e q u e s t s a n o t h e r b l o c k
G e n e r a l l y
p r o v i d e s a s p e e d u
p c o m p a r e d t o t h e l a c k o f s y s t e m b u f f e r i n g
D i s a d v a n t a g e s :
c o m p l i c a t e s t h e l o g i c i n t h e o p e r a t i n g s y s t e m
s w a p
p i n g l o g i c i s a l s o a f f e c t e d
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
17/21
L i n e - a t - a - t i m e o p e r a t i o n
a p p r
o p r i a t e f o r s c r o l l - m o
d e
t e r m
i n a l s ( d u m b t e r m i n a
l s )
u s e r
i n p u t i s o n e l i n e a t a
t i m e
w i t h a c a r r i a g e r e t u r n
s i g n a l i n g t h e e n d o f a l i n
e
o u t p
u t t o t h e t e r m i n a l i s
s i m i l a r l y o n e l i n e a t a t i m
e
B y t e - a t - a - t i m e o p e r a t i o n
u s e d o n f o r m s - m o d e
t e r m i n a l s
w h e n e a c h k e y s t r o k e i s
s i g n i f i c a n t
o t h e r p e r i p h e r a l s
s u c h
a s s e n s o r s a n d
c o n t r o l l e r s
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
18/21
D o u b
l e B u f f e r
U s e t w
o s y s t e m b u f f e r s i n s
t e a d
o f o n e
A p r o c e s s c a n t r a n s f e r d a t a t o o r
f r o m o
n e b u f f e r w h i l e t h e
o p e r a t i n g s y s t e m e m p t i e s o r f i l l s
t h e o t h e r b u f f e r
A l s o k
n o w n a s b u f f e r s w a p
p i n g
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
19/21
C i r c u l a r B u f f e r
T w o
o r m o r e b u f f e r s a r e u s e d
E a c h
i n d i v i d u a l b u f f e r i s
o n e
u n i t i n a c i r c u l a r b u f f e r
U s e d
w h e n I / O o p e r a t i o n m u s t
k e e p
u p w i t h p r o c e s s
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
20/21
-
8/18/2019 CH11-IOawf Management and Disk Scheduling
21/21
T e c h n i q u e t h a t s m o o t h e s o u
t p e a k s i n I / O d e m a n d
w i t h e n
o u g h d e m a n d e v e n t u a l l y a l l b u f f e r s b e c o
m e f u l l a n d t h e i r a d v a n t a g e
i s l o s t
W h e n t h e
r e i s a v a r i e t y o f I / O a n d p r o c e s s a c
t i v i t i e s t o s e r v i c e ,
b u f f e r i n g
c a n i n c r e a s e t h e e f f i c i e n c y o f t h e O S
a n d t h e p e r f o r m a
n c e o f
i n d i v i d u a l p r o c e s s e s