Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 71

1

1.1

/
1.2

1.3

I/O I/O

1.4
I/O
1.5

1.6

1.7

1.8 I/O
I/O I/O I/O

I/O I/O I/O


I/O I/O

DMA I/O DMA

1.9

1.10

2.1

2.2

2.3

2.4

2.5

I/O
2.6

2.7

2.8

I/O
2.9

2.10

3
3.1

3.2
3.1
3.3 3.6

I/O

3.4

3.5

3.6 3.9b

2*2
3.7 4
1.
2.

3.

4.
3.8
I/O
3.9

3.10

3.11
1.2.3.4.5.

3.12
I/O

3.13
I/O
3.14

4
4.1 3.5

3.5
ID

4.2
3

4.3
4.4
4.5
4.6

1.

2.

3.

4.7
1.

2.

4.8 jacketing
Jacketing I/O I/O

4.9 4.8
SIMD

MIMD/

SMP

4.10 SMP

4.11

4.12

API

4.13

4.14
IPC I/O
4.15

5
5.1

5.2

5.3

5.4

ID
I/O
ID
5.5

5.6

5.7
1.

2.
3.
4.
5.
6.
5.8
1.
2.wait 1 wait 3signal
1 0 wait
5.9
0 1
5.10

5.11 .

5.12

5.13 -
1.
2.
3.

6.1
/

/
6.2

6.3

6.4

6.5

6.6

6.7

7
7.1

7.2

7.3

7.4

7.5

7.6

7.7

7.8

7.9

1.
2.

8.1

8.2

8.3

8.4

P
M
8.5
TLB

8.6

8.7
12

8.8 FIFO Clock


7

FIFO
8.9
1
2 I/O

8.10

8.11

8.12

9.1

9.2

9.3

9.4
UNIX WINDOWS

9.5
I/O

9.6 FCFS

9.7

FCFS
9.8

9.9
SPN
8

9.10
R R=(w+s)/s,w s

9.1 1
RQ0
RQ1

FCFS

10

10.1

10.2

10.3
FCFS

FCFS

10.

10.5

T T
10.6

10.7

10.8

11

I/O

11.1 I/O
I/O I/O I/O

I/O I/O I/O I/O


I/O

DMA DMA I/O


DMA
11.2 I/O I/O
I/O I/O I/O
I/O

10

I/O I/O

11.3

11.4 I/O

11.5

11.6 11.7
FIFO:
SSTF: I/O
SCAN:

C-SCAN: SCAN
11.7 7 RAID
0
1
2

3 RAID3

4
5
6
11.8
512

12.1
field
record
12.2
file
database

12.3

12.4

12.5
11

12.6

12.7

12.8

12.9
noneknowledgeexecution(reading)appending
updatingchanging protectiondeletion
12.10
fixed blocking

variable-length spanned blocking

variable-length unspanned blocking

12.11

13.1

13.2

13.3

13.4

12

13.5 TCP/IP
/TCP/IPTCP/IP

13.6
API TCP/IP

14 /
14.1 /
/

14.2 /
1

4
14.3 TCP/IP /

14.4

14.5

14.6 pros cons

14.7 /

13

14.8

14.9 TCP/IP
TCP/IP API
14.10

14.11

14.12

14.13

15
15.1

15.2
Eagerall
precopy

Eagerdirty
14


copy-on-reference Eagerdirty

flushing

15.3

15.4

15.5

15.6

19443
16.1

16.2

16.3

16.4
ID

16.5
subject

object
16.6 16.6 salt
salt

4096
DES
15

16.7

16.8 1999 2000 VBS Melissalove letter

16.9

16.10
-

16.11 DES DEA


DES NIST DES
(DEA) DEA , DEA
16.12 AES DEA
AES TDEA , AES ,
16.13 AES

16.14
,

16.15

1.1 1.3 I/O


0011 = I/O AC
0111 = AC I/O
12 1.4
1. 5 AC
2. 940
3. AC 6
5 3940 2
16 300300530159403027006
13005>IR 23>AC
16

35940>IR 4325>AC
57006>IR 6AC> 6
1.2 6 1.4 MAR MBR
1. a. PC 300 MAR
b. 300 1940 MBR PC 1

c. MBR IR
2. a. IR 940 MAR
b. 940 MBR
c. MBR AC
3. a. PC 301 MAR
b. 301 5941 MBR PC 1
c. MBR IR
4. a. IR 941 MAR
b. 941 MBR
c. AC 941 AC
5. a. PC 302 MAR
b. 302 2941 MBR PC 1
c. MBR IR
6. a. IR 941 MAR
b. AC MBR
c. MBR 941
1.4 16 16
16
a. 16
b. 8
c. I/O
d. 8 I/O 8 I/O
(a)(b)216 = 64K bytes
811616
(c)I/O

(d)28 = 25628 = 256


16I/O,

1.5 32 16 8MHz
4
21

1/8MHZ125ns
4125ns500ns
500ns 2 4MB/s

/ 32
17

1.6 I/O /CPU

INPR8
OUTR8
FGI1
FGO1
IEN1
I/O 8
8 8

a. CPU 4 /
b. IEN
a. INPR FGI0 INPR
INPR FGI 1CPU FGI FGI1CPU
INPR AC FGI 0
CPU FGO FGO0CPU FGO
1CPU AC OUTER FGO 0 FGI
1
b.A CPU FGI FGO
CPU IEN CPU

1.7 DMA DMA


?
,
DMA()
DMA
1.9 CPU I/O D M
1 CPU 106 5 3
/ 1 CPU
95% I/O 1 1 M D

a. I/OI/O 1 CPU D I/O

b. DMA
a. 5 I/O. I/O 10e60.0550000 /
I/O 25000 /
b. DMA
10e60.0550.9522.1510e6
DMA
I/O
1.10
for ( i = 0i < 20i++)
for (j = 0j < 10j++)
a[i] = a[i]*j
a.
b.
18

a.
b. a[i]
1.11 1A 1.11.2 n

Ci = i
Si = i
Ti = i
Hi = i
Bi = i+1 i
12N
n

CS

C S
i

i 1
n

S
i 1

Ts x

i Pr[ x 1]
i 1

Ts Ti H i
i 1

M1M2M1
M2M1T2 = B1+T1
T3 = B2+T2 = B1+B2+T1
Ti

Ts

i 2

H
i 1

i 1

B
j 1

T1

i 1

j 1

i 1

( B j H i ) T1 H i

Ts
i 2

i 1

(B H ) T
j 1

1.12
Tc = 100 ns
Cc = 0.01 /
Tm = 1200 ns
Cm = 0.001 /
a.1MB
b.1MB
c. 10% H
a. = Cm8106 = 8103 = 80
b. = Cc8106 = 8104 = 800
c. 1.1 1.1T1 = T1+(1-H)T2
(0.1)(100) = (1-H)(1200)
19

H=1190/1200
1.13
20ns
60ns
12ms 60ns
0.9 0.6
ns

ns

0.9

20

0.10.6= 0.06

60+20 = 80

0.10.4= 0.04

12ms+60+20 = 12,000,080

Avg = (0.9)(20) + (0.06)(80) + (0.04)(12000080) = 480026 ns


1.14

2.1 T
I/O N
I/O
=
= T
=
T 1 2 4
a. I/O
b. I/O
ab I/O

=NT
=50

=NT
=100

=2N-1NT =100
2.2 I/O I/O

I/O
I/O

2.3

2.4 ?

20


2.5 IBM OS/390 System Resource
Manager,SRMSRM OS/390
SRM
I/O SRM I/O
SRM
SRM

SRM
SRM 20
1SRM
SRM

3
3.1.

3.2.

3.3.
3.4.

[PINK89]

[PINK89]

3.9b 7 3.8b
9.3
3.9b/
/
1 2
21

3.5.

/
/
3.13 VAX/VMS
a.
b.

c.

a.

b.

c.

3.6.

VAM/VMS

VMS I/O


CHM
REIReturn from Exception or
Interrupt
a.
b.

22

a.

b.
3.7. VMS 3.18 3.3 /
[SILB04]
Dj Di
j<i Di Dj
a.
b.

a. j<i Di Dj Dj Di

Dj Dj Di
Di
b. 16
3.8. 3.7b
a.
b.

a.

b.

3.9.

A
B A A
A [BRIN73]
3.10. 3.4 UNIX

4
4.1.

4.2.

4.3.

1
2

OS/2
23

4.4.

4.5.

4.6.

4.7.

PC

OS/2 3 2

a.
b.

a. /

b. /

I/O

[LEWI96]

[LEWI96]
OS/390

ASCB OS/390
ASCB
TCB

ASCB TCB

8 20
4 3
3 4

a. 4 4

b.

24

a.

4.8.

20/4=5
5

b.
20/3=6 0 2
Advanced Computer Architectrue,K.Hwang,1993.
Solaris

[LEVI96]

5
5.1
b. read rs squash
Read squash

sp print print 125

5.2 p qA.B.C.D E
parbegin
Void p()
void q()
{ A;
{ D;
B;
E;
C;
}
}
ABCDE;ABDCE;ABDEC;ADBCE;ADBEC;ADEBC;DEABC;DAEBC;DABEC;DABCE;
5.3
const int n=50;
int tally;
void total()
{ int count;
for(count =1;count <=n;count ++)
{tally++;
}
}
void main()
{
tally =0;
parbegin(total(),total();
write(tally);
}
a.,tally [50,100], 0 50.
, tally
25

tally .,,,
:
1. A tally ,tally 1,( 1,
).
2. B tally ( 0), 49 , 49
tally ,.
3. A ( 1 49 tally ),
.
4. B , 1( tally ),( B
).
5. A ,, 49 ,,
tally 50.
6. B . 2,
.
2 ,. tally [2,100].
b. N ,tally [2,N*50],,
. B .
5.4.
,.,,
,,,,
.
5.5
boolean blocked[2];
int rurn;
void P(int id)
{
While (true)
{
While(turn!=id);
{
While(blocked[1-!id]
/*do nothing*/;
Turn =id;
}
}
Void main ()
{
Blocked[0]=false;
Blocked[1]=false;
Turn=0;
Parbegin(P(0),P(1));
}
HYMA66
: turn=0, P(1) blocked[1] true, blocked[0]
false, P(0) true blocked[0]
, turn=0,P(0),P(1) 1 turn ,.
26

5.6 lamport bakery

Boolean choosing[n];
Int number[n];
While (true)
{
Choosing[i]=true;
Number[i]=1+getmax(number[],n)
Choosing[i]=false;
For(int j=0;j<n;j++)
{
While (choosing[j])
{}
While ((number[j]!=0)&&(number[j],j)<(number[i],i)
{}
}
/*critical section*/
Number[i]=0;
/*remainder*/;
}
choosing number false 0 i i
ab<cd
aca=c b<d
A

a.,.
, 1 .
.,.
, 0.
b.,,.,.
c.,: Pi ,Pk number[k],
,: ( number[i], i ) < ( number[k], k ).,
:
Tw1:Pi choosing[k], j=k,, Tw1 choosing[k] = false.
Tw2:Pi , j=k, while , Tw1 < Tw2.
Tk1:Pk repeat ;Tk2:Pk number[k];
Tk3: Pk choosing[k] false . Tk1<Tk2<Tk3.
Tw1 ,choosing[k]=false, Tw1<Tk1, Tk3<Tw1. ,
number[i]<number[k], Pi Pk ;., Tk2 < Tk3 <
Tw1 < Tw2, Tk2<Tw2. Tw2 ,Pi number[k]., Tw2 j=k
while ,(number[i], i ) < ( number[k], k),.
. Pi ,Pk .Pk , number[i]
0,( number[i], i ) < ( number[k], k ).
5.7 5.2
27

testset n-1 turn n


turn
[SILB98]
var j: 0..n-1;
key: boolean;
repeat
waiting[i] := true;
key := true;
while waiting[i] and key do key := testset(lock);
waiting[i] := false;
< critical section >
j := i + 1 mod n;
while (j i) and (not waiting[j]) do j := j + 1 mod n;
if j = i then lock := false
else waiting := false;
< remainder section >
Until
var waiting: array [0..n 1] of boolean
Lockboolean
waiting
5.8
Void semWait(s)
{
If (s.count>0)
{
s.count--;
}
Else
{
Place this process in s.queue;
Block;
}
}
Void semSignal(s)
{
If (there is at liast one process blocked on semaphore)
{
Remove a process P from s.queue;
Place process P on ready list;
}
Else
s.count++;
}
5.3

28

5.3

5.9 semWaitB semSignalB


delay mutex
Void semWait(semaphor s)
{
semWaitB(mutex);
s--;
if (s<0)
{
semSignalB(mutex);
semWaitB(delay);
}
Else
Semsignalb(mutex)
}
Void semSignal(semaphore s);
{
semWaitB(mutex);
s++;
if(s<=0)
semSignalB(delay);
semSignalB(mutex);
}
S semwait 1 semsignal
1. mutex 1 s delay
0
s
0 semwait s , semsignalb mutex
semwaitbdelay semwaits.
s 0 semWait s
semSignalBmutex semWaitBdelay semWaits
s=-2 mutex semSignals
semsignalbdelay semsignalb
semWait end else semSignal
semWait semSignalB(mutex)semSignal semSignalb(mutex)

5.10 1978 dijkstra


1979 j.m.morris
semwaits
semsignals s
semwaits
A B 1 M NANM 0.
A M NA NM A
A M M NM

29

[RAYN86]
var a, b, m: semaphore;
na, nm: 0 +;
a := 1; b := 1; m := 0; na := 0; nm := 0;
semWait(b); na na + 1; semSignal(b);
semWait(a); nm nm + 1;
semwait(b); na na 1;
if na = 0 then semSignal(b); semSignal(m)
else semSignal(b); semSignal(a)
endif;
semWait(m); nm nm 1;
<critical section>;
if nm = 0 then semSignal(a)
else semSignal(m)
endif;
5.11
m n

n
m n
p v semwait semsignal
Resource Jurassic_Park()
Sem car_avail:=0,car_taken:=0,car_fillde:=0.passenger_released:=0
Process passenger(i:=1 to num_passengers)
Do true->nap(int(random(1000*wander_time)))
P(car avail);V(car_taken);P(car_filled)
P(passenger_released)
Od
End passenger
Process car(j:=1 to num_cars)
Do true->V(car_avail);P(car_taken);V(car_filled)
Nap(int(random(1000*ride_time)))
V(passenger_released)
Od
End car
End Jurassic_Park
. process car V(passenger_released)
, P(passenger_released) V().
5.12 5.9 5.3 s
5.3

Producer

Consumer

delay

SemWaitB(S)

n++

30

If(n==1)
(semSignalB(delay))

semSignalB(s)

semWaitB(delay)

semWaitB(s)

n--

semWaitB(s)

If(n==0)
(semWaitB(delay))

10

5.13 5.10 /

append;semSignal;produce;append;semSignal
consume;take;semWait;consume;take;semWait;

n -1
5.10 m

[BEN82]
program producerconsumer;
var n: integer;
s: (*binary*) semaphore (:= 1);
delay: (*binary*) semaphore (:= 0);
procedure producer;
begin
repeat
produce;
semWaitB(s);
append;
n := n + 1;
if n=0 then semSignalB(delay);
semSignalB(s)
forever
end;
procedure consumer;
begin
repeat
semWaitB(s);
take;
n := n 1;
if n = -1 then
begin

31

semSignalB(s);
semWaitB(delay);
semWaitB(s)
end;
consume;
semSignalB(s)
forever
end;
begin (*main program*)
n := 0;
parbegin
producer; consumer
parend
end.
5.14 5.13.
a.semWait(e);semWait(s)
b.semSignal(s);semSignal(n)
c.semWait(n);semWait(s)
d.semSignal(s);semSignal(e)
s

5.15 5.12/ n-1

a.
b.
n

A
Out
in
out=in
D

In
out
out=in+1.in 1 out=in
bcount
5.16
1 2

iuxunlu unlu

santa: reindeer: elf: sleigh: toys:

32

5.17
a.
b.
b.[TANE97].
wait signal WAITHUO SIGNAL. RECEIVE

SIGNALs
0 WAITs
WAIT 0 WAIT
SIGNAL

33

..a

: :

....
.Q B , B A. P ,
2. Q B P A. Q B P

3. Q B P A. Q
B A. P B
4. P Q B. P A. Q
B. P B B
5. P A. P B. Q Q
,
6. P B. Q ,
..
Q B P, Q ,
P Q, Q , P A Q
Q B,
r1
0
2
0
2
0

r2
0
0
0
3
3

r3
1
0
3
5
3

r4
2
0
4
4
2

r1
0
2
6
4
0

r2
0
7
6
3
6

r3
1
5
5
5
5

r4
2
0
6
6
2

r1

r2

r3

r4
.

r1

r2

r3

r4

a
b
c
d
e0100

34

a. 0 0 0 0
0 7 5 0
6 6 2 2
2 0 0 2
0 3 2 0
b.p1, p4, p5,
p2, p3.
c. P1 P1

d.P2,P3,P4,P5
e. P1,P4,P5 4698P2,P3

. .

Available=(2
2 0 0 1
Request= 1 0 1 0
2 1 0 0
1.
2.
3.
4.

W = (2 1
Mark P3;
Mark P2;
Mark P1;

0)
0 0 1
Allocation= 2 0
0 1 2

0
0 1
0

0 0)
W = (2 1 0 0) + (0 1 2 0) = (2 2 2 0)
W = (2 2 2 0) + (2 0 0 1) = (4 2 2 1)
no deadlock detected

i+o
max
maxi o

1.
2.

3.
IPP

35

PI
..

(reso),

+
max
max reso
0 < reso < max
P , O reso, P
P O
I/O; ,
O ,

maxipo
resoresp

+ + max
+ max resp
+ max reso
max (reso + resp)

.
.
.
.
.
.
a
b.

1. i i + 1
2.
3.
4.
5.
6.

ii 1; p p + 1
pp 1; oo + 1
o o 1
pp + 1
p p 1

b. 6.7 ,
:
6.

36

5. (p= max reso)


4.
3. reso
2.
1. , i= o=0,
( p < max reso)
:

1
2
3

70
60
60

45
40
15

a
b
a.425154045=12525
1234
b.415

1
70
45
25
15
2
60
40
20
3
60
15
45
4
60
35
25
.
: ,

.12n1,
a.i(0in-1)

Repeat

Forever
0n-1
b.
ar buffer: array 0..max-1 of shared T;
available: shared array 0..n-1 of 0..max;
"Initialization"
var K: 1..n-1;
region available do
begin

37

available(0) := max;
for every k do available (k) := 0;
end
"Process i"
var j: 0..max-1; succ: 0..n-1;
begin
j := 0; succ := (i+1) mod n;
repeat
region available do
await available (i) > 0;
region buffer(j) do consume element;
region available do
begin
available (i) := available(i) 1;
available (succ) := available (succ) + 1;
end
j := (j+1) mod max;
forever
end
b.
P0 waits for Pn-1 AND
P1 waits for P0 AND
. . . . .
Pn-1 waits for Pn-2

(available (0) = 0) AND


(available (1) = 0) AND
. . . . .
(available (n-1) = 0)
max > 0,

claim(1)+ claim(2)+ +claim(n)


< available(1)+available(2)++available(n)
=max
.a.

b.
+
a. 2 1

b. X X-1
M-N(X1)
M-N(X1)1 XM+N-1,
M+N
.
38

C =

3
2
9
7

A=

1
1
3
2

.1 2

a,
1.

,
(),
, ; ,
,
2.


3.
,
,,

4.
, ,
b
1.

2.
,

; O(n m)
O(n)-
3.

39

O(n)
4.
, ,
,
.

.
.
begin
repeat
think;
wait(fork[(i+1)mod5]);
wait(fork[i]);
eat;
signal(fork[i]);
signal(fork[(i+1)mod5]);
forever;
end;
a
b
a D
Pj Pj , Pk

b
Pj Pj Pj Pj
Pi Pi
, , Pi
Pi
Pj Pj ,Pj
Pk ,, Pk Pk
Pj ; Pk

...
..

40

monitor dining_controller;
enum states{thinking,hungry,eating} state[5];
cond needFork[5] /*condition variable*/
void get_forks(int pid) /*pid is the philosopher id number*/
{
start[pid]=hungry; /*announce that I am hungry*/
if(state[(pid+1)%5]= =eating
||(state[(pid-1)%5]= =eating
cwait(needFork[pid]); /*wait if either neighbor is eating*/
state[pid]=eating; /*proceed if neither neighbor is eating*/
}
void release_fork(int pid)
{
state[pid]=thinking;
/*give right(higher)neighbor a chance to eat*/
if(state[(pid+1)%5])= =hungry)
&(state[(pid+2)%5])!=eating)
csignal(needFork[pid+1]);
/*give left(lower)neighbor a chance to eat*/
else if(state[(pid-1)%5]= =hungry)
||(state[(pid-2)%5!=eating]
csignal(needFork[pid-1]);
}

void philosopher[k=0 to 4] /*the five philosopher clients*/


{
while(true)
{
<think>;
get_forks(k); /*client requests two forks via monitor*/
<eat spaghetti>;
release_forks(k); /*client releases forks via the monitor*/
}
}

..Linuxatomic_read
(atomic_t *v).
,
,

.Linux

41

read_lock(&mr_rwlock);
write_lock(&mr_rwlock);
mr_rwlock
,
,
.abLinux
1
a = 3
mb( )
---

2
--c = b
rmb()
d = a

, cb , db , c 4
(), d 1.()mb() a b , rm
b() c d

7
7.1. 2.3 5 7.1 5
: ;
;
;
;
.
7.2. 2e16 2e24

:224/216 = 28. 8
28
7.3.
: n h ., 0.5,
. s
s/2..
7.4. 7.2

: s s/2
s/4
7.5.

42

7.6.
40MB20MB
10MB
a.
b.
c.
d.

a. 40M 2 , 80M. 20M . 20M. 10M


120M
b. 40M,20N,10M 230M,20M 160M.

c. 40M,20M,10M 80M,120160M.

d. 40M,20M,10M, 80M,230M,360M.

7.7. 1MB
a. 7.6 70 35 80
A 60 B D C
b. B

a.

b.

43

7.8.

011011110000.
a. 4
b. 16

a. 011011110100
b. 011011100000
7.9. buddyk(x) 2k x buddyk(x)

Fabonacci
F0=0,F1=1,Fn+2=Fn+1+Fn,n0
a.
b.

a. Fn = Fn-1 + Fn-2.
b.

7.11.

7.8

7.10.

44

7.12. 232 210 216

a.
b.
c.
d.
e. /

a. 216*210=226
b. ,210 .
c. 232/210=222, 22
d. ,, 216
e. / 23
7.13. a pw p w z
p w z a
a = pz + w p = a/z, a/z w = Rz(a) a z
7.14.

660

248

1752

442

222

198

996

604

a. 0198
b. 2256
c. 1530
d. 3444
e. 0222

a. 0 660, 660+190=858.
b. 222+156=378
c. 1 422,
d. 996+444=1440
e. 660+222=882.
7.15. S1,S2,Sn
Sn+1 S1,S2,Sn Sn+1 Sn

a. F
F(1-f)/1+kf), k=t/2s-1
s l f

45

b. f=0.2t=1000s=50 F

a. , t ., t
,, s/t . t0 ,t0=fmr/s, m=
,(1-f)m ,

2(1-f)m.

F F=1-t0/(t0+tc)
b. K=(t/2s)-1=9;F(1-0.2)/(1+1.8)=0.29

8.1 0
1024

0
1
1
0
4
1
1
1
1
7
2
0
0
0

3
1
0
0
2
4
0
0
0

5
1
0
1
0
a CPU
b
i1052
ii2221
iii5499

b:(i)1052=1024+28
7 7*1024+28=7196
(ii)2221=2*1024+173
(iii)5499=5*1024+379 0 379
8.2 32 1KB 32

a
b
c

a 232/210= 222 22 bit


210/4=28 22bit 8 bit

b 28 26
c 26 26
28 214 28 1+26+214
=16,449 26 1+28+214 =16,641
26 1+28+216 =65,973

46

8.3 a 8.4
b 8.4
20 6
3

a4Mbyte
b26+2=128 20+20+8bits=48bits=6bytes
128*6=768bytes
8.4 4 0

RM

R
M

2
0
60
161
0
1
1
1
130
160
1
0
0
2
26
162
1
0
3
3
20
163
1
1
4
a.FIFO
b.LRU
c.Clock
d.
e.
4,0,0,2,4,2,1,0,3,2
4

a: 3 20
b: 1 160
c: 3 R 2 R 0
R 0
d: 3 3
e: 6

8.5 5 A,B,C,D E
A;B;C;D;A;B;E;A;B;C;D;E

9 10 Beladys "An Anomaly in Space-Time

47

Characteristics of Certain Programs Running in a Paging Machine," by Belady et al,


Communications of the ACM, June 1969.
8.6 8 4

1,0,2,2,1,7,0,1,2,0,3,0,4,5,1,5,2,4,5,6,7,6,7,2,4,2,7,3,3,2,3
a. LRU 4

b. FIFO a
c. FIFO
LRU

a:LRU=16/33

b:FIFO=16/33

c:
8.7 VAX

1
2

8.8
for(i=1;in;i++)
a[i]=b[i]+c[i];
1000 n=1000

4000
4000 R11 i
4001 R1n R2 n
4002 R2R1 in
4003 4009
4004 R3BR1 R1 B[i]
4005 R3R3+CR1 R1 C[i]
4006 AR1R3 R1 A[i]
4007 R1R1+1 i
48

4008 4002
60006999 A
70007999 B
80008999 C
9000 1
9001 n

494944474846494441000
11.000 5
8.9 IBM System/370
370
2KB 4KB 64KB 1MB370

S/370 S/370
P
8.10 4KB 4 64

4bytes 4Kbytes 1024=210


210212=222bytes 264bytes
210 232

1
222bytes
2
232bytes
3
242bytes
4
252bytes
5
262bytes
6
272bytes
264bytes
5 64 6 6 2
10 72
64 4
4

8.11
a. 200ns
b. MMU 20ns 85%
MMU TLB
c. TLB

a.400ns200ns 200ns
b.
2200.85+4200.15=250
TLB 200ns 20ns

49

TLB 200ns
TLB
c.TLB 200ns

8.12 M P
N
a.
b.

a.N
b.P
8.13

a.8.2
b.

a.

b.

8.14 S/370

1 1

0 1

8.15
12345213323454511325
k Sk=1/kWtt=1k
k Mk=1/kFtt=1k
t Ft=1 Ft=0
a.=123456 8.19

b. S20
b. M20

a.

50

b.c.

S20 M20
8.16 VSWS Q
Q
Q
Q

[PIZZ89] Q
Q

Q Q
Q
Q
8.17 4 8
2KB
a.
b.
c. 00021ABC

51

a.82K=16k
b.16K4=64K
c.232=4GBytes

8.18 32 2KB 1MB

a.
b.
c.

a.

52

5
11
b.32 9 bits
c. 32 8bits
8.19 UNIX
C
10KB
UNIX

9.1

12

9.5 9.5

FCFS

RR, q=1 RR, q=4 SPN SRT HRRN


Feedback, q=1 Feedback, q=2(i)
A
B
C
D
E
Ta
0
1
3
9
12
Ts
3
5
2
5
5
FCFS
Tf
3
8
10
15
20
Tr
3.00
7.00
7.00
6.00
8.00
Tr/Ts
1.00
1.40
3.50
1.20
1.60
RR q = 1
Tf
6.00
11.00
8.00
18.00
20.00
Tr 6.00 10.00 5.00 9.00 8.00 7.60
Tr/Ts
2.00
2.00
2.50
1.80
1.60
RR q = 4
Tf
3.00
10.00
9.00
19.00
20.00

53

6.20
1.74

1.98

Tr
3.00
9.00
6.00
10.00
8.00
Tr/Ts
1.00
1.80
3.00
2.00
1.60
SPN
Tf
3.00
10.00
5.00
15.00
20.00
Tr
3.00
9.00
2.00
6.00
8.00
Tr/Ts
1.00
1.80
1.00
1.20
1.60
SRT
Tf
3.00
10.00
5.00
15.00
20.00
Tr
3.00
9.00
2.00
6.00
8.00
Tr/Ts
1.00
1.80
1.00
1.20
1.60
HRRN
Tf
3.00
8.00
10.00
15.00
20.00
Tr
3.00
7.00
7.00
6.00
8.00
Tr/Ts
1.00
1.40
3.50
1.20
1.60
FB q = 1
Tf
7.00
11.00
6.00
18.00
20.00
Tr
7.00
10.00
3.00
9.00
8.00
Tr/Ts
2.33
2.00
1.50
1.80
1.60
FB
Tf
4.00
10.00
8.00
18.00
20.00
q = 2i
Tr
4.00
9.00
5.00
9.00
8.00
Tr/Ts
1.33
1.80
2.50
1.80
1.60
9.2 9.1

7.20
1.88
5.60
1.32
5.60
1.32
6.20
1.74
7.40
1.85
7.00
1.81

A
B
Ta 0
1
Ts 1
9
FCFS
Tf 1.00
Tr 1.00
Tr/Ts
RRq=1
Tf
Tr
Tr/Ts
RRq=4
Tf
Tr
Tr/Ts

C
D
2
3
1
9
10.00
11.00
20.00
9.00
9.00
17.00
9.00
1.00
1.00
9.00
1.89
1.00
18.00
3.00
20.00
1.00
17.00
1.00
17.00
1.00
1.89
1.00
1.89
1.00
15.00
6.00
20.00
1.00
14.00
4.00
17.00
1.00
1.56
4.00
1.89

54

3.22
9.00
1.44
9.00
2.11

SPN

Tf
1.00
10.00
11.00
20.00
Tr
1.00
9.00
9.00
17.00
9.00
Tr/Ts
1.00
1.00
9.00
1.89
3.22
SRT
Tf
1.00
11.00
3.00
20.00
Tr
1.00
10.00
1.00
17.00
9.00
Tr/Ts
1.00
1.11
1.00
1.89
1.25
HRRN
Tf
1.00
10.00
11.00
20.00
Tr
1.00
9.00
9.00
17.00
9.00
Tr/Ts
1.00
1.00
9.00
1.89
3.22
FBq=1
Tf
1.00
19.00
3.00
20.00
Tr
1.00
18.00
1.00
17.00
9.25
Tr/Ts
1.00
2.00
1.00
1.89
1.47
FB
Tf
1.00
18.00
3.00
20.00
q=2i
Tr
1.00
17.00
1.00
17.00
9.00
Tr/Ts
1.00
1.89
1.00
1.89
1.44
9.3 SPN

n
t1<=t2<=<=tn. n 1 n-1 2
[n*t1+(n-1)*t2++tn]/n
j kj<k[k-j*(tk-tj)]/n>=0 SPN

9.4 burst-time 6464131313


10 9.9

apha=0.8

alpha=0.5

0.00

0.00

0.00

3.00

4.80

3.00

3.33

4.16

3.50

4.00

5.63

4.75

13

4.00

4.33

4.38

13

5.50

11.27

8.69

13

6.57

12.65

10.84

9.5 Sn+1=Tn+(1-)Sn,Xn+1=min[Ubound,max[Lbound,(Sn+1)]]
Ubound Lbound T Xn+1
Sn+1
9.3

Applied Optimal Estimation


9.6 9.5 B A 2
B A 3
A 2
9.7 t
t1t2t3 r1r2r3 9.18

55


t+r1+r2+r3 3
t+r1+r2 1 2 1
2 t
t 1

9.8
P. Mondrup, is reported in [BRIN73] t
1 n
1
2

n
t1
t2

ti

tn
r1
r2

ri

rn
i 1 n
Ti=t+r1+r2++ri i RiTi+Ti-ti/ri
i Ti
Ri(Ti)=min[R1(Ti),R2(Ti),,Ri(Ti)]
n

a
b

ta
tb

tj

tz

Ra
rb

rj

rz
a j 1 i a j
Tj=t+ra+rb++rj
j Rj(Tj)+(Tj-tj)/rj
1 j a j Ti-t Tj-t.
Ti<=Tj, Rj(Tj)>=Rj(Ti)
J j Ti
Rj(Tj)>=Rj(Ti)>=Ri(Ti). j Rj(Tj)
Ri(Ti).
FIFO
FIFO

9.9 Tr FIFO
Ts Tr=Ts/1-
T
h E [T/T > h] = Ts

F(x) = Pr[X x] = 1 eux Pr[X > x] = e-ux


X X +h

56


=Ts
w Tsw
Ts
Ts

9.10

Rx x Rx=x/(1-)

X
x = m
q = q Q
x m
q

Rx= wait time + service time= qx + x = (q +


1) x A Q
Q=/(1-), Rx=[/(1-)+1]*x=(x/1-)*Rx=[/(1-)+1]*x=x/(1-)
9.11

CPU

9.12 0

' ""
""
Y
9.13

1
2

57

9.14 I/O

I/O

9.15

Dekker

dekker
Flag[ 1 ] =
P1 Flag[ 1 ]

9.16 5 A E 15936 12
6379 4

a 1
b
cFCFS 15936 12
d
a: 1
1
2 3 4 5 Elapsed time
A B
C D E 5
A B
C D E 10
A B C D E 15
A B
D E 19
A B
D E 23
A B
D E 27
A B
E 30
A B
E 33
A B
E 36
A
E 38
A
E 40
A
E 42
A
43
A
45

A=45 min , B=35 min , C=13 min , D=26 min , E=42 min
(45+35+14+26+42)/5=32.2 min
b.
Priority Job
Turnaround Time
3
B
9
4
E
9 + 12 = 21
6
A
21 + 15 = 36
7
C
36 + 3 = 39
58

39 + 6 = 45
(9+21+36+39+45)/5=30 min
c.
Job
Turnaround Time
A
15
B
15 + 9 = 24
C
24 + 3 = 27
D
27 + 6 = 33
E
33 + 12 = 45
(15+24+27+33+45) / 5 = 28.8 min
d.
Running
Job
Turnaround Time
Time
3
C
3
6
D
3 + 6 = 9
9
B
9 + 9 = 18
12
E
18 + 12 = 30
15
A
30 + 15 = 45
: (3+9+18+30+45) / 5 = 21 min

10

10.1 3 10.5 10.5

10.5 10.1

A(1)
A(2)
.
B(1)
B(2)
.
C(1)
C(2)
.

0
20

10
10

20
40

0
50

10
10

50
100

0
50

.
15
15

50
100

ABC

A
A

A
A

B
B

B
B

A
A

A
C

C
C

C
A

A
C

A
A

B
A

B
B

A
B

A
A

C
A

C
C

A
C

A
C

C
10.2 5 10.6 10.6

10.6
10.2

59

A
B
C
D
E

10
20
40
50
60

20
20
20
20
20

100
30
60
80
70

10

10.3 10.2[
10.2]
a.
P1C1=20; T1=100
P2: C2=30; T2=145

b.
P3: C3=68; T3=150
10.2
C t=0
D1=100; D2=145; D3=150

a. P1, P2 0.41 10.2 0.828

b. 0.86 0.779
c. P3 P1P2 P3 203068
118 P1 0118 P3 11820138
P3
10.4 10.9b

60

T3 T1 T3 T1

11

I/O

11.1 I/O I/O I/O


2
I/O
C T I/O
max(C,T) C+T
(C+T)/2max(C,T)(C+T).
11.2 11.1 n
n+1n
11.3 11.2 27129110186147411064120
100

FIFO

27
129
110
186
147
41
10
64
120

SSTF

73
102
19
76
39
106
31
54
56
61.8

110
120
129
147
186
64
41
27
10

SCAN

10
10
9
18
39
122
23
14
17
29.1

64
41
27
10
110
120
129
147
186

61

C-SCAN

36
23
14
17
100
10
9
18
39
29.6

64
41
27
10
186
147
129
120
110

36
23
14
17
176
39
18
9
10
38

SCAN C-SCAN
SCAN

110
120
129
147
186
64
41
27
10

C-SCAN

10
10
9
18
39
122
23
14
17
29.1

110
120
129
147
186
10
27
41
64

10
10
9
18
39
176
17
14
23
35.1

1.4 N 0 (N-1)

a. t j

b. K K
c.
N-1
E[X]=iPr[x=i]
i=0
d N N/3.
a P[j/t] t j
1/N P[j/t]=1/N,t<=j-1 t>=N-j;P[j/t]=2/N,j-1<t<N-j.
j 2/N
b P[k]=P[k/t]*P[t]=1/NP[k/t],a 1/N 2k 2/N
N-k

62


P[k]=2k/N+2(N-k)/N/N=2(N-k)/N*N
(c)E[k]=k*P[k]=2k(N-k)/N*N
=(N*N-1)/3N
(d) N N/3
11.5
Ts=Tc+MTd
N 2

Ai= i
Hi= i
Bi=i+1 i
1 2 N
Ts=AiHi
M1 M2 M1 M2 M1

A2=B1+A1
A3=B2+A2=B1+B2+A1

Ai=A1+Bj

Ts=T1Hi+BjHi

Hi=1
Ts=T1+BjHi
11.6 11.12 Fnew,Fmiddle Fold
Fnew+Fmiddle+Fold=1.
aFold=1Fnew
b. Fold=1/

11.11 11.11a
LRU
11.7 9 120 1600 /

1600 16001200=192000
11.8 2400 0.6
11.7

a. 10 120
b 30
c.
d
e.
30
b
=30 120
=3600
=3600 /1600 /=2.35
=0.6
=2.25/120+0.6/60=0.02875

63

=240012/2.25+0.6=10105
101050.02875=291
c. 30 10105
3010105=303150
d. 30
R=303150120/291=125010 /
e=303150120=36378000
11.9 512 96 110 8
11.8b

4 =303150/4=75788
=75788/96=790
=790/110=8
11.10 11.9 360r/m I/O
2.5us I/O

512 512
=2.5512=1280us
=60s/m360r/m96 /=1736us
I/O =1001280/1736=74
11.11 DMA 11.10
DMA =2.5us
I/O =1002.5/1736=0.14
11.12 32
10 VDT

800KB/s

200KB/s

6.6KB/s

1.2KB/s
VDT
1KB/s

=800+800+26.6+21.2+101=1625.6KB/s
11.13 I/O
RAID 0 I/O
I/O

I/O I/O
I/O RADI 0

12.1B= R= P= F= 12.6
F

64

R/2

12.2
n
F
a. F n
b.

a.

b.
12.3
a.
b.
c.

a.
b.
c.
12.4

12.5

12.6
a.
65

b.
a. LISP

UNIX fsck
b.

12.7 UNIX 12.13. 12


8K
32 8 24
a.
b.
c. 12423956
a.
8K/4 = 2K pointers per block
I-Node
12
+
2K
+
(2K2K)

12
+
2K
+
8K

4M

+
(2K2K2K)

8G blocks

96KB+16MB+32GB+64TB

b. 24
2248K = 16M8K = 128GB
c.a 96KB
16MB 13MB 2

13.1a.
13.8

b.

66

b.

13.2
7 OSI

13.3 TCP 1500 160 IP 160


24 800

+TCP +IP 1820bits 24bits


776bits 3 1820+3x241892bits
13.4 TCP UDP
UDP TCP
13.5 TFTP RFC783
ACK

A K B B ACKA
K B A K ACK K+1
B K+1 A K+2

13.6 TFTP
TFTP 512 ACK

14 /
14.1 n
x MIPS
a. n x MIPS
b. n=16 x=4 MIPS 40 MIPS
a.MIPS [n (1 )] x ( n 1) x
b. =0.6
14.2 9 T
T 25% 9

a.

b. 18 9
a. T8 T/4
67

2T 3T=3 =
0.75
b. = 3.43
14.3 FORTRAN 32

L1 DO 10 I = 11024
L2 SUMI= 0
L3 DO 20 J = 1I
L4 20 SUMI= SUMI+ I
L5 10 CONTINUE
2 4
135
a.
b. I 32 1 32 I=1 to 32
2 32 a J
?
c. 32

d. 32

a. = 1,051,628 cycles
b. = 16.28
c. I-loop 32
d. = 32

15
15.115.1
a.
b.
a. Eagerdirty

b. copy-on-reference Eagerdirty

15.2 15.9 4 {aq} q a P3

P1 0 a 1 a11
P4 1 q14
a q P1 P4
1<4 4 {aq}
15.3 Lamport Pi Reply
Pi Pi Reply

15.4[RICA81]
a.
b.
68


a. i

j
i
b. ,
15.5

Pi
request [i]
token [i]
Pi tok
en [i] Pj requestj [i]max
Pj
15.6
a.
b.
c.
a. token_present 1
token_presenti
Pi Pi Pi false true Pj
token_presentj true Pj
false Pj
b.

c.
PiPjj = i+1, i+2, . .
., n, 1, . . ., i-1Pi
PjPj

15.7 15.11brequest(j) = t
Pj request(j) Pj
max

16

16.1 26 4
a.
b.

264
a. T
= 63.5
2
b.

13 T = 134=52

16.2 k p r
69

rk i xi
yi
a.
b. xkxixk yi
c.
a.
p = rk
b.

p =

rk r p
rk p

c.
p = rp
16.3 6 CVC
V= <a,e,i,o,u>C=V
a.
b.
a.
T = (21521)2 = 4862025
b.

p =

1
210-7
T

16.4 95 ASCII 10
6.4 UNIX
9510 61019

6 1019 passwords
9.4 1014 sec onds
6
6.4 10 passwords / sec ond
300, 000 years
16.5 UNIX SunOS-4.0
/etc/publickey A IDA KUa
KRa DES Pa A
EPa[KRa] KRaEx[a] x
a. Pa
b.
a. KUa KRa KRa Pa
X X = DKra[EKUa[X]]
b./etc/publickey P P' KRa'
= DP' [ EP [KUa] ] Y Y = DKRa [ EKUa [Y] ]
P' = P
16.6UNIX

16.7 UNIX salt 4096 salt

salt
salt
salt
salt
70

16.8 salt
salt 24 48
salt salt
salt salt salt
salt
16.9 D
P DP TRUE FALSE

Program CV =
{
main-program =
{ if DCVthen goto next
Else infect-executable
}
next
}
infect-executable
D CV
D P TRUE FALSECV
D D CV CV D CV CV
D D CV
16.10

**

16.11 16.11 Alice


Alice Alice back-pocket

Drake Drake
back-pocket
16.12
XOR
XOR

71

You might also like