计算机操作系统 (第四版) 汤小丹课后答案完整版
计算机操作系统 (第四版) 汤小丹课后答案完整版
1 2 3 4
2 OS
1 OS
2 OS
3 OS
3 OS
OS I/O
OS
5 I/O I/O
I/O
I/O
CPU
8 OS
OS
10 8 16
CP/M MS-DOS.
11 Windows OS
2 Windows 95 16 /32 32
4 Windows XP Windows2000
Luna
Windows IndexingService
12
100
13 OS
14
1
15 ?
16
I/O I/O .
17
18
19
1 OS
OS
2
20 OS /
C/S
21 OS
1 2 / 3
22 OS
OS
23
24
1.
Graph)
2. :
3.
5 ?
:
6 ?
(1)
(2) OS
(3)
7 PCB PCB
PCB
OS PCB
1 CPU
3 I/O
4 I/O
5/48
07 G09 5/48
10
11
12
I/O
13
1 OS Creat()
2 PCB
5 .
14
1 PCB PCB
5 PCB
15
a. b. c. d. .
16
1 A B A
B A B A
2 A B
A B
A B
17
"
S.L
signal(S) signal
S.value:=S.value+1 1 S. value 0
wakeup S.L
20
21
mutex
1 CS wait(mutex) signal(mutex)
mutex
wait wait
mutex wait
mutex signal
begin
parbegin
process 1: begin
repeat
wait(mutex)
critical section
signal(mutex)
remainder section
until false
end
process 2: begin
repeat
wait(mutex)
critical section
signal(mutex)
remainder section
until false
end
parend
22 2-17
begin
parbegin
parend
end
begin
parbegin
end
23 signal(full) signal(empty),
signal(full) full
full 0 wait(full)
signal(empty) n
empty 0 n
wait(full) wait(mutex)
wait(mutex) wait(empty)
signal(empty)
signal(mutex) wait(mutex)
signal(mutex) signal(full)
25 W W=1 W=0
W:=1;
unlock(W): W:=0;
lock(W): W:=W+1;
unlock(W): W:=W-1;
Var W:semaphore:=0
begin
repeat
lock(W);
critical section
unlock(W);
remainder section
until false;
end
26 :
producer:
begin
repeat
wait(mutex);
wait(full);
buffer(in):=nextp;
signal(mutex);
until false;
end
consumer:
begin
repeat
wait(mutex);
wait(empty);
nextc:=buffer(out);
out:=out+1;
signal(mutex);
until false;
end
27 .
Repeat
Wait(chopstick[i]);
Ea.t ;
Signal(chopstick[i]);
Ea.t ;
Think;
Until false;
28
gather:
begin
repeat
wait(empty);
wait(mutex);
buffer:=nextp;
signal(mutex);
signal(full);
until false;
end
compute:
begin
repeat
wait(full);
wait(mutex);
nextc:=buffer;
signal(mutex);
signal(empty);
until false;
end
gather:
begin
repeat
wait(empty);
buffer:=nextp;
signal(full);
until false;
end
compute:
begin
repeat
wait(full); nextc:=buffer;
signal(empty);
until false;
end
29
condition
30
ProclucerConsumer
1 Put item
count count n
PC
Var in,out,count:integer;
notfull notempty:condition;
begin
buffer(in):=nextp;
in:=(in+1)mod n;
count:=count+1;
end
begin
nextc:=buffer(out);
out:=(out+1)mod n;
count:=count-1;
end
begin in:=out:=0;
count:=0
end
producer: begin
pepeat
produce an inem in nestp
PC.put(item);
until false;
end
consumer: begin
repeat
PC.get(item);
until false;
end
31 AND AND
wait AND
in,out: integer:=0,0;
begin
parbegin
producer: begin
repeat
wait(empty);
wait(mutex);
buffer(in):=nextp;
in:=(in+1) mod n;
signal(mutex);
signal(full);
signal(s1,s2,s3,...,sn);
until false;
end
consumer: begin
repeat
wait(full);
wait(mutex);
nextc:=buffer(out);
out:=(out+1) mod n;
signal(mutex);
signal(empty);
signal(k1,k2,k3,...,kn);
until false;
end
parend
end
32
AND
Var RN integer;
L,mx: semaphore:=RN,1;
begin
parbegin
reader:begin
repeat
Swait(L,1,1);
Swait(mx,1,1);
Ssignal(L,1);
until false
end
writer:begin
repeat
Swait(mx,1,1;L,RN,0);
Ssignal(mx,1);
until false
end
parend
end
33
34
35
1 2 3 4
36 OS
OS
CPU ,
37
1) 2 3 4
38.
1 OS
39. OS
40
OS
41
1
42
LWP
LWP
43
PTDA TCB
TCB
TCB TCB
3 JCB
JCB
JCB 1) 2) 3) 4) CPU
I/O 5) 6) 7)
1 2 3
EDF LLF
10 FCFS SPF
FCFS
/ SPF
/ /
11
12
/
13
3 1 2 n
14 CPU
15
16
3-9
1 1
2 3 3 2 1
3 4 2 3
4 2
3-9 EDF
17
( )
200 ms
100 ms 100 ms
( ) 100 ms 400 ms
150 ms 250 ms
18
19
20
21 P0 Request(0,2,0) Request(0,1,0)
( )
1 10 5 7 T0
Requst0(0,1,0)<=Need0(7,4,3);
Requst0(0,1,0)<=Available(2,3,0);
3 P0 P0 Requst0(0,1,0),
Requst0(0,1,0)<=Need0(7,4,3);
Requst0(0,1,0)<=Available(2,3,0);
P0
22 1 2 P2
Request(1,2,2,2)
2 P2 Request 1,2,2,2 (
)
1 {P0,P3,P4,P1,P2}
Request(1,2,2,2) <=Need2(2,3,5,6);
{P2,P0,P1,P3,P4}
Cache
CPU
3 P120
Linker
Load Module
0 1
6
7
8 x
10
11
12
(1)
(2)
13
14
1) 0
2)
3)
4)
5)
15
CPU P
OS
16
17
, ; ,
, ,
3 ,
18 .
( )
19
20
1 2 3
21
22
P A M
P A
23
2
3 UNIX
UNIX
24
LRU
Clock
25
( )
26 LRU 4,3,
2 ,1 , 4 , 3 , 5 , 4 ,3 , 2 , 1 ,5 M 3 4
? ?( )
M 3 7 : 7/12=0.583
M 4 4 : 4/12=0.333.
-------
M 3 9 : 9/12=3/4
M 4 10 : 10/12=5/6.
27 LRU ?
28 Clock .
Clock
29
2 0 PSW
4
5
30 ?
Count Count
1 Count 1 0
I/O
2 CPU
I/O I/O
5 VESA PCI
VESA 32 132Mb/s
486 2~4
Pentium
PCI CPU
10 CPU
132Mb/s ISA EISA Pentium 64
6 I/O
DMA I/O
7 I/O
I/O
(2) I/O
(4) I/O
8 DMA
DMA CPU
CR
MAR
1 CPU I/O
2 CPU
3 CPU I/O
M CPU C
CPU
max(C, T) + M
11 max T,C ?
T M
max(C+M,T) M
max(C,T)
12
13
GetBuf(EmptyQueue) EmptyQueue
Hin PutBuf(InputQueue,Hin)
InputQueue
GetBuf(OutputQueue)
Sout
PutBuf(EmptyQueue,Sout) EmptyQueue
14
I/O I/O
CPU I/O
I/O I/O
I/O
15
1 2
I/O
16
(1) I/O
(2) I/O
(3)
(4)
(5)
(6)
17
18 SPOOLing
SPOOLing SPi
SPo
19 SPOOLing I/O
SPOOLing I/O
20
1 I/O
2 I/O
3 I/O
4 ROM
21
2 I/O I/O
5 I/O
22.
(1)
(2) CPU
(3)
(4)
(5)
23.
Ts Tr Tt
1 Ts s n
Ts = m n+s
600r/min Tr 50~100ms
3 Tt
Tt / b
Tt = b/rN
24.
(1)
(2)
(3)
25.
I/O
26.
4-6
27
RAM
28.
RAID
RAID
I/O
I/O I/O
3
1 /
N/2
N N /2
10 MS-DOS A B A 11 12 16 14 B 13
18 20 A B FAT
11 NTFS
NTFS
512B 512MB
512MB/512B=1M 1M
64K 512MB
13
, [ ]/[
] FCB 0-9 10
11 12
1 9999/1024=9 783 9 9
783
592
160
15
16 UNIX
UNIXSystem BSD UNIX 13 iaddr(0) iaddr(12)
17
18
19
20 Hash
Hash
Hash
21 Hash
Hash
Hash
22
DGA
23 6-33 1KB
0 i=3 j=3
b= 3-1 *16+3=35
map[3 3]=1
0 i=4 j=7
55 map[i j]=1
24 500 32
2 i j
3 /
2 b=(i-1)*32+j
3 map[i,j]=1
map[i,j]=0
25 UNIX
UNIX
26
27
28
29
30
31
Ti Ti
redo undo
32
Ti Q Q Q Ti
Q Ti Q Ti Q
33
34
0 N
1 K 0 K
2 K 2 K
3 K 0 K
1 login password
backup
erase
4 mkdir dir rmdir
tree chdir
>
<
MS-DOS UNIX
1 2 3
4 5
8 MS-DOS COMMAND.COM
COMMAND.COM
1 Autoexec.bat
exec
4 2
9 UNIX
mv mv oldname newname
10
cd .. cd .
: $catfile1>>file4
12. mail write ?
13. ?
14
2 /
15
16
2 CPU PSW PC
UNIX CHMK
17. open
:
18. UNIX
: unlink i.link 1
i.link 1 0
19. IPC
: IPC
1 msgget,msgsend,msgrcv
2 shmget,shmid,shmdt
20. trap.S
UNIX V trap.S
trap.S
trap.S
R0 CHMK
(PSL) PC (code)
trap.S trap.S
CPU R0 R11
R0 R11 1
22. trap.C
trap.C C 12
trap.C
23. UNIX
UNIX sysent[]
trap.C
1.
2.
3.
4.
1 2
5. LAN
LAN
1 2
9 TCP/IP
TCP/IP 4
TCP UDP
3 OSI IP
4 OSI
10 IP IP TCP
1 IP IP
2 TCP TCP IP
TCP
12. OSI/RM
OSI/RM
13.
14.ISO OSI/RM
OSI/RM 7
15. /
1 2
3 4
16..
C/S
C/S
17. C/S
2 C/S
C S C/S
18. Internet /
Internet / Web
19. C/S
2 3
1 2
20.
21.
22.
23.
24.
A B C
D E
25.
26.
TCP/IP
27. ? ?
E-mail, @
28.
Internet FTP
1 FTP FTP
2 FTP Internet
29.
Internet FTP
30.
31.
32. Internet
1 2 3 4
33. WWW
Web
34. BBS
BBS Bulletin BoardSystem BBS BBS
BBS
Internet BBS
BBS BBS
35. Internet
Internet
"." cctv.com
"." "."
36.
IP IP
IP DNS
IP
DNS UDP
IP
IP
37. Internet
38. /
/ B/S Browser/Server
B S
B/S
HTML
1
8 D1( ) C1( )
C2( ) B1 B2 B3 A1 A2
5.
publickey privatekey
6.
7. DES
64 X0 32 L0
32 R0
X0 16 56 Ki
16 32 32
8.
9
1 A Kda P DKda P
4 B A Kea DKda P
EKeb DKda P =P 10
(1) A CA A A
(2) CA A A
A CA CA CA
(3) A B A B
(4) B CA CA B CA
B B B
(5) B CA B
A A A
(6) B A A
11
12 -
- FEP
13.
1 2 3 4
14
15.
IC
16.
17.
18
19 SSL
SSL
SSL
20.
21.
switch
access(i,j) i j D1 D2 S
D1 D2 D2 D3 S D2
D3 D3 D1
22.
i j acess(i,j) i
acess(i,j)
acess(i,j)
23.
i j i j
24.
access(i,j)
C Di Qj
25
ACL
26
27
28.
29.
30.
(1) (2)
(3) (4)
31.
(1) (2)
(3) (4)
(5) (6)
32.
(1) (2)
1 UNIX
2 UNIX
UNIX OS OS
shell
3 UNIX PCB
UNIX PCB U
5 UNIX
1 fork
2 exit
3 exec
4 wait
7 exit
Unix exit
exit
exit
8 UNIX
UNIX
= CPU /2 +
9 sleep
sleep
10
:
11
proc
12
pipe pipe
pipe
mknod
13
1 pipe
14
msgctl( )
msgsnd( )
msgrcv( )
15
shmctl( )
shmat( ) shmaddr
16 shmget
shmid
17
semop( )
18
sem_op 3
sem_op V sem_op
(sem_flg&IPC_NOWAIT)
19 UNIX
UNIX V
20
1 file
I/O
21
22
I/O getcf
bp 6
putcf
bp cfreelist
23
UNIX
1 2
dev blkno
getblk
gdopen
gdstart
gdstartegy I/O
gdintr I/O
26 UNIX
bread breada
27 UNIX
A B
C D
28 UNIX
UNIX
29 UNIX
1 10 9999
783 9999
2 10 10+256
i-addr(10) 10
592 18000
3 266 64266
420000 266<410<64266
i-addr(11) 266
160 420000
30
ialloc i i
i i i 1
ifree i i
i i 1
31
creat
32
unlink nlink 0