You are on page 1of 136

MAMAH. (136.

) 25/7/2003 10:58 1

. ,
.

MAMAH. (136.) 25/7/2003 10:58 2

MAMAH. (136.) 25/7/2003 10:58 3

HPOOPIKH


'


M
M H/Y &

ATPA 2003

MAMAH. (136.) 25/7/2003 10:58 4




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,
.

MAMAH. (136.) 25/7/2003 10:58 5

............................................................................................................................................................................. 9

K 1

, , ,
E .................................................................................................................................... 11
K 2

A Linux

, , ,
E .................................................................................................................................... 15
2.1

E : Grep, Sed & Awk

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

MAMAH. (136.) 25/7/2003 10:58 6

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

MAMAH. (136.) 25/7/2003 10:58 7

EPIEXOMENA

5.1.1 O
5.1.2 O
5.2

..............................................

85

.......................................................................

90

................................................................................ 94
5.2.1 H Page faults

.........................................

5.2.2 Bo Page faults


5.2.3 O

................................

............................................

94
97

102

................................................................................................................................................................................ 108
B .................................................................................................................................................................. 108
E

............................................................................................................................................................................

............................................................................................

109
111

B .............................................................................................................................................. 125

......................................................................................................................................................................

129

MAMAH. (136.) 25/7/2003 10:58 8

MAMAH. (136.) 25/7/2003 10:58 9



.
(,
..), . ,
, (kernel) ,
.
,
,
, ,
, , .
, () , ,
() , , () , , , () ..


, .

MAMAH. (136.) 25/7/2003 10:58 10

10

,
,
,
( ) ,
.
,
UNIX (
LINUX),


.
, ,
. ,
,
. , , , , .
.

MAMAH. (136.) 25/7/2003 10:58 11

UNIX
, LINUX.



,
, :
scripts LINUX, scripts ,
, ..
C
UNIX ( , ..).
C , ( ) .

, .

() (PCB structures, timers, , ..) .

MAMAH. (136.) 25/7/2003 10:58 12

KEAAIO 1:

12


UNIX

LINUX

scripts


(.)

UNIX. To
,
( ).
,
UNIX (PCs LANs
),
LINUX. ( )
UNIX, .
,
UNIX,
(shell) (kernel) .
K 2 LINUX,

. (grep, awk sed)
UNIX,
scripts

.

MAMAH. (136.) 25/7/2003 10:58 13

K 3,
( C), ( ) UNIX ( , , /, ..).
K 4, ,
K 3, , .
, ,
,
.
K 5 , UNIX (
LINUX),
. (, , ..), , , ( C ) .
, , , ,
UNIX,
,
.

13

MAMAH. (136.) 25/7/2003 10:58 14

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]).

MAMAH. (136.) 25/7/2003 10:58 15

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

MAMAH. (136.) 25/7/2003 10:58 16

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 ( ..),
, , ..

MAMAH. (136.) 25/7/2003 10:58 17

2 . 1 E : G R E P, S E D & AW K

17

2.1 E : Grep, Sed & AWK

grep, sed, awk,


, Unixlike . H grep
, , sed , awk
C . Linux
(ls, ps, sort ..) K 1,4 5 [1] K 3 4 [2]
.
, ,
grep, sed awk,
,
( ),
.
2.1

,
4.1, 4.3 4.4
[1]
3.2, 3.5 3.6 [2] .
2.1
( editor vi),
(15) :
5 %
double quotes: ..: printf(The answer is %d.,x)

MAMAH. (136.) 25/7/2003 10:58 18

K E A A I O 2 : A K L I N U X

18

5 %, , , double quotes: ..: We offer a 25% discount for all


of our products

5 %. ..: This line


contains only alphabetic characters.
15 percent.txt.
grep
% double quotes.
grep
%.

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 ( ).

MAMAH. (136.) 25/7/2003 10:58 19

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

MAMAH. (136.) 25/7/2003 10:58 20

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 , X.0[0*](<_>|<_>) (X: ), .


,
:
3.01 65 76 6.9801 4 5.000007 54 6 7. 8.004 15


sed , , (.. 7. ).
(2) sed, pipe.
,
, 2 ,
( ) .

MAMAH. (136.) 25/7/2003 10:58 21

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

lines with no quote marks at all.

sed,
double quote ( )
.
.. :
testfile for trying out
problem
given to this class the other day

( )
difficulties including

( )

2.5
2.4
.
sed,

MAMAH. (136.) 25/7/2003 10:58 22

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

MAMAH. (136.) 25/7/2003 10:58 23

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 :.
, ( )
:

MAMAH. (136.) 25/7/2003 10:58 24

K E A A I O 2 : A K L I N U X

24

Papadopoulos Nikos:Eyripidou 2, Ano Xaraygi:17236, Dafni,


Athina

( 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

MAMAH. (136.) 25/7/2003 10:58 25

2 . 2 S C R I P T S

25

2.2 Scripts

grep, sed awk



,
Linux,
, , (.. for), (.. if),
.. K 4 5 [1], K 4 [2]

, scripts
Linux.
,
scripts
, scripts .
2.10

,
3.8 4.1
[1]
2.4 3.2 [2] .

2.4
customers.txt 2.2, ,
, , /
(45) .
script
:

MAMAH. (136.) 25/7/2003 10:58 26

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) .

MAMAH. (136.) 25/7/2003 10:58 27

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) .

MAMAH. (136.) 25/7/2003 10:58 28

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)

while counter> = (x+1) do

(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 ).

MAMAH. (136.) 25/7/2003 10:58 29

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

MAMAH. (136.) 25/7/2003 10:58 30

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

,
.

; ,
;

MAMAH. (136.) 25/7/2003 10:58 31

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

setuid, , login name ,


.
, setuid giorgos, :
giorgos:32
giorgos:Faidnos_26 5647121

MAMAH. (136.) 25/7/2003 10:58 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),
, ( ):
&&.
.

MAMAH. (136.) 25/7/2003 10:58 33

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 >

MAMAH. (136.) 25/7/2003 10:58 34

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

[1] B.W. Kernighan and R. Pike, UNIX, , A, 1989 [ Unix


Programming Environment, PrenticeHall, Englewood Cliffs, New Jersey,
1984].
[2] R. Petersen and R. Peterson, Linux Programmers Reference, 2nd edition,
Osborne McGrawHill Inc., New York, 1998.
[3] S. J. Leffler and M. K. McKusick, The Design and Implementation of the 4.3
Bsd Unix Operating System, 2nd edition, AddissonWesley, Reading
Massachusetts, 1990.

MAMAH. (136.) 25/7/2003 10:58 35

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.

MAMAH. (136.) 25/7/2003 10:58 36

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) ()
, () , ()

MAMAH. (136.) 25/7/2003 10:58 37

37


() /
. , ,
.

3.1
, :
[1] ( K 48)
,
.. C,
UNIX.
[4] ( K 3 4)
UNIX.

MAMAH. (136.) 25/7/2003 10:58 38

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

(Fist Come Fist Serve, Preemptive Priority, Shortest


Remaining Time First Round Robin), :

P1

P2

P3

P4

P5

12

() , () ( )
, () ( ,
).

MAMAH. (136.) 25/7/2003 10:58 39

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

() Fist Come Fist Serve (FCFS)


Gantt

9 10 11 12 13 14 15 16 17 18 19 20

chart
P1



P2

P3

P4

P5

MAMAH. (136.) 25/7/2003 10:58 40

40

KEAAIO 3: A T UNIX

() Shortest Remaining Time First (SRTF)


Gantt

9 10 11 12 13 14 15 16 17 18 19 20

chart
P1

P2

P3

P4

P5

() Round Robin (RR)


Gantt

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, :

MAMAH. (136.) 25/7/2003 10:58 41

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, , ,
, . ,

.



.
, ,
, ,

,
. , :

MAMAH. (136.) 25/7/2003 10:58 42

42

KEAAIO 3: A T UNIX

(C modules
).
header files ,
(, ..).
ready queue,
( ) , ...
K.M.E.
(.. ,
).
( , PCB ..)
, (.. , , ..). , , , .
( PCB ..) .
, ,
.
(testing)
,
.

, :

. -

MAMAH. (136.) 25/7/2003 10:58 43

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) ,
() ()

MAMAH. (136.) 25/7/2003 10:58 44

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

MAMAH. (136.) 25/7/2003 10:58 45

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

,

.

MAMAH. (136.) 25/7/2003 10:58 46

46

KEAAIO 3: A T UNIX

3.5
,
, , :

( , ) () , () ( ) () (
) .

( , ) () , ()
, ()
() (wait/signal).
,
( Gantt chart, , , ), :
K , ,
, ,
.
, ,
(.. ).
,
(,
..).
, , CPUbound
/bound,
( CPU
).

MAMAH. (136.) 25/7/2003 10:58 47

3.2 E /


,
.
, ,

:
C module
, (read, write ..) ( ..).
(
), ( )
.
( C module) (wait, signal) .
, , ( )
, ( )
.
( ..).
( ..) (block, wakeup)
,
(..
blocked,
).
, , (
) (
).

47

MAMAH. (136.) 25/7/2003 10:58 48

48

KEAAIO 3: A T UNIX

( ,
, block wakeup ..)

.
(testing)
,
.

, :
.
, , CPUbound,
I/Obound ( , ,
).
. () CPUbound
I/Obound;

,

deadlock ( ).
, ,
. , ,
...
( ).

MAMAH. (136.) 25/7/2003 10:58 49

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

Offset (x) bits

x=log2 PGSIZE

,
(PTR: Page Table Base Register).

MAMAH. (136.) 25/7/2003 10:58 50

50

KEAAIO 3: A T UNIX

(PLR: Page Table Length Register). VPN <= PLR,


.
:
VALID_BIT

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

MAMAH. (136.) 25/7/2003 10:58 51

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

() , ()
()
,
.

MAMAH. (136.) 25/7/2003 10:58 52

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)
.

MAMAH. (136.) 25/7/2003 10:58 53

3.3




,
. , :
(
), .. K.M.E. (.. , module
, ).
,
2.1 , . ,
( ) .

, module ...
2.1.
, , .
(, , ..) , , , .. ()
, ()
.
(testing)

.

53

MAMAH. (136.) 25/7/2003 10:58 54

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

MAMAH. (136.) 25/7/2003 10:58 55

3 . 4 A

55

Most Frequently Used), :


1,3,5,4,2,7,5,6,2,8,2,5,3,6,8,2,4,1,3,6
(1) 8
(6) (frames)
(demand paging).
3.4
, :
( ) (
, ),
(page faults),
.
() 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
Frame 2
Frame 3
Frame 4
Frame 5
Frame 6

Number of
Page Faults

MAMAH. (136.) 25/7/2003 10:58 56

56

KEAAIO 3: A T UNIX

() Least Recenly Used (LRU):


1 3 5 4 2 7 5 6 2 8 2 5 3 6 8 2 4 1 3 6
Frame 1
Frame 2
Number of
Page Faults

Frame 3
Frame 4
Frame 5
Frame 6

() Least Frequently Used (LFU):


1 3 5 4 2 7 5 6 2 8 2 5 3 6 8 2 4 1 3 6
Frame 1
Frame 2
Number of
Page Faults

Frame 3
Frame 4
Frame 5
Frame 6

() Most Frequently Used (MFU):


1 3 5 4 2 7 5 6 2 8 2 5 3 6 8 2 4 1 3 6
Frame 1
Frame 2
Frame 3
Frame 4
Frame 5
Frame 6

Number of
Page Faults

MAMAH. (136.) 25/7/2003 10:58 57

3 . 4 A

57

3.4.2 M B: Y

C
.
3.9
,
:
( ),
.
,
.

.
( ) .
, .
, .

page fault

, , page fault ,
.

(FIFO, LRU, LFU, MFU),
modules.

:

MAMAH. (136.) 25/7/2003 10:58 58

58

KEAAIO 3: A T UNIX


,
.
(pagefaults) .
(page fault rate) ,
.
,
. ,
, ,
.

, (, , , ..), ( 3.1 3.3). , , , :
(C modules
).

( ) ,

( 3.4.3) .

header files
(, , , ..).
() K.M.E., () () (

MAMAH. (136.) 25/7/2003 10:58 59

3 . 4 A

,
o pagefault).
(testing)
,
.

( , , ..) :

. (8) (
). .

(
Most Frequently Used )
.
, , ,

(pagefaults
), , ,
(thrashing)

59

MAMAH. (136.) 25/7/2003 10:58 60

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

[1] B.W. Kernighan and D. Ritchie, C, , A, 1990 [ The C Programming


Language, PrenticeHall Inc., Englewood Cliffs, New Jersey, 2nd edition, 1988].
[2] J. L. Peterson and A. Silberschatz, Operating Systems Concepts,
AddisonWesley, World Student Series Edition, Reading Massachusetts, 1985.
[3] . , , ,
H 11, T B'.
[4] S. J. Leffler and M. K. McKusick, The Design and Implementation of the 4.3
Bsd Unix Operating System, 2nd edition, AddissonWesley Inc., Reading
Massachusetts, 1990.
[5] A. S. Tanenbaum, ( ),
, A, 1993 [ Modern
Operating Systems, PrenticeHall Inc., Englewood Cliffs, New Jersey, 1992].

MAMAH. (136.) 25/7/2003 10:58 61

O
UNIX


(, , ) . , ,
,
, .


, , :
()
UNIX,
(assembler),
C ,

,
C ,
, .

readyqueue

MAMAH. (136.) 25/7/2003 10:58 62

62

K E A A I O 4 : O U N I X


/
. ,

UNIX. ,
, ,

.

,
, , ( ,
). ,

.
, ,
, , ,
,
.

4.1

,
:

MAMAH. (136.) 25/7/2003 10:58 63

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.

, ( ) (
() ).

MAMAH. (136.) 25/7/2003 10:58 64

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.

MAMAH. (136.) 25/7/2003 10:58 65

4.1 E


, . :


, .
,
/:
(
... ) ,
.
H Process Control Block (PCB) (
) , (.. , timeslice , ..), (..
, PTR PLR ..).

... (.. round robin) (.. , ..).
(pagefault)
,
pagefault ... , -

65

MAMAH. (136.) 25/7/2003 10:58 66

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.

MAMAH. (136.) 25/7/2003 10:58 67

4.2

67

4.2


UNIX , (...).
, .
4.2.1 Y

4.4
, , , C (..., ..)
. ( ),
4.2.2 4.2.3.

:
(accumulator) (8) ,
.
(accumulator) A7

A0

(index registers) (8)


(x y),
1 0
(loops) .
/ (program counter) (8) , o o
.

MAMAH. (136.) 25/7/2003 10:58 68

68

K E A A I O 4 : O U N I X

M P7

P0

(=2m) (bytes) (8) ( array


M) () 0 1
. P (P=2p)
R (R=2r=2mp) .
0

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, -

MAMAH. (136.) 25/7/2003 10:58 69

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

MAMAH. (136.) 25/7/2003 10:58 70

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, (

MAMAH. (136.) 25/7/2003 10:58 71

4.2

)
.

(assembly)
(assembler)
(8) , (4)
(4) ,
:
load <n>: accumulator <n>

000 n : 000 10010


add <n>:

accumulator
<n> ( accumulator, )
001 n : 001 01010

zerox <n>: <x> ,

,
<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

MAMAH. (136.) 25/7/2003 10:58 72

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

MAMAH. (136.) 25/7/2003 10:58 73

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

MAMAH. (136.) 25/7/2003 10:58 74

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).

MAMAH. (136.) 25/7/2003 10:58 75

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
, , ,

, .

(, ..)
, .
(
) ,

MAMAH. (136.) 25/7/2003 10:58 76

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 ( ).

MAMAH. (136.) 25/7/2003 10:58 77

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

MAMAH. (136.) 25/7/2003 10:58 78

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), -

MAMAH. (136.) 25/7/2003 10:58 79

4 . 3

79

... .
7. end, :
...
.
PCB
.
... (
).
8. 47
.

4.3

( C)
,
.
, Unixlike
,
,
.
4.8
, ,
( , , ), /:
1. /
:

4.2.3 (

MAMAH. (136.) 25/7/2003 10:58 80

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,

MAMAH. (136.) 25/7/2003 10:58 81

4 . 3

LRU) () FIFO.
3. , () First Come First Serve () Round Robin
.
, 3.1.2 ( , ). () , ()
Ganttchart
.
,

()
()
. ,
, ,
(.. ),
.

81

MAMAH. (136.) 25/7/2003 10:58 82

82

K E A A I O 4 : O U N I X


Unixlike
.
C (
) UNIX
,
(PCB structures, , ..)
.
, ,
()
,


.

.
B

[1] B.W. Kernighan and D. Ritchie, C, , 1990 [ The C Programming


Language, 2nd edition, PrenticeHall, Englewwod Cliffs, New Jersey, 1988].
[2] J. L. Peterson and A. Silberschatz, Operating Systems Concepts,
AddisonWesley, World Student Series Edition, AddisonWesley, Reading
Massachusetts, 1985.
[3] . , , ,
H 11, T B'.
[4] S. J. Leffler and M. K. McKusick, The Design and Implementation of the 4.3
Bsd Unix Operating System, 2nd edition, AddissonWesley, Reading
Massachusetts, 1990.
[5] A. S. Tanenbaum, ( ),
, 1993 [ Modern Operating
Systems, PrenticeHall, Englewood Cliffs, New Jersey, 1992].

MAMAH. (136.) 25/7/2003 10:58 83

A K Y
(T Linux)


UNIX,
(
)
Linux.

( )
Linux, , :
Unixlike
, ,

,
C (timers, shift registers
..) ,

(Linux),
(Linux),
Linux
.

(kernel) Linux

Process Control Block


timers

MAMAH. (136.) 25/7/2003 10:58 84

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
.

MAMAH. (136.) 25/7/2003 10:58 85

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

(schedule()) 1.0.9 Linux.


195 unsigned long itimer_ticks = 0;
196 unsigned long itimer_next = ~0;
197 static unsigned long lost_ticks = 0;
198
199 /*
200 * schedule() is the scheduler function. Its a very
simple and nice
201 * scheduler: its not perfect, but certainly works for
most things.
202 * The

one

thing

you

might

signalhandler code here.


203 *

take

look

at

is

the

MAMAH. (136.) 25/7/2003 10:58 86

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;

214 struct task_struct * p;


215 struct task_struct * next;
216 unsigned long ticks;
217
218 /* check alarm, wake up any interruptible tasks that have
got a signal */
219
220

if (intr_count) {

221

printk(Aiee: scheduling in interrupt\n);

222

intr_count = 0;

223

224

cli();

225 ticks = itimer_ticks;


226 itimer_ticks = 0;
227 itimer_next = ~0;
228

sti();

229

need_resched = 0;

MAMAH. (136.) 25/7/2003 10:58 87

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

if (p>it_real_value <= ticks) {

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

} while (p>it_real_value <= ticks);

244

245

p>it_real_value = ticks;

246

if (p>it_real_value < itimer_next)

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

if (p>timeout && p>timeout <= jiffies) {

257

p>timeout = 0;

258

p>state = TASK_RUNNING;

87

MAMAH. (136.) 25/7/2003 10:58 88

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

/* This depends on the values for TASK_XXX */

267

/* This gives smoother scheduling for some things, but */

268

/* can be very unfair under some circumstances, so.. */

269

if (TASK_UNINTERRUPTIBLE >= (unsigned) current>state &&

270

current>counter < current>priority*2) {

271
272

++current>counter;
}

273 #endif
274

c = 1;

275 next = p = &init_task;


276

for (;;) {

277

if ((p = p>next_task) == &init_task)

278

goto confuse_gcc2;

279

if (p>state == TASK_RUNNING && p>counter > c)

280
281

c = p>counter, next = p;
}

282 confuse_gcc2:
283

if (!c) {

284

for_each_task(p)

285
286

p>counter = (p>counter >> 1) + p>priority;


}

287 if(current != next)

MAMAH. (136.) 25/7/2003 10:58 89

5.1 X K.M.E.

288

89

kstat.context_swtch++;

289 switch_to(next);
290

/* Now maybe reload the debug registers */

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;

MAMAH. (136.) 25/7/2003 10:58 90

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()

wake_up_interruprible()) 1.0.9 Linux:

MAMAH. (136.) 25/7/2003 10:58 91

5.1 X K.M.E.

91

308 / * wake_up doesnt wake up stopped processes they have


to be awakened
309 * with signals or similar.
310 *
311 * Note that this doesnt need clisti pairs: interrupts
may not change
312 * the

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

struct wait_queue *tmp;

318

struct task_struct * p;

319
320
321
322
323

if (!q || !(tmp = *q))


return;
do {
if ((p = tmp>task) != NULL) {

324

if ((p>state == TASK_UNINTERRUPTIBLE) ||

325

(p>state == TASK_INTERRUPTIBLE)) {

326

p>state = TASK_RUNNING;

327

if (p>counter > current>counter)

328

need_resched = 1;

329

330

331

if (!tmp>next) {

332

printk(wait_queue is bad (eip = %08lx)\n,((unsigned


long *) q)[1]);

MAMAH. (136.) 25/7/2003 10:58 92

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

} while (tmp != *q);

340 }
341
342 void wake_up_interruptible(struct wait_queue **q)
343 {
344

struct wait_queue *tmp;

345

struct task_struct * p;

346
347
348
349
350

if (!q || !(tmp = *q))


return;
do {
if ((p = tmp>task) != NULL) {

351

if (p>state == TASK_INTERRUPTIBLE) {

352

p>state = TASK_RUNNING;

353

if (p>counter > current>counter)

354

need_resched = 1;

355

356

357

if (!tmp>next) {

358

printk(wait_queue is bad (eip = %08lx)\n,((unsigned


long *) q)[1]);

359

printk(

q = %p\n,q);

360

printk(

*q = %p\n,*q);

361

printk(

tmp = %p\n,tmp);

MAMAH. (136.) 25/7/2003 10:58 93

5.1 X K.M.E.

362

93

break;

363

364

tmp = tmp>next;

365

} while (tmp != *q);

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()

MAMAH. (136.) 25/7/2003 10:58 94

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

unsigned long error_code)


887 {
888

unsigned long address;

pt_regs

*regs,

MAMAH. (136.) 25/7/2003 10:58 95

5 . 2

889

unsigned long user_esp = 0;

890

unsigned int bit;

891
892

/* get the address */

893

__asm__(movl %%cr2,%0:=r (address));

894

if (address < TASK_SIZE) {

895

if (error_code & 4) { /* user mode access? */

896

if (regs>eflags & VM_MASK) {

897

bit = (address 0xA0000) >> PAGE_SHIFT;

898

if (bit < 32)

899

current>screen_bitmap |= 1 << bit;

900

} else

901

user_esp = regs>esp;

902

903

if (error_code & 1)

904

do_wp_page(error_code, address, current, user_esp);

905

else

906

do_no_page(error_code, address, current, user_esp);

907

return;

908

909

address = TASK_SIZE;

910

if (wp_works_ok < 0 && address == 0 && (error_code &


PAGE_PRESENT)) {

911

wp_works_ok = 1;

912

pg0[0] = PAGE_SHARED;

913

printk(This processor honours the WP bit even when in


supervisor mode. Good.\n);

914

return;

915

916

if (address < PAGE_SIZE) {

95

MAMAH. (136.) 25/7/2003 10:58 96

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

printk(Unable to handle kernel paging request);

921

printk( at address %08lx\n,address);

922

die_if_kernel(Oops, regs, error_code);

923

do_exit(SIGKILL);

924 }


, K 4 [3] K 4 [4]
,
(page_faults) Linux 4.3 BSD Unix .
5.3
,
:

916 ( 916920);
;

(return) , .
;

MAMAH. (136.) 25/7/2003 10:58 97

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;
;

5.2.2 Bo Page faults

(do_no_page()
do_wp_page()) 1.0.9 Linux.

.
822 void do_no_page(unsigned long error_code, unsigned long
address,
823

struct task_struct *tsk, unsigned long user_esp)

824 {

MAMAH. (136.) 25/7/2003 10:58 98

98

K E A A I O 5 : A K Y

825

unsigned long tmp;

826

unsigned long page;

827

struct vm_area_struct * mpnt;

828
829

page = get_empty_pgtable(tsk,address);

830

if (!page)

831

return;

832

page &= PAGE_MASK;

833

page += PAGE_PTR(address);

834

tmp = *(unsigned long *) page;

835

if (tmp & PAGE_PRESENT)

836

return;

837

++tsk>rss;

838

if (tmp) {

839

++tsk>maj_flt;

840

swap_in((unsigned long *) page);

841

return;

842

843

address &= 0xfffff000;

844

tmp = 0;

845

for (mpnt = tsk>mmap; mpnt != NULL; mpnt = mpnt>vm_next) {

846

if (address < mpnt>vm_start)

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);

MAMAH. (136.) 25/7/2003 10:58 99

5 . 2

855

99

return;

856

857

mpnt>vm_ops>nopage(error_code, mpnt, address);

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

address tmp > mpnt>vm_start address &&

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

/* user level access? */

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 */

MAMAH. (136.) 25/7/2003 10:58 100

100

K E A A I O 5 : A K Y

616 void do_wp_page(unsigned long error_code, unsigned long address,


617

struct task_struct * tsk, unsigned long user_esp)

618 {
619

unsigned long page;

620

unsigned long * pg_table;

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

if (!(page & PAGE_PRESENT))

630
631

return;
if (page & PAGE_RW)

632
633

return;
if (!(page & PAGE_COW)) {

634

if (user_esp && tsk == current) {

635

current>tss.cr2 = address;

636

current>tss.error_code = error_code;

637

current>tss.trap_no = 14;

638

send_sig(SIGSEGV, tsk, 1);

639

return;

640

641

642

if (mem_map[MAP_NR(page)] == 1) {

643

*pg_table |= PAGE_RW | PAGE_DIRTY;

644

invalidate();

MAMAH. (136.) 25/7/2003 10:58 101

5 . 2

645

101

return;

646

647

__do_wp_page(error_code, address, tsk, user_esp);

648

return;

649

650

printk(bad page directory entry %08lx\n,page);

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

, :

MAMAH. (136.) 25/7/2003 10:58 102

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

MAMAH. (136.) 25/7/2003 10:58 103

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

unsigned long address,int prot)

472 {
473

unsigned long *page_table;

474
475

if ((prot & (PAGE_MASK|PAGE_PRESENT)) != PAGE_PRESENT)

476
477

printk("put_page: prot = %08x\n",prot);


if (page >= high_memory) {

478

printk("put_page: trying to put page %08lx at


%08lx\n",page,address);

479

return 0;

480

481

page_table = PAGE_DIR_OFFSET(tsk>tss.cr3,address);

482

if ((*page_table) & PAGE_PRESENT)

483
484

page_table = (unsigned long *) (PAGE_MASK & *page_table);


else {

485

printk("put_page: bad page directory entry\n");

486

oom(tsk);

487

*page_table = BAD_PAGETABLE | PAGE_TABLE;

488

return 0;

489

490

page_table += (address >> PAGE_SHIFT) & (PTRS_PER_PAGE1);

491

if (*page_table) {

492

printk("put_page: page already exists\n");

103

MAMAH. (136.) 25/7/2003 10:58 104

104

K E A A I O 5 : A K Y

493

*page_table = 0;

494

invalidate();

495

496

*page_table = page | prot;

497 /* no need for invalidate */


498

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

unsigned long tmp, *page_table;

510
511
512

if (page >= high_memory)


printk("put_dirty_page: trying to put page %08lx at
%08lx\n",page,address);

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

if (PAGE_PRESENT & *page_table)

517

page_table = (unsigned long *) (PAGE_MASK &

MAMAH. (136.) 25/7/2003 10:58 105

5 . 2

*page_table);
518

else {

519

if (!(tmp = get_free_page(GFP_KERNEL)))

520

return 0;

521

if (PAGE_PRESENT & *page_table) {

522

free_page(tmp);

523

page_table = (unsigned long *) (PAGE_MASK &


*page_table);

524

} else {

525

*page_table = tmp | PAGE_TABLE;

526

page_table = (unsigned long *) tmp;

527

528

529

page_table += (address >> PAGE_SHIFT) & (PTRS_PER_PAGE1);

530

if (*page_table) {

531

printk("put_dirty_page: page already exists\n");

532

*page_table = 0;

533

invalidate();

534

535

*page_table = page | (PAGE_DIRTY | PAGE_PRIVATE);

536 /* no need for invalidate */


537

return page; }


, K 4 [3], K 4 [4] , , ,
, Linux 4.3 BSD Unix .

105

MAMAH. (136.) 25/7/2003 10:58 106

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

MAMAH. (136.) 25/7/2003 10:58 107

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

MAMAH. (136.) 25/7/2003 10:58 108

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"

MAMAH. (136.) 25/7/2003 10:58 109


,
,
:
UNIX (
LINUX )

,
UNIX,
.
, ,
, pagefaults , / ,
UNIX ,
UNIX.
( , UNIX)
,
, ..
, , UNIX (LINUX) (hardware) ,
(, ,
, ..).

MAMAH. (136.) 25/7/2003 10:58 110

110

,
, . , ,
UNIXlike .

UNIXlike
,

(SDOS, Windows, Windows NT & 2000, VMS,
MacOS, IBM OS ..), , ,
,

.
.

MAMAH. (136.) 25/7/2003 10:58 111

A A A

2.1
%
doublequotes:
grep "^[^"]*"[^%]*%[^"]*".*$" percent.txt

[ percent.txt
( ^) () ([^]*), () , () % ([^%]*), () %, () ([^]*), () ()
( )
(.*$).]
%:
grep "^[^%]*$" percent.txt

[ percent.txt (
^) , %
([^%]*), ($).]
2.2
:
sed n "/^Address/p" customers.txt

[ (n, p) customers.txt Address (/^Address/).]


:
sed "/^Age/,/^Phone/d" customers.txt

[ (d) customers.txt Age (/^Age/)


Phone (/^Phone/). ,
.]
2.3
( )

MAMAH. (136.) 25/7/2003 10:58 112

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 }"

[ sed , customers.txt ( 2.2 n, p


d). pipe
awk script,
(END) ( NR, ,
) .]
2.5
(3)
( , , (50) ) :
awk "(NR+3)

==

str

$2

(NR+2) % 4 == 0 { if ($2 >= 50) printf "%s %d\n", str, $2 }"


customers.txt |
sort +1nr | sed 3q

[
awk
script,

MAMAH. (136.) 25/7/2003 10:58 113

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

() Fist Come Fist Serve (FCFS)


Gantt

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

MAMAH. (136.) 25/7/2003 10:58 114

114

P1

P2

P3

P4

P5

41

41

41

41

41

10

10

() Shortest Remaining Time First (SRTF)


Gantt

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

() Round Robin (RR)


Gantt

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

MAMAH. (136.) 25/7/2003 10:58 115

A A A

115

P1

P2

P3

P4

P5

29

25

39

198

198

198

198

198

15

33

36

57

57

() Shortest Remaining Time First (SRTF) :


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 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

() 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 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

() Shortest Remaining Time First (SRTF) :


Gantt

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

MAMAH. (136.) 25/7/2003 10:58 116

116

P1

P2

P3

P4

P5

62

14

185

185

185

185

185

24

90

32

32

() Ready Queue 0,12,14,18,25:


Ready Queue
FCFS
0

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).

MAMAH. (136.) 25/7/2003 10:58 117

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)

MAMAH. (136.) 25/7/2003 10:58 118

118

() Least Recenly Used (LRU):


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 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)

() Least Frequently Used (LFU):


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 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)

() Most Frequently Used (MFU):


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 1 1 1 2 5 5 5 5 2 2 1 1 1
Frame 2

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)

MAMAH. (136.) 25/7/2003 10:58 119

A A A

: pagefaults ( (6) pagefaults


,
demandpaging, , o ).
4.1
62+5:
load 6:

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

MAMAH. (136.) 25/7/2003 10:58 120

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)).

MAMAH. (136.) 25/7/2003 10:58 121

A A A

276286 goto, whileloop,



confuse_gcc2, :
277

while ((p = p>next_task) != &init_task)

278

if (p>state == TASK_RUNNING && p>counter > c)

279
280

c = p>counter, next = p;
if (!c) {

281

for_each_task(p)

282
283

p>counter = (p>counter >> 1) + p>priority;


}

5.2
,
(wait_queue),
( 315), ,
pointers
structures (struct wait_queue **q). (q), () () ,
, . next (. .. 364),

. next, , () ( ), (. .. 365).

( 320) () NULL (!q), (
, ) ()
( )
NULL (!(tmp=*q)), , , , (, ).

121

MAMAH. (136.) 25/7/2003 10:58 122

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

if (address < TASK_SIZE) {


. lines 895906 ..

908

}
else {

909

address = TASK_SIZE;

910

if (wp_works_ok < 0 && address == 0 && (error_code &


PAGE_PRESENT)) {
. lines 911913 .

914

915

else {

916

if (address < PAGE_SIZE) {


. lines 917918 .

919

} else

MAMAH. (136.) 25/7/2003 10:58 123

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

MAMAH. (136.) 25/7/2003 10:58 124

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(),

.

MAMAH. (136.) 25/7/2003 10:58 125

[1] B.W. Kernighan and R. Pike, UNIX, , 1989 [ Unix Programming


Environment, PrenticeHall, Englewood Cliffs, New Jersey, 1984].
( ) UNIX , .. (ls, ps, grep, ..), scripts
UNIX (awk, sed scripts ..),
( , , /, ..) ..
[2] B.W. Kernighan and D. Ritchie, C, , A, 1990 [ The C Programming
Language, 2nd edition, PrenticeHall, Englewood Cliffs, New Jersey, 1988].
C (Ansi C)
(
/, , ..). , ,
Ansi C.
[3] R. Petersen and R. Peterson, Linux Programmer's Reference, 2nd edition,
Osborne McGrawHill Inc., New York, 1998.
Linux,
[1] UNIX.

,
UNIX.
[4] R. Card, E. Dumas and F. Mevel, The Linux Kernel Book, 2nd edition, John
Wiley and Sons, New York, 1998.
,
.. Linux. Linux
( , , , / ,
..)
, .

MAMAH. (136.) 25/7/2003 10:58 126

126

[5] J. L. Peterson and A. Silberschatz, Operating Systems Concepts, World Student


Series Edition, AddisonWesley Inc., Reading, Massachusetts, 1985.

.
( )
,
(.. Unix, Linux), , ,
, /, , ..
[6] . , ,
(...), H 11, T B'.

. (, ..) [5].
,
.
[7] S. J. Leffler and M. K. McKusick, The Design and Implementation of the 4.3
Bsd Unix Operating System, 2nd edition, AddissonWesley Inc., Reading,
Massachusetts, 1990.
/
.. Unix (4.3 BSD).
(.. , ..),
( ..) .
[8] A. S. Tanenbaum, ( '), , A, 1993 [ Modern Operating
Systems, PrenticeHall Inc., Englewood Cliffs, New Jersey, 1992].
,

MAMAH. (136.) 25/7/2003 10:58 127

[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

MAMAH. (136.) 25/7/2003 10:58 128

MAMAH. (136.) 25/7/2003 10:58 129

(file permissions): (.. , , ) .


(redirection):

.
(page replacement): ,
, () () .
(arithmetic logic unit): (, ..)
,
/ .
(file): (
) .
(process wakeup): ( ) ,
(.. ).
(dirty page): ,
.
(machine language): ,
, ( )
.
awk:
C ( , , / ..),
scripts .
(parent directory):

MAMAH. (136.) 25/7/2003 10:58 130

130

.
( pipe): .
(process):
UNIXlike .
(state of the process)
.
sed: , (, , /, ..) .
(recursion):
(.. ) .
(option): ,
. .
(directory): ()
.
(root directory):

.
(index register):
, ,
. .
(editor): (, , ,
..).
(shell): (interaction)
UNIXlike ,
. , ,
/ (.. ).

MAMAH. (136.) 25/7/2003 10:58 131

(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

MAMAH. (136.) 25/7/2003 10:58 132

132

,
, / scripts , (, , ..).
(priority):
. , .
(kernel): ,
,
, .
(pagefault rate):


.
(paging): (
) (),
()
( ) .
(shell script): ,
.
(semaphore): , (.. , ..) .
(assembly):
,
(, ..), .
(assembler):

.

MAMAH. (136.) 25/7/2003 10:58 133

(password):
, .
(accumulator):
,
.


, .
(page fault):
.
(terminal): .
(current directory):
( ).
(filter):
. , ,
.
grep: ,
, (,
).
(process scheduling):
, , ( , ..).

133

MAMAH. (136.) 25/7/2003 10:58 134

MAMAH. (136.) 25/7/2003 10:58 135

MAMAH. (136.) 25/7/2003 10:58 136

You might also like