Professional Documents
Culture Documents
ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ mamalis
ΛΕΙΤΟΥΡΓΙΚΑ ΣΥΣΤΗΜΑΤΑ mamalis
) 25/7/2003 10:58 1
. ,
.
HPOOPIKH
'
M
M H/Y &
ATPA 2003
HPOOPIKH
'
M
M H/Y &
K
T M
T M
EPAIMO MPATH
XPITINA KAPAEPTOOYOY
EI EKOTIKH E..E
TYPORAMA
/ 1997 2003
ISBN: 9605382113
K : H 40/3
Copyright 2003
& , 262 22 : 2610 314094, 314206 : 2610 317244
. 2121/1993,
.
............................................................................................................................................................................. 9
K 1
, , ,
E .................................................................................................................................... 11
K 2
A Linux
, , ,
E .................................................................................................................................... 15
2.1
2.2
Scripts
.....................................................................................
17
...............................................................................................................
25
...................................................................................................................................................................................
34
B ..................................................................................................................................................................... 34
3
, , ,
E .................................................................................................................................... 35
3.1
X K.M.E. ............................................................................................................... 38
3.1.1 M A:
3.1.2 M B: Y
3.2
...................................................................................
38
.................................................................................................................
40
E/
................................................................................................
3.2.1 M A:
3.2.2 M B: Y
3.3
43
...................................................................................
43
.................................................................................................................
45
.............................................................................................
49
3.3.1 M A:
3.3.2 M B: Y
3.4
...................................................................................
49
.................................................................................................................
52
...................................................................
54
...................................................................................
54
.................................................................................................................
57
...................................................................................................................................................................................
60
3.4.1 M A:
3.4.2 M B: Y
B ..................................................................................................................................................................... 60
K 4
O
Unix
, , ,
E .................................................................................................................................... 61
4.1
.........................................
63
4.1.1 E .................................................. 63
4.1.2 E
4.2
................
64
.............................................................................................
67
4.2.1 Y
..................
67
4.2.2 .................................................... 70
4.2.3 M ............................................................................ 75
4.3
..........................................................................................................
79
...................................................................................................................................................................................
82
B ..................................................................................................................................................................... 82
K 5
A ..
(T .. Linux)
, , ,
E .................................................................................................................................... 83
5.1
X K.M.E. ............................................................................................................... 85
EPIEXOMENA
5.1.1 O
5.1.2 O
5.2
..............................................
85
.......................................................................
90
................................................................................ 94
5.2.1 H Page faults
.........................................
................................
............................................
94
97
102
................................................................................................................................................................................ 108
B .................................................................................................................................................................. 108
E
............................................................................................................................................................................
............................................................................................
109
111
B .............................................................................................................................................. 125
......................................................................................................................................................................
129
.
(,
..), . ,
, (kernel) ,
.
,
,
, ,
, , .
, () , ,
() , , () , , , () ..
, .
10
,
,
,
( ) ,
.
,
UNIX (
LINUX),
.
, ,
. ,
,
. , , , , .
.
UNIX
, LINUX.
,
, :
scripts LINUX, scripts ,
, ..
C
UNIX ( , ..).
C , ( ) .
, .
() (PCB structures, timers, , ..) .
KEAAIO 1:
12
UNIX
LINUX
scripts
(.)
UNIX. To
,
( ).
,
UNIX (PCs LANs
),
LINUX. ( )
UNIX, .
,
UNIX,
(shell) (kernel) .
K 2 LINUX,
. (grep, awk sed)
UNIX,
scripts
.
K 3,
( C), ( ) UNIX ( , , /, ..).
K 4, ,
K 3, , .
, ,
,
.
K 5 , UNIX (
LINUX),
. (, , ..), , , ( C ) .
, , , ,
UNIX,
,
.
13
KEAAIO 1:
14
1.1
,
,
,
,
,
(
). :
... ( [6]),
..., ( ..), ( , ..),
( ..)
( ..).
K 35 [1] K 2 3
[3], UNIX ( LINUX).
K 13 [2]
K 48 ,
C .
K 46, 7 9 [5]
2,3 5 [8], , .. Unixlike
.
K 2 4 [4] K 3
4 [7],
UNIX
C, ,
.
, , Internet URL
Linux ( [9]).
A K Linux
Unixlike , Linux (
).
Linux,
, :
Linux,
Linux,
scripts scripts Linux,
grep sed
,
sed awk
,
grep, sed awk
Linux (.. sort, date ..), ,
scripts .
(pipe)
grep, egrep
awk
K E A A I O 2 : A K L I N U X
16
sed
scripts
Linux
( ) UNIX . ,
,
.
, (2.1)
(grep, awk sed) Linux,
(administrator) UNIX
.
( 2.2) Linux (scripts), 2.1
Linux ( ..),
, , ..
2 . 1 E : G R E P, S E D & AW K
17
K E A A I O 2 : A K L I N U X
18
2.2
customers.txt (
editor vi), o, ,
,
( .. , ..):
Basileios Mamalis
Age 29
Address Eyripidou 2, Ano Xaraygi, 17236, Dafni, Athina
Phone 019738383
Nikolaos Papadopoulos
Age 76
Address Filolaou 45, Pagkrati, 17564, Athina
Phone 016854321
( 510 )
sed ( ).
2 . 1 E : G R E P, S E D & AW K
19
sed ,
.
2.3
(
customers.txt 2.2),
,
, 18 .
awk script
( 18 ), ,
.
script,
.
2.2
basket.txt ( editor
vi) 15 :
27111965:Fasoulas, Panagiotis:97
03051974:Alvertis, Fragiskos J.:27
12011973:Sigalas, Giorgos K.:32
13121962:Giannakis, Panagiotis:91
25081973:Oikonomou, Nikolaos:74
( 10 ),
() , () ()
( :).
, 0 100.
egrep
K E A A I O 2 : A K L I N U X
20
70
.
egrep
74
.
2.3
numbers.txt ( editor vi),
(
), :
3.01 65 76.0 6.9801 4.0000 5.000007 54.0000000 6.00 7.
8.004 15.0
sed , , (.. 7. ).
(2) sed, pipe.
,
, 2 ,
( ) .
2 . 1 E : G R E P, S E D & AW K
21
2.4
sed_test.txt ( editor vi),
/ double quotes, :
Here is a testfile for trying out
the sed problem
that was given to this class the other day
with the hope that they would overcome
the various difficulties including
sed,
double quote ( )
.
.. :
testfile for trying out
problem
given to this class the other day
( )
difficulties including
( )
2.5
2.4
.
sed,
K E A A I O 2 : A K L I N U X
22
/
double quotes .
..
:
testfiletrying out
problem
given class day
( )
difficulties
( )
2.6
sed 2.5 , . ,
5
:
testfiletrying out
problem
given class day
difficulties
2.7
life.txt ( editor vi),
15 :
Byron:1788:1824
Yansen:1832:1896
2 . 1 E : G R E P, S E D & AW K
23
Berthold:1912:1950
Damiani:1767:1799
Kraislov:1854:1912
( 10 ),
()
() , () ()
( :). , , 15 90.
awk 40 .
2.8
address.txt ( editor
vi), 5 ,
3 . ..:
Papadopoulos Nikos
Eyripidou 2, Ano Xaraygi
17236, Dafni, Athina
Papapetrou Giorgos
Filolaou 45, Pagkrati
17564, Athina
( 3 )
awk script
, (, ) 1
3 :.
, ( )
:
K E A A I O 2 : A K L I N U X
24
( awk script
) .
2.9
votes.txt ( editor
vi), 10 :
Avramopoulos:Athina:y:n:y:y:y:n:n:y:n:n:n:n:y
Karavolas:Patra:y:n:n:y:y:n:y:y:n
Kosmopoulos:Thessaloniki:n:y:n:n:y:y:y:y
Sarantopoulos:Dafni:n:n:n:y:n
( ),
()
, () () (y)
(n) .
( y n , )
, .
, ,
:.
awk script () , () ()
(y) .
, :
Avramopoulos:Athina:6
2 . 2 S C R I P T S
25
2.2 Scripts
2.4
customers.txt 2.2, ,
, , /
(45) .
script
:
K E A A I O 2 : A K L I N U X
26
.
(.. Number of customers
records = )
2.5
customers.txt
2.2, , , 50 .
script
( 50 ) (3)
:
( )
.
script
/:
,
/
,
pipes.
2.11
( 1015), (.. read/write , read ).
script world (read) .
2 . 2 S C R I P T S
27
:
, :
The following files in the current directory are
worldreadable:
() ,
. ..:
basket.txt
votes.txt
address.txt
..
, :
The following files in the current directory are
worldreadable:
No files are worldreadable
script ,
, (
chmod), worldreadable .
.
/ .
2.12
grep pattern files, ,
g
pattern (
) files (
)
pattern.
context pattern
shell script c
files, grep, , ,
( ) pattern, , , (5)
(5) .
K E A A I O 2 : A K L I N U X
28
5 5 ,
(
).
, ,
( ).
context while *.txt,
, script c
while ,
:
notes1.txt lines 1 to 5
notes2.txt lines 1 to 8
(first line)
...............................
(line 2)
..............................
...............................
..............................
(line 3)
..............................
while finish!=FALSE do
(last line)
..............................
notes3.txt lines 22 to 32
(first line)
..............................
(line 2)
..............................
while (x+y)<=(k+1) do
(line 22)
(line 23)
(line 24)
..............................
(line 4)
..............................
(line 5)
..............................
..............................
..............................
(line 6)
..............................
(line 25)
(line 26)
(line 7)
..............................
(line 8)
..............................
..............................
..............................
(line 28)
(line 29)
(line 30)
..............................
(line 31)
..............................
(line 32)
..............................
, script, , (pattern)
.
script ,
(.. 5 .txt
editor vi
5 5 , , , 5 2 5 5 ).
2 . 2 S C R I P T S
29
2.13
shell script ,
w,
.
script w,
(5). ,
context while *.txt w 2
c
context while *.txt, :
c
notes1.txt lines 2 to 5
notes2.txt lines 1 to 5
notes3.txt lines 25 to 29
. . . . . . . . . . . . . . .
(line 2)
......................
(first line)
....................
(line 25)
. . . . . . . . . . . . . . .
(line 3)
.....................
(line 2)
....................
(line 26)
while finish!=FALSE do
.................
(last line)
while (x+y)<=(k+1) do
while counter>=(x+1) do
.....................
(line 4)
....................
(line 28)
.....................
(line 5)
....................
(line 29)
script ,
( )
2.14
phonebook.txt
:
Aleksandra:9765612
Andrianna:3458756
Basilis:8769876
Nikos:9757232
( 10 )
, :.
,
addphone name number :
a
K E A A I O 2 : A K L I N U X
30
, name ,
.
, , , ( )
, .
.
10
3
,
.
, sort o.
2.15
setall,
:
, ()
. ,
$setall x 1 y sec z left
$echo $x $y $z
1 sec left
,
.
; ,
;
2 . 2 S C R I P T S
31
2.16
users.txt login name ()
. login name
( , )
.
, (3) login names: nikos, giorgos, basilis
users.txt
( ,
, .. login name
:):
nikos:25
basilis:21 9738383 Maizonos_54
giorgos:32
nikos:7650987
giorgos:Faidnos_26 5647121
nikos:Panepistimiou_32
K E A A I O 2 : A K L I N U X
32
2.17
(system administrator)
() . script :
(directory)
(directory subtree) /. . ..
final_project.ps 1253652
:
() opendir,
() .
,
(directory subtree) .
2.18
weekday, :
( ), weekday 0 ( ).
,
.
( date),
, ( ):
&&.
.
2 . 2 S C R I P T S
33
date .
grep.
.
weekday.
2.19
showshow delay files, s
:
files, ,
.
, , :
,
, delay .
,
.
, ,
delay 5 , :
Next file: test1.txt
< 5 >
This is the first test file given in class
< 5 >
for practice on delay functions
< 5 >
Next file: test2.txt
< 5 >
This is just another test file
< 5 >
K E A A I O 2 : A K L I N U X
34
Unixlike (
.. LINUX )
, ,
/ .
,
() LINUX (ls, ps ..), () (grep, sed, awk ..), ()
(sort, date, && ..) ()
(shell scripts ..)
(for, while, if, case ..) LINUX.
LINUX
.
B
A
T UNIX
UNIX,
C. , ,
(,
..) .
UNIX C,
, :
C readyqueue ,
UNIX,
C , , First Come First Serve, Shortest Time Remaining First Round Robin,
C (..
, ) ,
signal
wait ,
,
,
C , FIFO, LRU,
LFU MFU.
36
KEAAIO 3: A T UNIX
First Come
First Serve
Round Robin
Shortest Time
Remaining First
FIFO
LRU
LFU
MFU
,
UNIX, ( /, , ).
C, UNIX
( ,
C,
).
UNIX,
, .
(3.13.4), ( modules C) ()
, () , ()
37
() /
. , ,
.
3.1
, :
[1] ( K 48)
,
.. C,
UNIX.
[4] ( K 3 4)
UNIX.
38
KEAAIO 3: A T UNIX
3.1 X K.M.E.
( UNIX),
o C .
3.2
, () K 4
[2] () K 2 ( 2.4 )
[5] ,
...
.
3.1.1 M A: E
P1
P2
P3
P4
P5
12
() , () ( )
, () ( ,
).
3.1 X K.M.E.
39
3.1
, :
Gantt chart
, , ... .
, () , ()
, () ()
, .
() Priority based Preemptive (PP)
Gantt
9 10 11 12 13 14 15 16 17 18 19 20
chart
P1
P2
P3
P4
P5
9 10 11 12 13 14 15 16 17 18 19 20
chart
P1
P2
P3
P4
P5
40
KEAAIO 3: A T UNIX
9 10 11 12 13 14 15 16 17 18 19 20
chart
P1
P2
P3
P4
P5
9 10 11 12 13 14 15 16 17 18 19 20
chart
P1
P2
P3
P4
P5
3.1.2 M B: Y
(Fist Come
Fist Serve, Preemptive Priority, Shortest Remaining Time First Round Robin),
( ) C, .
3.3
, C, :
3.1 X K.M.E.
41
() , () ... ( ) () (, ).
(Gantt chart), , , , (
):
Time :
PP
10
..........................
: P0 P1
P1
P1
P2
P2
P3
P3
P4
P4
P5
..........................
FCFS :
.................................................................................................................................................................................
STRF :
.................................................................................................................................................................................
RR
.................................................................................................................................................................................
, ,
() , () , () () , .
Shortest Remaining Time First, , ,
, . ,
.
.
, ,
, ,
,
. , :
42
KEAAIO 3: A T UNIX
(C modules
).
header files ,
(, ..).
ready queue,
( ) , ...
K.M.E.
(.. ,
).
( , PCB ..)
, (.. , , ..). , , , .
( PCB ..) .
, ,
.
(testing)
,
.
, :
. -
3.2 E /
43
(8) (
). .
(
Preemptive Priority )
.
, , ,
,
( ) ,
(starvation).
3.2 E /
,
( ),
, ,
.
3.4
,
/ ()
K 7 9 [2] ( 7.3 9.6 )
() K 5 ( 5.3 ) [5]
... .
3.2.1 M A:
() .
(5) ,
() ()
44
KEAAIO 3: A T UNIX
( ), , .
P1
15
P2
10
28
P3
14
P4
25
32
P5
43
18
3.2
,
:
First Come First Serve
Shortest Remaining Time First
Gantt chart
(
100 )
:
Gantt
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 00
chart
P1
P2
P3
P4
P5
3.2 E /
45
:
P1, 12 ,
(.. ) 6 .
P2, 3 ,
mutex (..
wait(mutex), 0).
P4, 12 , mutex (.. signal(mutex)).
;
,
Ready Queue 0, 12, 14, 18 25.
Ready Queue
FCFS
0
12
14
SRTF
18
25
12
14
18
25
End
Start
3.2.2 B: Y
,
.
46
KEAAIO 3: A T UNIX
3.5
,
, , :
( , ) () , () ( ) () (
) .
( , ) () , ()
, ()
() (wait/signal).
,
( Gantt chart, , , ), :
K , ,
, ,
.
, ,
(.. ).
,
(,
..).
, , CPUbound
/bound,
( CPU
).
3.2 E /
,
.
, ,
:
C module
, (read, write ..) ( ..).
(
), ( )
.
( C module) (wait, signal) .
, , ( )
, ( )
.
( ..).
( ..) (block, wakeup)
,
(..
blocked,
).
, , (
) (
).
47
48
KEAAIO 3: A T UNIX
( ,
, block wakeup ..)
.
(testing)
,
.
, :
.
, , CPUbound,
I/Obound ( , ,
).
. () CPUbound
I/Obound;
,
deadlock ( ).
, ,
. , ,
...
( ).
3.3
49
3.3
( paging) C .
3.6
(paging) Unixlike
() K 5 [2] () K 3
( 3.1 ) [5] ,
..., .
3.3.1 M A:
,
,
, .
3.3
(paging)
:
(8 bits),
. (VPN:
Virtual Page Number) offset ,
(PGSIZE ):
VPN (8x) bits
x=log2 PGSIZE
,
(PTR: Page Table Base Register).
50
KEAAIO 3: A T UNIX
CHANGED_
BIT
REF_BIT
(not used)
(10 bits)
PTR+VPN.
bit (VALID_BIT) 0, PAGE_FAULT
VPN (PFR: Page Fault Register).
VALID_BIT 1,
offset (10+x) bits
( ) x PGSIZE + offset
, REF_BIT 1, , , CHANGED_BIT 1.
() x 3 (bits), () 10101111, () PTR
00000, () PLR 11111 () () (page table) :
00000
NU
1010000110
NU
0010000110
NU
0010001110
NU
1010111110
NU
0011100110
NU
0011000110
NU
0100000110
3.3
11111
51
NU
0000100111
NU
1010001111
NU
1010011110
NU
1011110111
NU
0010011111
NU
1111000000
NU
1110000100
NU
0000000110
NU
0000000010
NU
0000001111
NU
1111110110
NU
1011111110
NU
1010101010
NU
0101010101
NU
1110000111
NU
1111001111
NU
1100000011
NU
0011111100
NU
0001111000
NU
0001110000
NU
1111011111
NU
0000100000
NU
1111111100
NU
0000101010
NU
1010101111
() , ()
()
,
.
52
KEAAIO 3: A T UNIX
3.3.2 M B: Y
, , C.
3.7
,
:
,
(.. P1 Pn).
( bits) (8 ), x (offset) (10+x ).
,
,
( ).
(page tables) PTR PLR .
:
( )
. , ,
( ) .
, ( REF_BIT CHANGED_BIT )
.
VALID_BIT
0, PFR (page fault register)
.
3.3
,
. , :
(
), .. K.M.E. (.. , module
, ).
,
2.1 , . ,
( ) .
, module ...
2.1.
, , .
(, , ..) , , , .. ()
, ()
.
(testing)
.
53
54
KEAAIO 3: A T UNIX
, ,
( 3.4 ).
, :
( ).
(.. ()
x, ()
VALID, REF CHANGED_BIT ..).
3.4 A
,
Unixlike ,
.
3.8
, () K 6 [2] () K 3 ( 3.3 3.4 )
[5]
...
.
3.4.1 M A:
(Fist In First Out, Least Recently Used, Least Frequently Used
3 . 4 A
55
Number of
Page Faults
56
KEAAIO 3: A T UNIX
Frame 3
Frame 4
Frame 5
Frame 6
Frame 3
Frame 4
Frame 5
Frame 6
Number of
Page Faults
3 . 4 A
57
3.4.2 M B: Y
C
.
3.9
,
:
( ),
.
,
.
.
( ) .
, .
, .
page fault
, , page fault ,
.
(FIFO, LRU, LFU, MFU),
modules.
:
58
KEAAIO 3: A T UNIX
,
.
(pagefaults) .
(page fault rate) ,
.
,
. ,
, ,
.
, (, , , ..), ( 3.1 3.3). , , , :
(C modules
).
( ) ,
( 3.4.3) .
header files
(, , , ..).
() K.M.E., () () (
3 . 4 A
,
o pagefault).
(testing)
,
.
( , , ..) :
. (8) (
). .
(
Most Frequently Used )
.
, , ,
(pagefaults
), , ,
(thrashing)
59
60
KEAAIO 3: A T UNIX
Unixlike . ,
( )
, (lowlevel) ,
C, (kernel) .
, ( ) () (Round Robin, Shortest Remaining Time
First, First Come First Serve Preemptive Priority), ()
(First In First
Out, Least Frequently Used, Most Frequently Used Least Recently Used),
() , ( ) / Unixlike .
B
O
UNIX
(, , ) . , ,
,
, .
, , :
()
UNIX,
(assembler),
C ,
,
C ,
, .
readyqueue
62
K E A A I O 4 : O U N I X
/
. ,
UNIX. ,
, ,
.
,
, , ( ,
). ,
.
, ,
, , ,
,
.
4.1
,
:
4.1 E
63
[1] ( K 48)
,
.. C,
UNIX.
[4] ( K 34 67)
UNIX (, ..)
4.1 E
UNIX
( , ). , ,
,
.
4.1.1 E
4.2
() ,
3.3, () 3.4.
, ( ) (
() ).
64
K E A A I O 4 : O U N I X
, :
3.4
()
() 3.3,
/
,
(interface) ,
.
, ,
(, ..)
(testing)
,
,
3.3 3.4 ( testing ).
,
3.3.2 3.4.2.
4.1.2 E
4.3
()
( 4.2) ()
3.1.
4.1 E
, . :
, .
,
/:
(
... ) ,
.
H Process Control Block (PCB) (
) , (.. , timeslice , ..), (..
, PTR PLR ..).
... (.. round robin) (.. , ..).
(pagefault)
,
pagefault ... , -
65
66
K E A A I O 4 : O U N I X
,
... .
, , / ,
(interface)
.
(testing)
( ) ,
3.1, 3.3 3.4 (.
testing ).
, /
,
. ,
/
.
(testing) 3.1, 3.3 3.4,
/:
,
, 3.1.2.
,
()
() , 0. , 3.3.2 3.4.2.
4.2
67
4.2
UNIX , (...).
, .
4.2.1 Y
4.4
, , , C (..., ..)
. ( ),
4.2.2 4.2.3.
:
(accumulator) (8) ,
.
(accumulator) A7
A0
68
K E A A I O 4 : O U N I X
M P7
P0
R1
P1
0000(m)
2R1
P2
3R1
P3
(P1)R1
M1
PP
1111(m)
PTR (Page Table Base Register), PLR (Page Table Length Register)
PFR (Page Fault Register), (8) .
, :
(fetch) .
(
..., , ).
( (8) ,
/ .
,
/:
UNIX
( , )
CPU module, -
4.2
(.
3.1) .
, 4.2.3
.
, , .
() ()
.
.
() () ... ( , ..).
(M, P, R, m, p), ,
( .. page
faults, ..).
( )
=28=256 R=24=16 ,
(testing 4.3) =210=1024 R=26=64.
.
69
70
K E A A I O 4 : O U N I X
,
(PTR, PLR, PFR)
.
(testing)
, ()
()
...,
.
,
, ( 4.3 , , ).
4.2.2
4.5
( ) ,
(assembly),
. , (machine code) , ... .
,
(assembler), , , C, (
4.2
)
.
(assembly)
(assembler)
(8) , (4)
(4) ,
:
load <n>: accumulator <n>
accumulator
<n> ( accumulator, )
001 n : 001 01010
,
<n> ,
,
010 n : 010 00110
zeroy <n>: <y> ,
,
<n> ,
,
011 n : 011 00110
storex:
accumulator <x>
100 * : 100 *****
storey:
accumulator <y>
101 * : 101 *****
print:
accumulator
110 * : 110 *****
end:
111 * : 111 *****
71
72
K E A A I O 4 : O U N I X
(
)
(8) ,
:
(3) .
(23) ( ),
(4) 0 , (4)
1 .
(5) :
)
(, , 32 (25=32) 0 31
).
) .
(8) .
, 3*4 (
, ,
,
... ).
4.1
(3* 4) :
load 4:
000 00100
storex:
100 00000
load 0:
000 00000
add 3:
001 00011
zerox 1:
010 00001
end:
111 00000
4.2
, C
:
(
ass, .. xx.ass),
( ) (
.. xx
, ).
, ...
( ),
(4.2.1), :
( ) 8bits :
0, () , () /
() (.. 01011 accumulator, 00101011).
1, () , ()
() (..
accumulator x, 10000000).
, , print end ... ( . 4.2.3 / )
. (
) ,
.
73
74
K E A A I O 4 : O U N I X
( ),
( .. , ..),
Unixlike
.
(testing)
.
4.1
,
:
62+5
.
4.2
(
) n! n=5.
n n! ;
4.3
(
) 62*3 (
31).
4.2
75
4.6
,
()
, ()
,
:
n!+x2 n=4 x=6.
52+102.
53+62+8.
64+ 9.
(2) ,
(x y) (nested
loops ).
(, , ).
4.2.3 M
4.7
, , ,
, .
(, ..)
, .
(
) ,
76
K E A A I O 4 : O U N I X
.
( ... ) ( ),
.
&
, , ()
( ) . ( + )
(, ,
).
YPHNA
EITOYPIKOY YTHMATO
(,
,
..)
IKO
PTR
KX
PLR
PFR
KY
PC
, ,
interface,
3.1 ( ).
4.2
( .. xx) (xx)
.
,
( ) :
1. ( )
( )
:
( ) ( ).
(demand
paging 3.4). , , , .
(page table) .
PTR PLR.
2. Process Control Block (PCB) (,
, , ..),
(K.M.E.) .
3. ready queue, (
)
.
4. , (
readyqueue ... ):
.
77
78
K E A A I O 4 : O U N I X
PCB PCB.
.
(.. timer
timeslice, round robin)
( ), .
5. ... (
),
:
(fetch
) .
.
, ( ) , .
print,
.
6. ... , ( .. round robin), :
.
(PCB, , ..).
..., readyqueue
(
).
... (.. round robin), -
4 . 3
79
... .
7. end, :
...
.
PCB
.
... (
).
8. 47
.
4.3
( C)
,
.
, Unixlike
,
,
.
4.8
, ,
( , , ), /:
1. /
:
4.2.3 (
80
K E A A I O 4 : O U N I X
).
, ,
/ :
(
) (6) 2 ( 21 26).
n!+(n1)!++1 n=5.
5!+102+(4*5)+2.
(3) .
2. ,
, ,
pagefaults.
,
(FIFO, LRU, LFU, MFU),
pagefaults . () ( pagefaults
), ()
(pagefaultrate) () .
,
( )
(..
M=256 16 (8) 4 ).
, ()
LRU ( , , pagefaults,
4 . 3
LRU) () FIFO.
3. , () First Come First Serve () Round Robin
.
, 3.1.2 ( , ). () , ()
Ganttchart
.
,
()
()
. ,
, ,
(.. ),
.
81
82
K E A A I O 4 : O U N I X
Unixlike
.
C (
) UNIX
,
(PCB structures, , ..)
.
, ,
()
,
.
.
B
A K Y
(T Linux)
UNIX,
(
)
Linux.
( )
Linux, , :
Unixlike
, ,
,
C (timers, shift registers
..) ,
(Linux),
(Linux),
Linux
.
(kernel) Linux
84
K E A A I O 5 : A K Y
o (shift)
(PTR)
a (blocked)
a (wakeup)
(PFR)
(dirty)
,
, ( )
3,
( LINUX),
.
, A
( , , , ..) ()
, () , () ()
Linux.
, , Linux
( 1.0.9) ( C) .
(
), ( ) Linux,
, , WWW
.
5.1 X K.M.E.
85
5.1 X K.M.E.
5.1
, :
[1] ( K 48)
,
.. C, Linux
.
T 3.2, 3.6 3.8.
, URL [5]
,
Linux.
5.1.1 O
one
thing
you
might
take
look
at
is
the
86
K E A A I O 5 : A K Y
204 * NOTE!! Task 0 is the idle task, which gets called when
no other
205 * tasks can run. It can not be killed, and it cannot
sleep. The state
206 * information in task[0] is never used.
207 *
208 * The confuse_gcc goto is used only to get better
assembly code..
209 * Djikstra probably hates me.
210 */
211 asmlinkage void schedule(void)
212 {
213
int c;
if (intr_count) {
221
222
intr_count = 0;
223
224
cli();
sti();
229
need_resched = 0;
5.1 X K.M.E.
230 p = &init_task;
231
232
for (;;) {
if ((p = p>next_task) == &init_task)
233
234
goto confuse_gcc1;
if (ticks && p>it_real_value) {
235
236
send_sig(SIGALRM, p, 1);
237
if (!p>it_real_incr) {
238
p>it_real_value = 0;
239
goto end_itimer;
240
241
do {
242
p>it_real_value += p>it_real_incr;
243
244
245
p>it_real_value = ticks;
246
247
itimer_next = p>it_real_value;
248
249 end_itimer:
250
if (p>state != TASK_INTERRUPTIBLE)
251
252
continue;
if (p>signal & ~p>blocked) {
253
p>state = TASK_RUNNING;
254
continue;
255
256
257
p>timeout = 0;
258
p>state = TASK_RUNNING;
87
88
K E A A I O 5 : A K Y
259
260
}
}
261 confuse_gcc1:
262
263 /* this is the scheduler proper: */
264 #if 0
265 /* give processes that go to sleep a bit higher priority..
*/
266
267
268
269
270
271
272
++current>counter;
}
273 #endif
274
c = 1;
for (;;) {
277
278
goto confuse_gcc2;
279
280
281
c = p>counter, next = p;
}
282 confuse_gcc2:
283
if (!c) {
284
for_each_task(p)
285
286
5.1 X K.M.E.
288
89
kstat.context_swtch++;
289 switch_to(next);
290
291 if(current>debugreg[7]){
292
loaddebug(0);
293
loaddebug(1);
294
loaddebug(2);
295
loaddebug(3);
296
loaddebug(6);
297
};
298 }
, K 2 [3] 3 [4]
,
Linux
4.3 BSD Unix .
5.1
,
:
278 (label) confuse_gcc2;
;
(
276 286)
confuse_gcc2 goto;
90
K E A A I O 5 : A K Y
5.2
, :
( ) ( ready_queue, , ... ..);
(round robin,);
;
.
.
; ( ) .
T TASK _RUNNING, TASK_
INTERRUPTIBLE ;
p>state ;
234240;
.
250260;
.
5.1.2 O
()
(wakeup)
blocked
(wake_up()
5.1 X K.M.E.
91
waitqueue
structures
directly,
but
only
call
wake_up() to wake
313 * a process. The process itself must remove the queue once
it has woken.
314 */
315 void wake_up(struct wait_queue **q)
316 {
317
318
struct task_struct * p;
319
320
321
322
323
324
if ((p>state == TASK_UNINTERRUPTIBLE) ||
325
(p>state == TASK_INTERRUPTIBLE)) {
326
p>state = TASK_RUNNING;
327
328
need_resched = 1;
329
330
331
if (!tmp>next) {
332
92
K E A A I O 5 : A K Y
333
printk(
q = %p\n,q);
334
printk(
*q = %p\n,*q);
335
printk(
tmp = %p\n,tmp);
336
break;
337
338
tmp = tmp>next;
339
340 }
341
342 void wake_up_interruptible(struct wait_queue **q)
343 {
344
345
struct task_struct * p;
346
347
348
349
350
351
if (p>state == TASK_INTERRUPTIBLE) {
352
p>state = TASK_RUNNING;
353
354
need_resched = 1;
355
356
357
if (!tmp>next) {
358
359
printk(
q = %p\n,q);
360
printk(
*q = %p\n,*q);
361
printk(
tmp = %p\n,tmp);
5.1 X K.M.E.
362
93
break;
363
364
tmp = tmp>next;
365
366 }
, K 2
[3] K 3 [4]
, , ,
blocked Linux 4.3 BSD Unix .
5.2
, :
(blocked/sleep) ;
.
(
320) ;
5.3
, :
wake_up()
wake_up_interruptible();
; wake_up_interruptible()
94
K E A A I O 5 : A K Y
wake_up;
( )
( , , );
T TASK_UNINTERRUPTIBLE (
wake_up(), 324) ;
;
350355
wake_up_interruptible(); p>state == TASK_UNINTERRUPTIBLE, wake_up();
struct wait_queue
q.
pcounter current
counter wake_up() ( 327).
5.2
5.2.1 H Page faults
(do_page_fault()) 1.0.9 Linux.
882 / * This routine handles page faults. It determines the
address,
883 * and the problem, and then passes it off to one of the
appropriate
884 * routines.
885 */
886 asmlinkage
void
do_page_fault(struct
pt_regs
*regs,
5 . 2
889
890
891
892
893
894
895
896
897
898
899
900
} else
901
user_esp = regs>esp;
902
903
if (error_code & 1)
904
905
else
906
907
return;
908
909
address = TASK_SIZE;
910
911
wp_works_ok = 1;
912
pg0[0] = PAGE_SHARED;
913
914
return;
915
916
95
96
K E A A I O 5 : A K Y
917
printk(Unable
to
handle
kernel
NULL
pointer
dereference);
918
919
pg0[0] = PAGE_SHARED;
} else
920
921
922
923
do_exit(SIGKILL);
924 }
, K 4 [3] K 4 [4]
,
(page_faults) Linux 4.3 BSD Unix .
5.3
,
:
916 ( 916920);
;
(return) , .
;
5 . 2
97
5.4
, :
( )
( ..);
()
(regs, error_code) () (address,
user_esp, bit) .
892902; ,
.
IF_statement 910 .
TASK_SIZE,
VM_MASK, PAGE_SHIFT, PAGE_PRESENT, PAGE_SHARED;
;
(do_no_page()
do_wp_page()) 1.0.9 Linux.
.
822 void do_no_page(unsigned long error_code, unsigned long
address,
823
824 {
98
K E A A I O 5 : A K Y
825
826
827
828
829
page = get_empty_pgtable(tsk,address);
830
if (!page)
831
return;
832
833
page += PAGE_PTR(address);
834
835
836
return;
837
++tsk>rss;
838
if (tmp) {
839
++tsk>maj_flt;
840
841
return;
842
843
844
tmp = 0;
845
846
847
848
break;
if (address >= mpnt>vm_end) {
849
tmp = mpnt>vm_end;
850
continue;
851
852
if (!mpnt>vm_ops || !mpnt>vm_ops>nopage) {
853
++tsk>min_flt;
854
get_empty_page(tsk,address);
5 . 2
855
99
return;
856
857
858
return;
859
860
if (tsk != current)
861
862
goto ok_no_page;
if (address >= tsk>end_data && address < tsk>brk)
863
864
goto ok_no_page;
if (mpnt && mpnt == tsk>stk_vma &&
865
866
tsk>rlim[RLIMIT_STACK].rlim_cur
>
mpnt>vm_end
address) {
867
mpnt>vm_start = address;
868
goto ok_no_page;
869
870
tsk>tss.cr2 = address;
871
current>tss.error_code = error_code;
872
current>tss.trap_no = 14;
873
send_sig(SIGSEGV,tsk,1);
874
if (error_code & 4)
875
return;
876 ok_no_page:
877
++tsk>min_flt;
878
get_empty_page(tsk,address);
879 }
880
613 / * check that a page table change is actually needed, and call
614 * the lowlevel function only in that case..
615 */
100
K E A A I O 5 : A K Y
618 {
619
620
621
622
pg_table = PAGE_DIR_OFFSET(tsk>tss.cr3,address);
623
page = *pg_table;
624
if (!page)
625
626
627
return;
if ((page & PAGE_PRESENT) && page < high_memory) {
pg_table = (unsigned long *) ((page & PAGE_MASK) +
PAGE_PTR(address));
628
page = *pg_table;
629
630
631
return;
if (page & PAGE_RW)
632
633
return;
if (!(page & PAGE_COW)) {
634
635
current>tss.cr2 = address;
636
current>tss.error_code = error_code;
637
current>tss.trap_no = 14;
638
639
return;
640
641
642
if (mem_map[MAP_NR(page)] == 1) {
643
644
invalidate();
5 . 2
645
101
return;
646
647
648
return;
649
650
651
*pg_table = 0;
, K 4
[3] K 4 [4]
,
page_faults Linux 4.3 BSD
Unix ( , , , ..).
5.4
, :
do_no_page()
. ;
626 do_wp_page(); ,
, ;
5.5
, :
102
K E A A I O 5 : A K Y
do_no_page()
do_wp_page();
page faults .
__do_wp_page()
do_wp_page(); , ,
(__do_wp_page()).
( ) address do_no_page(); [ do_page_fault() 4.2.1.]
fffff000 843
do_no_page() (address &=0xfffff000)
address;
843851
do_no_page();
, .
629640
do_wp_page();
.
PAGE_MASK,
PAGE_COW, PAGE_RW, PAGE_DIRTY
do_wp_page(); ;
5.2.3
("put_page()" "put_dirty_page()")
1.0.9 Linux.
465 / * This function puts a page in memory at the wanted
address.
466 * It returns the physical address of the page gotten, 0
5 . 2
if
467 * out of memory (either when trying to access pagetable
or
468 * page.)
469 */
470 unsigned long put_page(struct task_struct * tsk,unsigned
long page,
471
472 {
473
474
475
476
477
478
479
return 0;
480
481
page_table = PAGE_DIR_OFFSET(tsk>tss.cr3,address);
482
483
484
485
486
oom(tsk);
487
488
return 0;
489
490
491
if (*page_table) {
492
103
104
K E A A I O 5 : A K Y
493
*page_table = 0;
494
invalidate();
495
496
return page;
499 }
500
501 /*
502 * The previous function doesn't work very well if you
also want to mark
503 * the page dirty: exec.c wants this, as it has earlier
changed the page,
504 * and we want the dirtystatus to be correct (for VM).
Thus the same
505 * routine, but this time we mark it dirty too.
506 */
507 unsigned long put_dirty_page(struct task_struct * tsk,
unsigned long page, unsigned long address)
508 {
509
510
511
512
513
514
if (mem_map[MAP_NR(page)] != 1)
printk("mem_map disagrees with %08lx at
%08lx\n",page,address);
515
page_table = PAGE_DIR_OFFSET(tsk>tss.cr3,address);
516
517
5 . 2
*page_table);
518
else {
519
if (!(tmp = get_free_page(GFP_KERNEL)))
520
return 0;
521
522
free_page(tmp);
523
524
} else {
525
526
527
528
529
530
if (*page_table) {
531
532
*page_table = 0;
533
invalidate();
534
535
return page; }
, K 4 [3], K 4 [4] , , ,
, Linux 4.3 BSD Unix .
105
106
K E A A I O 5 : A K Y
5.5
, :
477 put_page();
;
put_dirty_page() ( )
; ;
5.6
, :
,
"put_dirty_page()" "put_page()"
. "put_dirty_page()" ( ) (,
);
(4) "put_page()" (tsk, page, address,
prot) *page_table.
481, 490 496
"put_page()"
.
.
484489 490494
5 . 2
"put_page()" . , ( ..) .
"get_free_page()",
"put_dirty_page()" 519;
"put_dirty_page()", "get_free_page()" 0; [, , ]
PTRS_PER_
PAGE, PAGE_DIR_OFFSET, BAD_PAGE_TABLE, GFP_KERNEL,
;
;
107
108
K E A A I O 5 : A K Y
,
( C)
LINUX (
Unixlike PCs). , , ,
.
, ()
LINUX, ()
... (wakeup blocked ), () (page faults) () ( ..).
B
[1] B.W. Kernighan and D. Ritchie, " C", , 1990 [ The C Programming
Language, 2nd edition, PrenticeHall Inc., Englewood Cliffs, New Jersey, 1988].
[2] . , , ,
H 11, T B'.
[3] R. Card, E. Dumas and F. Mevel, The Linux Kernel Boo, 2nd edition, John
Wiley and Sons, New York, 1998.
[4] S. J. Leffler and M. K. McKusick, "The Design and Implementation of the 4.3
BSD Unix Operating System", 2nd edition, AddissonWesley Inc., c1990.
[5] URL LINUX:
() "http://www.linux.org", () "http://home.rmi.net/~glabuhn/linux.html",
() "http://www.caldera.com", () "http://www.redhat.com",
() "http://www.dandelion.com/linux", () "http://www.linux.or.jp"
,
,
:
UNIX (
LINUX )
,
UNIX,
.
, ,
, pagefaults , / ,
UNIX ,
UNIX.
( , UNIX)
,
, ..
, , UNIX (LINUX) (hardware) ,
(, ,
, ..).
110
,
, . , ,
UNIXlike .
UNIXlike
,
(SDOS, Windows, Windows NT & 2000, VMS,
MacOS, IBM OS ..), , ,
,
.
.
A A A
2.1
%
doublequotes:
grep "^[^"]*"[^%]*%[^"]*".*$" percent.txt
[ percent.txt
( ^) () ([^]*), () , () % ([^%]*), () %, () ([^]*), () ()
( )
(.*$).]
%:
grep "^[^%]*$" percent.txt
[ percent.txt (
^) , %
([^%]*), ($).]
2.2
:
sed n "/^Address/p" customers.txt
112
( 18 ):
awk "(NR+2) % 4 == 0 { if ($2 >=18) s += 1 }
END { print s }" customers.txt
[ customers.txt () ((NR+2) % 4 == 0
/ ), ()
($2 , , )
18 (if ($2>=18)) ()
s (s+=1). (END)
( s, ).]
2.4
:
sed n "/^Age/,/^Phone/p" customers.txt |
awk "END { printf "Number of customers records = %d\n, NR }"
==
str
$2
[
awk
script,
A A A
113
customers.txt ()
((NR+3) % 4 == 0
/ ) (
$2) str (str=$2), () ((NR+2) % 4 == 0
) ()
($2 , , )
50 (if ($2>=50)) , ,
( str) ( $2) .
( ) awk script
, pipe
sort (+1nr , ).
, sort pipe
sed (3q), (3)
.]
3.1
() Priority based Preemptive (PP)
Gantt
9 10 11 12 13 14 15 16 17 18 19 20
chart
P1 P2 P2 P2 P2 P2 P2 P1 P1 P1 P1 P3 P5 P5 P5 P3 P4 P4 P4 P4
P1
P2
P3
P4
P5
11
44
44
44
44
44
11
13
11
9 10 11 12 13 14 15 16 17 18 19 20
chart
P1 P1 P1 P1 P1 P2 P2 P2 P2 P2 P2 P3 P3 P4 P4 P4 P4 P5 P5 P5
114
P1
P2
P3
P4
P5
41
41
41
41
41
10
10
9 10 11 12 13 14 15 16 17 18 19 20
chart
P1 P1 P1 P1 P1 P3 P3 P2 P2 P2 P2 P2 P2 P5 P5 P5 P4 P4 P4 P4
P1
P2
P3
P4
P5
36
36
36
36
36
12
11
9 10 11 12 13 14 15 16 17 18 19 20
chart
P1 P1 P2 P1 P2 P3 P1 P2 P3 P1 P2 P4 P2 P4 P5 P2 P4 P5 P4 P5
P1
P2
P3
P4
P5
49
49
49
49
49
10
15
10
3.2
() First Come First Serve (FCFS) :
Gantt
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 00
chart
P1 P1 P1 P2 P2 P2 P2 P2 P3 P3 P4 P4 P4 P4 P4 P4 P5 P5 P5 P5
A A A
115
P1
P2
P3
P4
P5
29
25
39
198
198
198
198
198
15
33
36
57
57
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 00
chart
P1 P1 P1 P3 P2 P2 P2 P2 P2 P2 P5 P5 P5 P4 P4 P4 P4 P4 P4 P4
P1
P2
P3
P4
P5
12
43
163
163
163
163
163
15
40
75
25
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 00
chart
P1 P1 P2 P1 P3 P4 P4 P2 P2 P2 P2 P2 P4 P4 P4 P4 P5 P5 P5 P5
P1
P2
P3
P4
P5
25
24
39
198
198
198
198
198
21
53
11
56
57
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 00
chart
P1 P1 P3 P3 P2 P4 P4 P4 P4 P4 P4 P5 P5 P5 P5 P2 P2 P2 P2 P2
116
P1
P2
P3
P4
P5
62
14
185
185
185
185
185
24
90
32
32
12
SRTF
14
18
25
(P1)
(P2)
(P1)
P3
P3
(P2)
P2
P2
P1
P4
12
14
18
25
(P1)
P2
(P1)
P2
P1
(P2)
P2
P3
P3
P4
End
Start
P1
P1
: () Ready
Queue x x+1, () ( ) .
3.3
()
10101 ( 22 ), 5
(VPN = 8 x = 8 3 = 5) :
10101
NU
1110000111
, () 5
PTR
(00000+10101=10101) () ,
PLR ( 10101<11111).
A A A
117
() (10+x) =
13 1110000111111, (
3.3.1) :
( ) = ( ) x PGSIZE + offset =
= (1110000111) x (1000) + (111) = 111000111111,
() PGSIZE = 2x = 8 = 1000, () offset = 111 x=3
() 10
(1110000111)
(10101) . , (10101)
( VALID_BIT
1).
() 10101 :
10101
NU
1110000111
REF_BIT 0 1,
( ) ,
CHANGED_BIT 0 1, .
3.4
() Fisrt In First Out (FIFO):
1 3 5 4 2 7 5 6 2 8 2 5 3 6 8 2 4 1 3 6
Frame 1 1 1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 6 6 6 6
Frame 2
3 3 3 3 3 3 3 3 8 8 8 8 8 8 8 8 8 8 8
Frame 3
5 5 5 5 5 5 5 5 5 5 3 3 3 3 3 3 3 3
Frame 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
Frame 5
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
Frame 6
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
Number of
Page Faults
10
(6 + 4)
118
3 3 3 3 3 3 3 3 8 8 8 8 8 8 8 8 8 8 8
Frame 3
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 1 1 1
Frame 4
4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3
Frame 5
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
Frame 6
7 7 7 7 7 7 7 7 7 7 7 4 4 4 4
Number of
Page Faults
11
(6 + 5)
3 3 3 3 3 3 3 3 8 8 8 8 8 8 8 8 8 8 8
Frame 3
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
Frame 4
4 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3
Frame 5
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
Frame 6
7 7 7 7 7 7 7 7 7 7 7 4 4 4 4
Number of
Page Faults
12
(6 + 6)
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
Frame 3
5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6
Frame 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
Frame 5
2 2 2 2 2 8 8 8 8 8 8 8 8 8 8 8
Frame 6
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
Number of
Page Faults
12
(6 + 6)
A A A
000 00110
storex:
100 00000
load 0:
000 00000
add 6:
001 00110
zerox 1:
010 00001
add 5:
001 00101
print:
110 00000
end:
111 00000
4.2
5!:
load 5:
000 00101
storex:
100 00000
load 0:
000 00000
add 4:
001 00100
zerox 1:
010 00001
storex:
100 00000
load 0:
000 00000
add 3:
001 00011
zerox 1:
010 00001
storex:
100 00000
load 0:
000 00000
119
120
add 2:
001 00010
zerox 1:
010 00001
end:
111 00000
n!
(5), (.. 6! = 720)
( 28 1 = 255).
4.3
62*3:
load 31:
000 11111
storex:
100 00000
storey:
101 00000
load 0:
000 00000
add 3:
001 00100
zerox 1:
010 00001
add 3:
001 00100
zeroy 1:
011 00001
print:
110 00000
end:
111 00000
5.1
O schedule()
278 confuse_gcc2, /
loop (for(;;)) ..., next.
( &init_task)
(p>state=TASK_RUNNING) (p>counter>c). confuse_gcc2 ... 289 (switch_to(next)).
A A A
278
279
280
c = p>counter, next = p;
if (!c) {
281
for_each_task(p)
282
283
5.2
,
(wait_queue),
( 315), ,
pointers
structures (struct wait_queue **q). (q), () () ,
, . next (. .. 364),
. next, , () ( ), (. .. 365).
( 320) () NULL (!q), (
, ) ()
( )
NULL (!(tmp=*q)), , , , (, ).
121
122
5.3
, 916 (address)
(
894 if (address < task_size)).
(TASK_SIZE/
909), () (else/ 919
address>TASK_SIZE+ PAGE_SIZE) () ,
(TASK_SIZE < address < TASK_SIZE+PAGE_SIZE) ( 918). ( 917, 920).
do_page_fault() 894
924
(return), ( ) ifthenelse, :
894
908
}
else {
909
address = TASK_SIZE;
910
914
915
else {
916
919
} else
A A A
. line 920 .
. lines 921923 .
}
}
924 }
909
921923. ifthenelse .
5.4
do_no_page()
swap_in()/ 840 get_empty_page()/ 854
878. ,
swap_in() ,
, get_empty_page()
.
626 , , (page
< high_memory). ,
,
650 .
5.5
477 put_page() , , () (high_memory) . () (page >= high_memory , ), 0
123
124
( 478), () (
) ( 481) (page table
entry), . PAGE_DIR_OFFSET(),
(pointer) page_table.
529534
530 (if (*page_table)),
validbit ( bit 529 / ) 1. () ( 531), () valid bit
0, ( ,
516528) (
dirtybit validbit ..) () invalidate(),
.
126
[5]. (,
, ,
..), .. Unix, Multics, Ultrix ..
[9] URL LINUX:
http://www.linux.org: ( /) .. Linux .
Linux, (office automation, drivers ..),
Linux, (Webpages, , ..)
http://home.rmi.net/~glabuhn/linux.html: Internet Linux
( , , setup drivers, ..).
http://www.caldera.com: caldera
Linux. , , , , .. .
http://www.redhat.com: redhat
Linux. , , , , .. .
http://www.dandelion.com: dandelion
Linux. , , ,
, .. .
http://www.linux.or.jp: /
,
Linux Linux ( ), .
127
130
.
( pipe): .
(process):
UNIXlike .
(state of the process)
.
sed: , (, , /, ..) .
(recursion):
(.. ) .
(option): ,
. .
(directory): ()
.
(root directory):
.
(index register):
, ,
. .
(editor): (, , ,
..).
(shell): (interaction)
UNIXlike ,
. , ,
/ (.. ).
(password):
, .
LINUX: / UNIX .
UNIX: (multitasking)
(multiuser) (mainframes, midrange systems,
workstations ..)
(blocked process): ()
, (
)
(.. ).
(group):
. .
(loginname):
, UNIX.
(ready queue):
,
()
.
(argument): ,
.
, , .
(field): , ,
.., .
(page table):
( ,
, ..). (entry)
.
(shell programming):
131
132
,
, / scripts , (, , ..).
(priority):
. , .
(kernel): ,
,
, .
(pagefault rate):
.
(paging): (
) (),
()
( ) .
(shell script): ,
.
(semaphore): , (.. , ..) .
(assembly):
,
(, ..), .
(assembler):
.
(password):
, .
(accumulator):
,
.
, .
(page fault):
.
(terminal): .
(current directory):
( ).
(filter):
. , ,
.
grep: ,
, (,
).
(process scheduling):
, , ( , ..).
133