Вы находитесь на странице: 1из 155

-

..

-
2014

.. . : ,
2014. 155 .

,
.
,
.

.
,

,
.
, , ,
230100 231000
,
.
,

.

11 2014 ., 3.

2009 ,
12 ,
.

20092018 . 2011
-
,

-
, , 2014
.., 2014


.............................................................................................................. 5
1. ....................................... 8
1.1.
.......................................................................................................... 8
1.2. ..................................... 12
1.3. ...................................... 13
1.3.1. (Transparency) ....................................................... 13
1.3.2. (Openness) ................................................................. 16
1.3.3. (Scalability) .................................................. 18
1.3.4. ....................... 23
1.4.
............................................................................ 24
1.5. ................................ 27
1.5.1. ......................................................................... 27
1.5.2. ............ 30
1.5.3. ............................................................ 33
1.5.4. ........................................................ 34
1.5.5. ................... 42
2. ...................................... 45
2.1. .................................................... 45
2.2. - .................................. 52
2.3. ............................................................ 56
2.4. .......................... 61
2.5. ............................................................................... 63
3. ........................................................................... 65
3.1. ......................... 65
3.2. .............................................................. 68
3.2.1 ........................................................................ 69
3.2.2 ............................................................... 71
3.3. .................................................................................. 75
3.3.1 ........................................................................ 79
3.3.2 .................................................................. 81
3.4. .................. 82
3.4.1 .................. 83
3.4.2 , ................................. 85
3.4.3 - ............................................ 90

3.5. ................................................................................ 93
3.5.1 ........................................................................ 95
4. ............... 96
4.1. ............................................................................... 96
4.2. ......................................................... 101
4.3. ............................ 103
4.3.1 ..................................................................... 103
4.3.2 - ....................................................... 109
4.3.3 .............................................. 114
4.4. ..................................... 132
4.4.1 - ...................... 133
4.4.2 ............ 138
....................................................................................... 152
.............................................................................. 152
.................................................................. 152


,

. ,
,
, .
,
. ,

.
. ,
,
. , ,

, ,
, .
,
, "
" .
,
.
,
.
,
.
.

.
,
. , ,
,


.
. [2, 6] . [3, 7].
.
,
, ,
. , ,
-,
, ,
5

.
.
. ,

. ,
,
. ,
, ,
,

.
,

.

, ,

,
.

.
, ,

.
,
.
, .
, ,
" ",
.
,
,
, , ,
.
,

.
,


[1-7]
[1-30].
6

, , ,
" "
" ", "
" .
,

.
, , "
",
.
mkosyakov@gmail.com
, .

1.

1.1.
(. distributed computing)
,
(.
distributed systems).

,
.
, ..

. ,

,
.



.

,
.
,
.

(Leslie
Lamport). , ,
, ,
, ,
.
, , ,
, ,
(. single point of failure).

. (Andrew S. Tanenbaum)
,
.
,
.

8

,
(. middleware).
, ,

.
,
.

,
,

,
.

,

()
,

.
,
.

" "
, ,
, ,
, .


,
(
),
.
,
.
, , ,
. ,
"
" (. Single Instruction - Multiple Data, SIMD),

,
, ,
, ,
.
:
.
9


,
.
,
,
,
.
,
,
.
,
.
. 1.1; ,
() .

. 1.1.
.

, ,
,
.
:

.
.
, ,
, ,
.
. ,

10


. ,

.
,


(. Distributed Shared Memory,
DSM). ,
,

,
,
.
, ,

.
. ,
, ,
.
,
().
(. Cluster Of Workstation, COW),
(),
.

. COW
-
.
, Google
COW.
. ,
,
, ,
.
,
,
. , ,
,
.

11

1.2.

.
:
.

.
.
.

.

.
.

. (
, ,
)

.

. ,
.



.
.
.

( )
.

, ,
. , 1
2
.

.

,

12

,
.
. ""
,
( ),
.

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

.

. ,
(. Triple Modular Redundancy, TMR)
,
,
.
1.3.

: (. transparency), (. openness),
(. security), (. scalability).
, ,
,
.
1.3.1. (Transparency)

, ,
,

.
Reference
Model for Open Distributed Processing (RM-ODP)
. .

13

(. access transparency).
,

.
, , ,
, ,

.
(. application programming interface, API)
,
,
, .
(. location transparency).

.
, .

. ,
user@company.com
,
.
\\server\foo ,
, ,
.
(. migration transparency).

. ,

. ,
, ,
. ,


,
.
,

.

(.
relocation
transparency).

. ,
14

. ,

, ,
.
, ""
.
(. replication transparency).

(),
, ,
.
, ,
, .
, , ,
.
(. concurrency
transparency).

( )
,
. ,
(). ,
,
, , ,
()
.
(. failure transparency). ,
,


,
. , ,

,

.

. , ,
,

. ,
. - ,
, ,
, , .
15


. ,

.
,
,


. ,
,
. , ,

, ,
. , , ,
,
.
1.3.2. (Openness)
, IEEE POSIX 1003.0,
,
() , ,
, :



( , );

()


(, );

,
( ).

, , ,
, ,
,
, .

, ..
.

. ,
,
.

16


, ,

. ,
.
,
,
, .
, .. ,
, ..,
(. Interface
Definition Language, IDL). , .. ,
, ,
, .

,
, ,
, . ,

,
. ,
(, )
,
. ,

. , ,
A,
B, ,
. .
,

(-,
, ).

, .


.
. ,

.

17

1.3.3. (Scalability)
,


. ,

. ,
.

, ,
,
.
, , ,
, .
,
:
, ,

,
.
:

.


.


, ,

()
.

, ,

.

18

.


, . ,
,

(). ,
,
, , ,
.

( ),
,
. ,
,
.

(. Domain Name Service, DNS),
.
DNS IP-
.
DNS
DNS-,
. DNS
,
,
.
,
. ,

,
.


.
,
.
,
,
:
. ,

,
19

. , ,

,
. ,
.
,

,
.
: ( / )

,
. , ,
,
.
. ,
:
,
.

,
: ,
, .
.

.
,
,

.

-
, -
. , ,
,


, ..
.

, ,

20


.
.

.


.
,
, ,
(. synchronous communication).
, - ,
. ,
.

,
, .

,

(. point-to-point). ,

,
. ,
, ,

.
. ,
, ,
. ,
, .
.

,
:
. ,
.
(. distribution),
(. replication) (. caching).


.
,
21


.
DNS,
DNS- ,
DNS-.

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

,
.

,
.
, ,
. , ,
(. asynchronous
communication),
,
. , ,

.
. ,

.
,

. ,


.
Java Javascript.
22

1.3.4.

.
,

.


.
90-
Sun Microsystems "
"
, .
: " , ,
, . , ,
, .
:
1.
.
2.
.
3.
.
4.
.
5.
.
6.
.
7.
.
8.
".
,

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



.

23

1.4.



,

(). ,
,
(. middleware).


,
.




. .

. 1.2. .

.

. 1.2 , ,
, " "
24

1 2.
,

,
.
,

, .


,

send() receive().

. 1.3.

. 1.3.
.

,
. ,

.
,
, ..
, . ,
,
25

,
. ,
,
,
.
.
,

,

. ,
,
. ,
, ,
,
, / ,
, .

( ) ,


. ,

, Sun RPC (. Remote
Procedure Call), ,
ISIS. ,
(. distributed objects),

,
.
, , ,
.
CORBA (. Common
Object Request Broker Architecture), Object Management Group,
Java RMI (. Remote Method
Invocation) DCOM (.
Distributed COM) Microsoft,
Windows.
,
,
, ,

26

, .
, CORBA ,
, ,
. , ,
,
.

.

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

,

, ..
.
1.5.
1.5.1.

,
.
,
, ,
.
,
,

.

, , ,

. ,
,
.
, ,
27

, . ,
: ,
,
,
.
(. clock skew),

UTC (Coordinated Universal Time)
(. clock drift rate) . . 1.4.

. 1.4. UTC;
, .

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

,

.

28


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

()

()

()
. 1.5. .


. ,
9:00 , .
, . 1.5, $10.
, . 1.5,

29


, ..
, .
, $0. ,
,
. ,
,
.
""
,
. "" ,
, ,
,
. , ,
, , ..
.
, , ,
. , . 1.5,
, ..
.
9:00 , $10.
, 9:01 ,
, 8:59.
9:00
.
1.5.2.

,

.
:

,
.
.
,
.

30


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


. ,

.
.
, , ,
.
,
,
.

:
,
.

:
, .
, A B
, B
C .

.



. ,

,
.
, , ,
. , , ,
FTP
. ,

, ,
31

, ,
.
,

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

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

, . ,
, ( ,
, ,
). ,
? ,
. ,
"!".
, , 3 , , ,
10 ?
- ,
:
, , min , max .
,
"!", min .
1
. ,
, (max min
+ 1) .

32

1.5.3.

(, ),
, , ..

.

.

A, B, C .
" ".
"Re:
".

:
1.
.
2.
, .
3.

, .

,
. , ,
. 1.6,
:
1.
"Re: ".
2.
" ".
3.
"Re: ".

. 1.6. , .

, ,
,
33


-. , m1, m2 m3
t1, t2 t3, t1<t2<t3.

, .
, ,
.
,

. . ,
, .
(. logical clock),
(. logical time),
,
.
(
) .
, ,
.
1.5.4.

send() receive(),
. send()
: ,
-
. ,
:
send(void *sendbuf, int count, int dest),
sendbuf , ,
count ,
dest -.

receive()
: -,
(
, ),
-,
,
:
34

receive(void *recvbuf, int count, int source),


recvbuf , ,
count ,
source -.

send() receive()
, P1 P2,
P2 .
P1

P2

a = 100;
send(&a, 1, 2);
a = 0;

receive(&a, 1, 1);
printf("%d\n", a);

, P1
"a" send(). ,
send() P2
100, . , P2
"a" send().

-
() . ,
send()

, , P2
100.

P1 ,
. ,

, .
, ,
send()
.
.
/ .
send() ,
receive()
-.

35

(. handshake)
. ,
- ,
-
,
. -
,
receive().
, .
. 1.7,
, ,
/ , ..
,
, .

()

()

()
. 1.7. / ;
() send(), () send() receive()
, () receive().

. 1.7 , /
, send() receive()
.

. ,

36

,
.
, /
,
, (. deadlock).
,
:
P1

P2

send(&a, 1, 2);
receive(&b, 1, 2);

send(&a, 1, 1);
receive(&b, 1, 1);


"" P1 P2. ,
send() receive()
/ , send() P1
receive() P2,
send() P2 receive() P1.

.
/ .
,
, , ,
- ,

.
-
(
). send()
, ,
- , ..

.
,
-
receive().
.
,
, .
- ,
receive(), ,

37

,
.

, ,
. ,

, .
, /

, , ,
. send()
,

, -
. ,
receive(),
.


. 1.8.

()

()

. 1.8. / ;
() send(), () receive().

,
, ,
, ,
,
/ , . ,

38

(..
send() receive() ),

, .
,
,
.

:
P1

P2

for (i = 0; i < 1000; i++)


{
produce_data(&a);
send(&a, 1, 2);
}

for (i = 0; i < 1000; i++)


{
receive(&a, 1, 1);
consume_data(&a);
}

P1 1000
, P2 . , P2
, P1.

,
. ,
, .
send(),
, ,
receive(),
.
,

.

.

.

, ,
, . ,
, receive()
-
. , ,

39

, ..
, :
P1

P2

receive(&a, 1, 2);
send(&b, 1, 2);

receive(&a, 1, 1);
send(&b, 1, 1);

,
receive().

send(),
receive()
.
:
P1

P2

send(&a, 1, 2);
receive(&b, 1, 2);

send(&a, 1, 1);
receive(&b, 1, 1);

send() ,
-
.
,
.
,
. /

.
,

,
.
/ .


, .

,
.
send() receive() .

40


, ,
send() receive()
.
/
,
, ,
, ,
. ,
send() receive() .
,
,
send() receive().
/
, .
send() receive()
,
. ,
,
. ,

.
. 1.9
/ ,
/
.

()

()

. 1.9. / ;
() , () .

41

, -

. -
receive(),
.
, ,

,
send() receive().
. 1.9.
,

.
-
.
receive()

. ,
,
.
receive() .
. 1.9,
/ ,
.
,

,

.
,

.
, ,
, .
1.5.5.



. ,

-
42

-,
.
.
.
.

,
, .
send()
, , ,
,
receive().
,
.

,
, .. send()
,
receive(). , ,
. ,
receive()
(. acknowledgement)
send().

send() receive()
.
.

. send()
-.
, ,
, , ,
. ,
, ..
FIFO (. First In First Out),
,
. receive()
(. acknowledgement)
.


, ..
.
43

,
,

, .
,
send() .
,
.
, .

44

2.


.

.
(
)
,
.
"" ,

. ,
, ,
(
,
).

,
.
,
.

, ,
,
.
2.1.
N
{P1, P2, PN}. Pi
Pj, ,
Pi Pj Cij.
.
,
,
.
,
,
.
. , ,
45

, , ..
,
.

,
. () -
. ,
" ",
..
. ,
, ,
.
,
.

(. states),
,
(. initial states) (. events).
, ,
,
, :
( ,
, )
( , ,
).
(. internal events),
(. send events) (. receive
events). ,

, , ,
.
,
.
(1) , ;
(2) s ;
(3) s' ;
(4) , ;
(5) m, ( ,
, ),
( , ,
).
(, s, s', m, ), m null,
, .
46

P
. eix x-
Pi, 1 i N. ,
,
. eix(s) s',
Pi s eix.
(. run, execution) Pi
ei0, ei1, eix, eix+1, si0
Pi x 0
six+1 = eix(six). Pi Ri:
Ri = (Ei, i),
Ei Pi, i

Pi. ei i ei' , ei ei'
Pi.
, , ,
.
S (. global state)
,
. (. initial global state)
,
, .
,
,
.
E = Ei ,
.
, = (,
s, s', m, ), S
, (1) S
s (2) , ,
, m
. e(S)
e
S. e(S) ,
S. e(S)
S , ,
.
1.
e(S)
s'.
2.
, ,
, e(S)

47

3.

S m,
.
, ,
, e(S)
S m,
.

e0, e1, ex, ex+1,


,
ex Sx, S0
, x 0
Sx+1 = ex(Sx).
R. S
R,
k 0, ek(Sk) = S.

(. token).
1 2 12 21, .
. 2.1.

. 2.1. .

,
.
s s', s ,
, s' , .
1 s', 2
s, .. 1.
: (1)
s' s (2)
s s'.

. 2.2.

48

. 2.2. .


. 2.3.

S0 S.

: (1) (2)
"1 , 2 , 2
". "1 , 2
"
, .. "2 "
, 2 s.

. 2.3. .

(.
49

. 2.1), 1 2
. 2.4. 1
s1, 2 s2.

()

()

. 2.4. () 1 () 2.

. 2.5. ,

, , .

. 2.5. .

, S0
"1 m" "2 m' ". ,
, S0
, . ,
"1 m" S0
S1, 1 s1', 2 s2,
50

12 m, 21 .
"2 m' " S0
S1', 1 s1,
2 s2', 12 , 21 m'.

. 2.5 ,
, .
(. fairness).

(.
fair executions).
,

,
- ,
.
,

,
- ,
.
, ,
, ,
, .
,
, , ,
.
(. safety) (. liveness).
, ,
,
.
,
: .
,
, "- ".
, ,

.
;
,

51


.
, ,
, - . ,
, ,
: , , ,
. , ,


.

.
. ,
, "-
". , ,

.

, ,
.
2.2. -
,

. , e
e', e e'.
R = (e0, e1, ex, ex+1, ).

(S0, S1, Sx, Sx+1, ) , Sx+1 = ex(Sx) x 0.
, R
: R
i i, 1 i N,

. R
i, i = (i, s, s', m, ) ,
i s. , R
,
S0
(S0, S1, Sx, Sx+1, ).

- .
. 2.6. Pi

52

. i
i ,
. ,
, , -
.
Pi ei ei'
, ei i ei', .. ei
ei' Pi.
. , . 2.6 ,
P2, ,
,
.
. m
ei, m
ej', ei ej'
. R
.

, , ,
.

. 2.6. -
.

,
R, -
""
53

, ,
(. . 2.6). ,
R ,
,
.
E ,
,
.

. ,

,
. , S
, ei ej ,
Pi Pj, .. i j,
S. ei ej(S),
ej ei(S) ei (ej(S)) = ej (ei(S)).

i = (i, si, si', mi, i) j = (j, sj, sj', mj, j), i j ,
Pi Pj.
, ei ej
, .. mi mj .


S, . Si
, S
ei, .. Si = ei(S). . 2.1, Si
S i , ,
i. , i
si', mi i, ei
, i, ei
. mi mj , sj
Pj S Si, j
Si.
, i
Sj = ej(S).
Sij = j(Si).
Pi Pj si' sj', mi
i, , ei,
mj j, ,
ej.
Sji = i(Sj), .. Sij = Sji, .

54

, ,
:
1.
i = j, .. ei ej ,
2.
ei ej
.
, ,
,
. ,
, ..
S Si Sij S Sj Sji .. Si Sj,
Sij = Sji.
, -
, , .
E , .
-
, :
1.
ei ei' Pi
ei i ei', .. ei ei' Pi, ei ei';
2.
ei ej'
, ei ej';
3.
, .. ei ej' ej' ek'', ei ek''.
ei ej' , ei ej', ej'
ei. ,
-
ei ej', ,
, ,
. ,
. 2.6 e11 e33 e33 e26.
-
. " " (.
happened before). ei ej' "ei ej' ".
-
, " ei
ej' ", " ej' ei ". ,

, ei ej' ,
, ei
ej'. , " ej'
ei ". , . 2.6 e26 ""
, .
55

-
E
, ei
ej', ei ej', ej' ei.
ei ej' ei
/ ej' , ej'
ei , , ei
ej'. , , ei
/ ej', ej' "
" ei, ,
ei Pi. , . 2.6
e1 3
/ e33 e24
/ e31.
:

ei ej': ei
/ ej '
/ ej '
/ ei ;

ei ej': ei ej' ej'


/ ei .
ei ej', ei
/ ej ' ej '
/ ei,
(. concurrent) (. independent)
ei || ej.
, . 2.6, e13 || e33
e24 || e31.
, || , ..
(ei || ej') (ej' || ek'')
/ ei || ek''. , . 2.6 e33 || e24 e24 || e15,
e33 ||/ e15.
ei ej',
, ei ej', ej' ei,
ei || ej'.
2.3.
,
, -
, .

,
.
R = (e0, e1, ex, ex+1, )
(S0, S1, Sx, Sx+1, ),
Sx+1 = ex(Sx) x 0. R
= (0, 1, x, x+1, ) , x = e(x),

{0, , k 1}, R ,
k . R
- , x y x < y, ..

56

y x,
y .
= (0, 1, x, x+1, )
R, - .

S0. R ,
k (0 = S0,
1, k), x+1 = x(x), 0 x k 1,
Sk R.

x (0 = S0, 1, x, x+1, )
, x+1 , x
x.
, 0 y x 1 y
y y+1 = y(y). x ,
Pi, x = (i, s, s', m, ). x
x, (1) x i
s (2) x ,
m .
, x i
s .
, -
Pi i. ,
Pi ,
R.
1: x Pi .
x Pi
si0. x Pi
R, .. Pi si0 .
s = si0.
2: x Pi
. Pi,
x , ei = (i, si, si', mi, i).
x Pi si'. ei
Pi, x
R, s = si'.
, m
, x ,
,
,
R. x
,
R. , x
57


e(x) = x R.
, x x
x, x+1
x(x).
, , R ,
k
Sk R.
R Pi, Sk Pi
si0.
Pi, Pi k
si0. Pi Sk ,
Pi
R.
Pi . , Pi k
, Sk.

k
S ,
,
R. R ,

k .
, k = Sk, .
R
, - R
. , , R
R ~ .
. 2.7. -
, , 2.6.

R.
""
"" , , ,
,
.

58

. 2.7. - ,
2.6.

, . 2.6 . 2.7
,
.
, . 2.6 S,
, e13 e23,
.
. 2.7
, .. , e23,
, e13.
,

,
, ..
.
, ..
,
. . ,
, ,
e13 e23, .
isSim,
true,
, false .
2.6, isSim
true, . 2.7
59

false. , ,
,
isSim .
~
.
(. computation)
:
= (E, ).
R
(. linear extension) , ..
<,
- , ..
ei ej': ei ej' ei < ej'.
,
ei ej' , ei
/ ej',
< ,
ej' < ei. , ei ej'
, R
, ei ej',
, ej' ei.
,
, , ,
.

, ..
.
,

.
(. relevant events). ,
,
.
,

(. checkpoints). ER E
, R
ER, .. ei, ej' ER: ei R ej' ei ej'.
,
R,
= (ER, R).
60

2.4.

ej'
ei, ei ej', ej' ""
ei.
ei "" ej', Past(ej'):
Past(ej') = {ei: ei , ei ej'}.
Past(ej') ()
ej', . 2.8.
Past(ej') , Pi, Pasti(ej').
Pasti(ej') i.
max(Pasti(ej')) . ,
max(Pasti(ej')) Pi,
ej' (. . 2.8). ,
max(Pasti(ej')) i j
.
P(ej') =
max(Pasti(ej'))
, ej',
ej'. ,
ei , ej', ,
Pi ei, ej'.
Past(ej') ,
ej'.

. 2.8. .


. , () Future(ej') ej'

61

ei, ej' (.
. 2.8):
Future(ej') = {ei: ei , ej' ei}.
Futurei(ej') Future(ej'),
Pi, min(Futurei(ej'))
Pi,
ej'. , min(Futurei(ej'))
i j .
F(ej') =
min(Futurei(ej'))
, ej' ,
ej'. P(ej')
F(ej')
Future(ej'), ej'.
, Pi,
max(Pasti(ej')), min(Futurei(ej')),
ej'. ej'
,
E \ Past(ej') \ Future(ej').
.
,
-
. ,
. ,
,
. , . 2.7
e24 e31 , ,
. ,
,
.
,
.
, ,
,
,
. ,
,
, .. (ei || ej') (ej' || ek'')
/ ei || ek''. ,
4
, e2 e31 . 2.7
. e24
e15.
e31 ||/ e15,
62

,
.
2.5.

.
. ,
, , FIFO (. First In
First Out). , m1
m2 ,
m1 ,
m2.
,
.
, (non-FIFO ),
,
(),
() .
.
, .
,
.

,
. ,
. 2.1, ,

, ,
, , .
.

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

: , ,
. ,
.
,

63

.
, ,
. ,
,
.
.

64

3.
;
.
, , ,
b, a , b.
,
,
.
" ",
,
. ,

, .. " "
,
,
.
,
-
, ,
,
. ,
,
.
,
,
- , .
,
,
. ,
, .
,
.
:
, "",
.
3.1.
,
9:30, , 9:30,
, 9:31.

65

(.
timestamp), .

, ,

,
. (. logical
clock) ,


(T, <),
(. time domain).
Pi i
.
ei, Pi,
ei, ..
(ei) = i(ei) ei Pi. ,
i
Pi, .. i .
, ,
, ,

. , ,
ei, , (ei)
ei. , ei
, (ei):
ei, ej' : ei ej' (ei) < (ej').

(. clock consistency)
.

,
. ,
- ,

:
1: ei ei'
Pi, ei Pi ei', (ei) < (ei').
2: ei ej'
, Pi
Pj, (ei) < (ej').

66

, T
ei, ej' : ei ej' (ei) < (ej'),
(. strongly
consistent).

(1) ,

, (2)
,
.
Pi
.


.
Pi
.

Pi .
Pi
.

.

, .

.
.
1: ,
.
2: ,

. , ,

, ,
,
.
,
1 2
1 2, .

, ,
.
67

1 2 ,
, .
3.2.

. ,

.
Pi
, Li.
ei L(ei).
1 2
.
1: Pi
Li:
Li = Li + d, d > 0.
d ,
. d
. Li
.
,
1 .
1
2.

.
2:
Li - Pi
. Pj ,
Lmsg, :
1.

Lj = max(Lj, Lmsg);

2.

1;

3.

,
1 2
.
, ..
ei ej':
ei ej' L(ei) < L(ej').

68

d = 1
. 3.1.
. ,
.

. 3.1. .

3.2.1
.


<,
- .

. , ,
, ,
, . ,
. 3.1 P1 P2
, .

, .
,
. <,
ei ej', Pi Pj,
:
ei < ej' (L(ei) < L(ej')) ((L(ei) = L(ej')) (i < j)).
,
,
, .. L(ei) = L(ej') ei || ej'.

- , ,

69

. , <
- : ei ej' ei < ej'.
, ,

, ..
, .


: , , ,
,
, , ,
.
, <, ,

. "
",
. ,
, L(ei) = L(ej') i < j, , ei < ej',
L(ei) mod N (i, j], ej' < ei
.
.
(d = 1), :
e L(e), L(e) 1
,
, , e
, . , . 3.1
a
, a, ,
,
, , ,
.
L(e) 1 (. height) e.
.
, .. ei ej' ,
L(ei) < L(ej')
/ ei ej'.
, . 3.1 e13 P1
L(e13) = 3, .. ,
L(e23) = 4 e23 P2. P1
" " P2. ,
,
,
. , ..
70

|| , .. ,
(ei || ej') (ej' || ek''), ei ek''.
, ei ej'
L(ei) < L(ej'), , ej'
/ ei,
, ei ej' ei || ej', ..
.
, L(e)
= (E, )
Z0.
.

, .., ()
, ,
- .
3.2.2

.
. . 1.5.1
,
. ,

,
. ,
Pi,

. :
"" $0 .
, FIFO.
, , . 1.5.1,
, ,
,
. ,
t Z0, ..
, t,
, , t, t ,
. , Pi

ei, L(ei) > t.
, ..
. ,
,

71

,
t, , t.
, ei, L(ei) > t, ..
,
, Pi
Lmsg t. Cji
Lmsg > t, Pi
Cji t,
, .
Lmsg > t , ..
Pj
Pi.
,
.
,
, R .
R ,
, , R, ..
,
.
, S
, t, ..
. , ,
,
.
. 3.2 ,
.
. ,
.

. 3.2. , .

72

,
t = 5, . 3.2 ,
.
P1 , $10 $1 $3 =
$6. P2 $20 + $1 $2 + $3 $5 = $17. C
P3 $30 + $2 $4 = $28. , P1
C31 $4, P3
C23 $5. $6 + $17 +
$28 + $4 + $5 = $60, .
. 3.3
,
. . 3.3
. 3.2
, , .
, 3.3
, ,
5
6.

. 3.3. , . 3.2.

.
. 1.5.3
. ,
,
, ,
, .

, ,
FIFO.

73



,
.
,
, .
,

, .

. m
(L(m), i), L(m)
, i .
, . 3.2.1.
, - ,
,
.
. 3.4.
.
, ,
m1 P1 2, m2
3 P4,
.
1 2 , m1,
3 4 , m2.
, , ,
- ,
.
m, ,
,
, m.
FIFO ,

, m.

. ,
,
, .

,
m, , , m
.
74

. 3.4. .

,
,
,
m .

,

, .
,
,
.
.
3.3.

. ,
,
- .
, , . 3.2.2,
. , ,
(. distributed debugging) ,

75

,
.
,
.
, ,
T
, . ,
, ,
,
.
,
,
.

N- , i-
Pi.
V
. 3.5.

. 3.5. .

.


. Pi
Vi[1..N]. Vi[i]
Pi,
76

.
,
, Vi, ,
Vi[j] , Pi
Pj. , Vi[j] = x,
Pi "" , Pj
x. ,
Pj , .. Pj
x, , Pi
. Vi
Pi
,
.
,
N- , N
.
. ei,
Pi,
Vi ei.
ei V(ei).
V(ei) V(ej')
ei ej' :
V(ei) = V(ej') k: V(ei)[k] = V(ej')[k];
V(ei) V(ej') k: V(ei)[k] V(ej')[k];
V(ei) < V(ej') V(ei) V(ej') k: V(ei)[k] < V(ej')[k].
, <
N 2. ,
V(ei) = [2, 3, 0] V(ej') = [0, 4, 1] .
V(ei) || V(ej'):
V(ei) || V(ej') (V(ei) < V(ej')) (V(ej') < V(ei)).

Pi
.
1: Pi
Vi[i]:
Vi[i] = Vi[i] + d, d > 0.
, d
. d .

77



.
2:
Vi - Pi
. Pj Vmsg,
:
1.

:
Vj[k] = max(Vj[k], Vmsg[k]), 1 k N;

2.

1;

3.

Vi[k] , 1 k N.
, 1 2
<
1 2

,
..

:
ei, ej' : ei ej' V(ei) < V(ej').
d = 1
. 3.6. .
, .

. 3.6. .

78

3.3.1
.
,
ei ej' V(ei) V(ej'),
, :
ei ej' V(ei) < V(ej'),
ei || ej' V(ei) || V(ej').
ei ej'
.
, V(ei) < V(ej')
ei ej', , ei ej' ,

ei
/ ej' V(ej')[i] < V(ei)[i].
, , ej' " "
ei, "" - ,
ei Pi ( V(ej')[i] 0).
, i = j, .. ei ej' Pi,
ei
/ ej' , ej' ei.
1 Pi
V(ej')[i] < V(ei)[i]. , i j, .. ei ej'
. V(ei)[i]
Pi ei.
, Pj
, .. ei
/ ej', .. V(ej')[i] < V(ei)[i].
, ei
/ ej' (V(ei) < V(ej')),
V(ei) < V(ej') ei ej', .. V(ei) < V(ej')
ei ej'.

ei || ej' V(ei) || V(ej')


.
, ..
, ,
(E, )
(V, <).
,
ei ej' Pi Pj,
(.. i j),
:

79

ei ej' V(ei)[i] V(ej')[i],


ei || ej' (V(ei)[i] > V(ej')[i]) (V(ei)[j] < V(ej')[j]).
, ej' ""
ei Pi. ,
ej' Pj " " ei
Pi ( ), Pi "
" ej' Pj ei (
). i j ei
ej'
.
.
,
,
. , ,
,

.

:
. ,
, , ,
,
(. distributed debugging)
(. checkpoints)
.


, N ,
, ,
N , .
,
-
. ,
, N ,
n , V(ei) < V(ej')
ei ej', n N.
.
(d = 1), i-
Pi, Vi[i], ,
Pi . ei
V(ei), j- V(ei)[j]
80

, Pj ei
- . ,
j V(ei)[j] 1 ,
ei , ..
. ,
, , ,
ei, , V(ei)
i- : i-
V(ei)[i].
ei
(. breakpoint event),
,
ei, ,
,
ei, (. casual distributed breakpoint). ,

, ei, , ,
ei.


,
.
3.3.2
.
. 3.2.2
,
.
,
t,
.

t . ,

t
, .. , t
,
t.
, t ,
.

. , Pi Pj
81

Vi[i] Vj[i], ..
Pi
. Pi
Vi[i] Pj,
Vj > Vi. ,

Pi .
t Pi
.

t
.
1.

Pi ,
t = Vi + (0,0, 1, 0,0),
.

2.

Pi ,
,
t. ,
, t
.

3.

t
, Pi
, .. Vi t,
,
t.

,
. 3.2.2.
,
Pi
t.
(N + 1)-
, Pi, t.
Pi t
(N + 1)- ,

.
3.4.
N
, ,
N. , ,
82


.

, ,

. ,

,
,
.
3.4.1

,

-.
,
,
. , Pi
Pj,
Pi,
Pj.
,
Pj Pi i1, i2, in
Vi v1, v2, vn,
Pi : {(i1, v1), (i2, v2),
(in, vn)}. Pj ,
:
Vj[ik] = max(Vj[ik], vk), 1 k n.

, ,
-
. ,
, ,
, ,
, ,
Vi. ,
FIFO.
,


.
83


O(N2). ,
,
, O(N).
.
Pi
:

LSi[1..N] ( . Last Sent). LSi[j]


Pi, Vi[i],
Pi Pj.

LUi[1..N] ( . Last Update). LUi[j]


Pi, Vi[i],
Pi j-
Vi[j].

, LUi[i] = Vi[i] Pi,


LUi[j] Pi ,
Vi[j]. LSi[j]
Pi Pj.
, ,
Pi Pj Pi
k Vi[k],
LSi[j] < LUi[k]. ,
,
Pi Pj. , Pi
Pj,

{(k, Vi[k]): LSi[j] < LUi[k]},


Vi, N .

. 3.7. ,
P3 P2 {(3,2)},
P2 ,
, .
,
P3 P2 P3
.

84

. 3.7. .

,

,
, , ,
.
3.4.2 ,
,
,

. "" ,
-
,
, .. on-line.
, ,

. , ej' Pj
ei Pi,
ei ej' Pi
Pj. : ej'
ei , i = j ei i ej', i j
s r
, (ei i s) (ei = s) (ej' = r) (r j ej').

, ,
85

off-line ,

.
, ,
Pi Vi
(. direct dependency
vector) Di[1..N]. Di[k]
Pk Pk Pi.
ei Di
ei D(ei). Di[k]
, 1 k N, Pi
Di.

Pi

Di[i], .. Di[i] = Di[i] + 1.

Pi Pj,

Di[i].

Pj Pi ,
d, i-
:
Dj[i] = max(Dj[i], d).

, Dj[i]
Dj[i] d ,
FIFO, .. Pi
d
d.
Di , Di
Pi
. ,
Di[j]
Pj, Pi .
, Pj
Pj, Pi
- .
, ,
. 3.8. , P4
P3,
, ,
e32 P3 e42
P4. P3 P2,
86

P2 P3. ,
, e24 P2
e42 P4
- . , P2

. ,
P2, D2[4],
e41 P4, e24 .

. 3.8. , .


-
.
off-line
, .
,

.
,
-
" " . , ,
(. distributed
debugging), ,
, , off-line,
, .

87

, ei
,
, ..
ej', ei, ek'',
ej'.
. 3.8.
e24 P2 e42 P4
, D(e24)
e24 e33 P3
D(e33) e33 e42.
,
, x- eix Pi,
3.1.
eix, , ,
eix
DTV. DependencyTrack(i,x) i-
DTV x eix.
eix
Pi i- D(eix),
eix. DTV .
,
DTV,
VisitEvent(j,y), j , y
. , VisitEvent(j,y)
D(ejy) , ,
DTV, DTV
.
VisitEvent (
) DTV.
, VisitEvent
eix. DTV
,
eix.
3.1.
.
void DependencyTrack(ProcessID i, EventIndex x) {
/* eix */
/* DTV */
EventIndex DTV[N];
void VisitEvent(ProcessID j, EventIndex y) {
/* ejy DTV */

88

/* D
ejy */
for (int k=0; k<N; k++)
if (k != j)
if (D[k] > DTV[k])
{ DTV[k] = D[k]; VisitEvent(k, D[k]) }
}
/* DTV */
for (int k=0; k<N; k++)
if (k != i) DTV[k] = 0; else DTV[k] = x;
VisitEvent(i, x);
}


P2
(. . 3.8). DependencyTrack
i = 2, x = 4 DTV (0 4 0 0).
VisitEvent(2,4).
D2 (1 4 3 1), DTV
(1 4 0 0) P1
VisitEvent(1,1).
D1 = (1 0 0 0). D1
DTV,
VisitEvent(1,1) D2.
, D2
DTV ( , 3 > 0). DTV
(1 4 3 0), VisitEvent(3,3)
P3. D3 =
(0 0 3 2). D3 ,
DTV ( , 2 > 0), DTV (1 4 3 2),
VisitEvent(4,2). D4 = (0 0 0 2)
DTV, VisitEvent(4,2),
VisitEvent(3,3), .. D3 .
D2
DTV ( , 1 < 2),
DependencyTrack .
(1 4 3 2) P2.
, ,
,

89

, ..
.
off-line
, .
3.4.3 -


,

.
,
..
(, ,
).

, .. .

,

.
-
, .. ,
.
,
() ER E
- R,
E.
,

.
,
. -

( ,
)
(
,
).

90

- :
ei
,
, ,
ei. , ei
, ,
Pi , ,
Pi,
, ei.
, Pi
,
, ei.
( )
"" ,
ei, , ei. -

on-line, , ,
,
.

, ,
- <<
. ,
ei ej', Pi Pj,
- , ei << ej', ,
ei ej'

. : ei << ej',
, i = j ei i ej', i j s1, r1, s2,
r2, sn, rn sk rk
, (ei i s1) (ei = s1), rk sk+1
, rk sk+1, (ej' = rn) (rn j ej'),

.

Pi -
PVi (. partial vector clock),
(j, x), ,
Pi -
ejx x Pj.
(i, v) v Pi.
ei
91

, -
ei PV(ei).
- Pi: PVi = {(i, 0)}.
PVi = {(i1, v1), (i, v), (in, vn)}
- Pi. -
Pi
:

(v + 1)- eiv+1 Pi

PVi:
PVi = {(i1, v1), (i, v + 1), (in, vn)}.
- Pi
PV(eiv+1)
eiv+1:
PVi = {(i, v + 1)}.

Pi Pj
PVi.

Pi
PVmsg = {(im1, vm1), (im2, vm2), (imk, vmk)},
- PVi
:
1.
(imx, vmx), (imx, .) PVi;
2.
(ix, vx), (ix, .) PVmsg;
3.
(ix, max(vx, vmx)) (ix, .),
PVi PVmsg.

-
. 3.9; .
P2.
PV2 (2, 0). e21 P2

PV(e21). P1
PV2 (1, 0).
P3
{(3, 1), (4, 0)}. PV2 = {(1 ,0), (2, 1), (3, 1), (4, 0)}.
e22, P2 ,

PV(e22) . PV2
(2, 2). , e22
e10, e21 e31. ,
- e40.
92

. 3.9. -.

ei
, c ei
- .
, ,
ei.
- ,

, . , ,
- ,
.
, ,
k , ,
,
k.

.
3.5.

N x N.
Pi Mi[1..N, 1..N]
.

Mi[i, i] Pi
.

93

Mi[i, j] ,
Pi Pj. ,
Mi[i, .] Pi.

Mi[j, k] ,
Pi , Pj
Pk.

Mi
Pi ,
, "" .
ei, Pi,
Mi
M(ei).
Pi
.
1: Pi
Mi[i, i]:
Mi[i, i] = Mi[i, i] + d, d > 0.
, d
. d .


.
2:
Mi - Pi
. Pj Pi
Mmsg, :
1.

Mj[j, .]
Pi, Mmsg[i, .]:
1 k N: Mj[j, k] = max(Mj[j, k], Mmsg[i, k]);
Mj :
1 k, l N: Mj[k, l] = max(Mj[k, l], Mmsg[k, l]).

2.

1;

3.

Mi[k, l] , 1 k, l N.
d = 1
. 3.10. e26
P2. e15 P1,
e26 -
. M(e26)[2,1] = M(e26)[1,1] = 5. , M(e26)[2,3] =
94

M(e26)[3,3] = 4. P2 P1,
"" P3, e12. M(e26)[3,1] = 2.
, e34 P3, "" P1
P2, .. M(e26)[1,3] = 4.

. 3.10. .

3.5.1
Mi[i, .]
. , Pi
mink (Mi[k, l]) t, Pi
Pk "" , Pl
t . ,
e26 . 3.10 P2 ,
, P1
e12. Pi
, ,
Pl
, t.
, - ,
Pl,
(. obsolete information).

(d = 1), Mi[k, l]
, Pl Pk ,
"" Pi.

95

4.

. ,
,
. , -,
,
(. critical section),
. -,
(. mutual exclusion),
:


, .

(),

(). ,

.
,
.

( )
:

. ,

.

.

,
.
, ,

.
4.1.

:
96

,
,

. ,
(FIFO) (non-FIFO).

. ,

.

.

: (1)
, , (2)
,
. ,
,
4.1.
: request_CS()
release_CS()

.

R.
,
.
4.1. .
P1
void P1(int R) {

PN

void PN(int R) {

while(true) {

while(true) {

/* */;

/* */;

request_cs(R);

request_cs(R);

/* */;

/* */;

release_cs(R);

release_cs(R);

/* */;

/* */;

97

()

: (1) , (2) (3)
.
(
request_CS),
( request_CS)
(
release_CS ). ,
,

.

.

.

.
.
.
.

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


-
, . ,
, ,
,
.
, ,
,
.


.

98

1.

(. permission-based
algorithms).
""
. ,

, .


,
,

.

2.

(. token-based
algorithms).
,


.
.

, ,
,
, .
:
(. perpetuum mobile)

(. token asking methods).
,
,
,
, .

,

,
, .

,

,
. ,
, , ,
, ,
99

.

.
.

. 1.3.3
.
.
,

( ),
.

.
:
, , , -
.
-,
,
.

. ,

- ,
- . ,
.

,
.
.

.
:

.


,
. ,
,
,
. ,
100

(.
peer-to-peer)

(. ad-hoc)
.
4.2.

,
,
. , ,
. ,
, REQUEST
.

.
, ..
, REPLY
. ,
, . . 4.1:
1 3 ;
3 .

()

()

()
()
. 4.1. .

101

, 1 ,
P2 (.
. 4.1; 1 ). ..
, , 1,
P2 .
. . 4.1
, P2
. , , "
". 2
. P1 ,
RELEASE,
. RELEASE
1
,
; 2. , 2
, . 4.1.
,
:
. ,
, ..
.
. , ,
,

, .
, ,
,
, ,
.
, , , P1
P3 P2.
P1 P2 P3
. , P2 P3
P1, P2 P1
(. . 4.1). ,
.
,
:
REQUEST REPLY,
RELEASE.

102

4.3.


.
4.3.1
, . ,


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

(Li, i), Li Pi
, i Pi.
, . 3.2.1.
,
, . 3.2.2.
,
, ""

,
.
"", , ,

.

.
,
.
103

: ,
? , - ,
,

,
.

. 3.2.2 . 3.4.

,
, ,
, ,
. FIFO
,
,
, , ,
, .
Qi Pi,
.
.
1.

. i ,
REQUEST(Li, i)
(Li, i) , ,
Qi.
i.
j REQUEST(Li, i) i,
Qj i
REPLY(Lj, j) (Lj, j).

2.

. i ,
.

3.

REQUEST(Li, i) i
,
Qi.
i
, (Li, i).
, FIFO,
, i
, .

. i
Qi
RELEASE(Li, i) .
104

-
i. RELEASE(Li, i),
j i Qj.
j i Qj
Qj, j
.
,
: ,

. ,

,
, ""
, .
,
, , , .
,
.
.
Pi j . ,
Pi Qi,
Pj Qj,

, . ,
Pi j. ,
FIFO ,
, Pj
Pi Qj
Pi, Pj Qj.
,
. , ,
Pi, ,
,
.
. Pi
(N 1)
. Pj
RELEASE,
Pj , Qi.
Pj ,
Pi, Pi.
Pi Qi
105

. ,
, , ,
.
,
,
- .
,
.

. 4.2. . 4.2 2
3 , L2
L3;
( ,
).

()

()

()

()

106

()

()

()

()

()
. 4.2. .

107

. 4.2 1 3 2
. .. 2
3, 2 3
Q3. 2 3.
2 ,
1 3. ,
FIFO , 2
3 , 3.
2 3, Q2
3 .
3 2,
3 Q2, . 4.2.
1 3, 2 , ..
Q2 . . 4.2.
1
.
1 2 3
. . 4.2. ,
3 2.
, 1, . . 4.2
2 , Q2
RELEASE. 1
2 , , RELASE,
2 Q1 . . 4.2. ,
. 4.2 1,
3.
.
2. ,
3 , 1, ..
1. , 1
3. FIFO 3
1 1 3,
. 4.2. 1 3,
Q1, ..
3 , 1 .
. 4.2. 1 , 3
. , 3
1 . . 4.2. 3
RELEASE,
, 1.
1 Q1,
, . 4.2.

108

, ,
3(N 1)
: (N 1) REQUEST
(N 1) REPLY, (N 1)
RELEASE.
.

REPLY. , j REQUEST(Li, i)
i , i
(Lj, j) > (Li, i) ( , ,
REQUEST(Lj, j), j
i), j Pi
. , FIFO
j i i
, Pj
, (Li, i). , . 4.2 P1
P3 (1, 3) ,
(4, 1) . . 4.2.
. 4.2 P1 P3
(11, 1) .
,

, 2(N 1) 3(N 1).
4.3.2 -


. REPLY
RELEASE . REPLY
,
, , ,
.
RELEASE

. , ,
,
.

, REPLY:
,
, , REPLY
.
109

. .
,
RELEASE RELEASE REPLY
. , - ,
FIFO.
,
.
, ,
REQUEST
REPLY. ,
,
, .
,
, ,
, REPLY. ,
,
,
.
, , ,

(Li, i), Li
Pi , i
Pi. , ,
. ,
Pi
Pj (Li, i)
(Lj, j) ,
REPLY, (Li, i) < (Lj, j). (Li, i) > (Lj, j), Pi
REPLY Pj .

.
- Pi
DRi[1..N],
( . deferred reply). Pi
Pj,
DRi[j] = 1; REPLY DRi[j]
. DRi[k] , 1 k N.
-
.
1.

. i ,
,
Li, REQUEST(Li, i)
. j
110

REQUEST(Li, i) i, i
REPLY , j ,
, j
(Lj, j) (Li, i)
i. j
REPLY DRj[i] = 1.
2.

. i ,
REPLY .

3.

. i
REPLY , ..
j, DRi[j] = 1, DRi[j] = 0.


.
.
Pi j ,
Pi j. j
,
. j Pi ,
Pi ;
Pi j
. Pi
REPLY j,

, , Pi .
, j
REPLY , , Pi.
, -
. Pi ,
,
Pj. , Pi Pj.
, Pj
, .
Pj Pi. Pj
,
Pi. Pj
, ,
Pk , Pj Pk.
, , : Pi
Pj, Pj Pk, Pk Pm, .. ,
:
. Pl
111

,
.
Pl
, , ,
.

.
, -,
,
,
- . ,
REQUEST Pi
Pi.
, ,
, , ,
,
, .
- . 4.3.
, ,
. 4.3 2 3
. . 4.3 1 3 2
. 2,
3, , .. 2

3. DR2
. 3
, 2 .
1
,
. 4.3. , 1 3,
2 . . 4.3. 1
2 3. ,
1 2 3 , .. 2
, 3

1.
: 1 3, 3 2.
. 4.3. , 3 ,
1, .. DR3[1] = 1, 2 ,
1 3, .. DR2[1] = 1 DR2[3] = 1.

112

()

()

()

()

()

()

113

()
. 4.3. -.

. 4.3 2
1 3.
3, .
. 4.3 3 1, , ,
1 , 3 ,
.. 1 3.
3 . 3 ,
1 , 1 ,
. 4.3. . 4.3 1 .
.
, , 2(N 1) : (N 1)
(N 1)
.
4.3.3
-
2(N 1) . , 2(N 1)
. ,
,
, , .
,
, , .
-,

,
( ),
.

114


,

.
,
, ,
.

,
- .

,
.
. ,
,
,
.

, ,
, ,
.
, .. , -
,
.
, ,
,
- ,
.
, ,

.
1.

.

.

.

2.

.
,
, .. ,

.

115


,
,
.
.

,
.
, ,
, .
,
, . ,
-

.

.
, ,
, ,
, .
,
. ,


, - .


G, Pi .
, , Pi Pj,
G , Pi Pj
: ,
,
, .
G (. conflict graph).

.
- ,
. ,
, 4.1.
,
.

.
116

,
. ,
,
20 ,
. 4.1 ,
, ..
, ,
: 4.1.
. , E
1 2.
4.1. : ,
.
1



, ,
.

,
. , ,
1 2, , ..
. 1
3 ,

.

. 4.4.
, ,
.
,
, .. 12 : ,
117

1 3, 2 5,
4.
,

, " "
,
,
.

. 4.4. .


,
,

. , ,

, ..

.

H (. precedence graph),
G

. . 4.5 H ,
P1 P2, P4 P5,
P3 P2 P4.
,
, H . ,
, , ,
, .. Pi
Pj, , Pi Pj , , Pj
Pi.
118

. 4.5. .

, H
, P1, P5 P4,
. 4.6. P1
P5, P5 P4, P4 P1.

,
. ,

.
.

. 4.6. .

H , ,
, .

(. depth),

. .
. ,
119

. 4.5 P1, P5 P4 0, 1 2.
, , , H
.
,

H .
H
. ,


. ,
, ,
" " H ,
,
. " H"
, ,
H ,

. ,
" " H .
H, .. ,
,
.. .
H?
. ,
H


.
, , ,
H
.
1.

H .

2.

H , ,
, ,
, ..
,
.

3.

H
.

120

H

,
.
H

.
.

G,
.
"" , , u, v,
w. ,
G.
: ,
.
,

. ,
,
.

,
.
,
, , ..
. G
.
,
,
.
1.

.
, ..
.

2.

.

. -
, .

3.

.
.
,
.
121

4.

.

, , .

5.

. ,

, .


,
, , ,
. G
. ,
N

. ,
. ,
G N
,
.

, ,

, .
,
,
, ,
,
.
H,
.

H ,
, , ,
.

.

,
,
. ,

.


.
122

- u
w v, w v u, .. u
(u
).
H , v,
. , ,
H, ..
u
, u.
, H ,
, , , ..

. v k, k > 0,
.
v , -
, v ,
. ,
H, ,
, .
, H, ,
, ,
. ,
, k, ,
,
, k, , k,
,
.

. 4.7. .

. 4.7 H,
. 4.5. . 4.7 P1
,
123

1,
P2, P4 P5. P5 .
H

.
H ,
,
,
. ,
,
,
. ,
,
. ,
?

, (. fork), ,
G . ,
, u v,
,
. ,
, , .
,
, ..
,
.
, ,


.
1.

u ,
u ,
v , u v v
.

2.

u
v , v u,
u , ..
.



H. , H
,
124


,
.
H
"" / ""
, u
v, .. H u
v, , 1) u v ,
"", 2) v u , "",
3) v u.
H
.

, ,
, "".
,

.

, "" ,
, .
"".
,
.

,
"" "" ,
. ""
. ,
"" H,
,

.

"" .

.
, ""
. ,
"".
.
, ,
,
.
, H
, , ,
125


:
1.

u ,
u ,
v , v "", v
.

2.

u
v , v
"".

u ""
v , v . , , ,
,
, , ,
. , ,
, ,
.
, ?
,
- ,
.
(. request-token),
.

.
, . , u
v , ,
, u , v .
,
.
1.

. u
v , 1) u
, 2) u v 3) u
.

2.

. u v
, 1) u
, 2) "" 3) u .
"".

3.

.
u ,
u ,
v , "", u
126

v. u
,
"".
.

:

H ;

"" ;


, .


. ,

, H . , ,
,
"",

.
,
.
.
, , u
, v , u,
, u ,
. ,
, v.
"", .. v u.
, , v . , u
,
.
, u
v, , v . , u
,
.
, u, ,
"" ,
. u ,
v, ,
1.

127

. v , , ,
. v ,
, .. ""
(.
). , , v
"" u (. ).
, , ,
u
, , ,

, . ,
H, ,
, , .
.
,
.
2.

.

. ,
d,
d d ,
. , ,
, e "" .
(d e)
. , ,
"" ,
. ..
""
.
2d
.

,
2d. ,
,

.
3.

.
,


, .
4.

128

.
,
,
: ,
.
5.

,
,
..
,
.
(N 1) :
.

2(N 1) . , ,
,

. , ,
, ,
.

. 4.8.
() Pi forki[1..N], dirtyi[1..N]
reqfi[1..N] , forki[j] = 1, Pi Pj ,
dirtyi[j] = 1, "", reqfi[j] = 1, Pi
, Pj .
.
. . 4.8
: ,
,
( ), .. "",
.
. 4.8 2 3
( ) .
Pi Pj, reqfi[j]
. Pj Pi
reqfj[i] .
P1
P2 P3, .. 1 ""
, , , 1
( ). "" . . 4.8.

129

()

()

()

()

()

()

130

()

()

()
. 4.8. .

, . 4.8 2
. 1 "", 3
"". 2 ( ),
.. ""
3. 2 3,
"", . 4.8. 3
"" 1 2 .
3 "":
1 2 . .. 2
, 3.
3 "" 2, ..
3 .
. 4.8. . 4.8 1

. , 3 1 "" ,
131

.. , 2 1 , ..
"". 1 , 3
, 2 .
3 ""
. . 4.8.
, 2 , . 4.8.
2 1 3.
, 1,
2 1 , 1
, . 4.8.
4.4.

,

.

. ,
, ,
. ,
.
,
, ,
,
, . ,
,
(.
perpetuum mobile). ,
,
, .

(. token ring). ,
, ,
. , ,
, .
,
.
,
.
, ,
.

132

,

(. token
asking methods). ,
,
, ,
.
4.4.1 -
,
, ,

. .
. , . ,
, ,
REQUEST .
REQUEST , ,
.
REQUEST , ,
, , .
, - ,
FIFO.
,

.
1.


, . ,
, ,
, .
, ,
,
. , -
,
, ,
.. , , ,
. ,
,
, ,
.
,
.

133

2.

,
.
, ,
, ,
.

-
(. sequence numbers)
. n (n = 1, 2, ) Pi
, Pi
. Pi
REQUEST REQUEST(i, n). ,
Pi RNi[1..N] ( .
request number), RNi[j]
, Pj.
, REQUEST(j, n) Pi
j- RNi RNi[j] =
max(RNi[j], n).
Q
, ,
LN[1..N] ( . last number), LN[i]
, Pi.
LN[1..N] ,
Pi LN[i] = RNi[i],
, RNi[i] .
, Pi
Pj RNi[j] ,
RNi[j] LN[j]. RNi[j] = LN[j] + 1, , Pj
, Pj RNi[j]
. Pi, ,
Pj Q ,
Pj Q. Pi
, Q.
, -
.
1.

i ,

RNi[i]
REQUEST(i, n), n RNi[i].
j REQUEST(i, n)
i, RNj[i] =
max(RNj[i], n). j
134

, j
i , RNj[i] = LN[i] + 1.
2.

. i ,
.

3.

i
LN[i]: LN[i] = RNi[i].

Pj,
Q, RNi[j] = LN[j] + 1, i
Pj Q.


Q , i
Q ( )
.

, -
. , i
.
(, , ,
).
i Q.
(N 1) , ,
, , i , i
.
- . 4.9.
1,
.
, , 2 3
,
. 4.9. . 4.9 1
2, 2.
, 1 3,
3.
-,

. . 4.9 2
1 TOKEN .
1
.

135

()

()

()

()

()

()

136

()
()
. 4.9. -.

1 2 3, . 4.9.
2 LN[2]
Q. , LN[2]
, , , 2
, Q
1 3, . ,
Q ,
, ,
RNi. 2
RN2 ,
1 Q 3
, 1 3.
Pi RNi i + 1 N,
1 i 1, 2
3 1. . 4.9 2
, Q, ..
1, 1 . , . 4.9
1 , 3 , 1
3: 3
1. 1 Q,
,
2. 1
3, .. Q 3.
. 4.9 4.9 3 .
3 LN[3] , ..
, . 4.9.
3 n = 1,
1,
, .. RN1[3] = 1 LN[3] = 1.

137

, ,
- N :
(N 1) REQUEST .
,
.
4.4.2
,
, ,
,
,

.
,
,
, -.
, , ,
, , ,
, , ,
REQUEST TOKEN.


,
-. , . 4.10
P1 P2, P3 P4
P5 P6.

. 4.10. .


, ,
Holder,
. ,
Pi Holderi
138

Pj, , ,
, .
Pi Pj
, . Pi
, Holderi self.
, Pi ,
Pj, .. Holderi = j,
Pi Pj
Pi Pj. , ,
Holder ,
, ,
, . 4.11 ,
P6.

. 4.11. ,
.

Pi ,
REQUEST
Pj,
Holderi. , Pj ,
REQUEST Pi
, , ..
Holderj. , REQUEST
,
, , . ,
P1 . 4.11 ,
P4, .. Holder1 = 4. ,
Holder4 = 6, P4 P6,
.
,
, ,
REQUEST. ,
139

P6 P4,
Holder6 = 4. P4 ,
REQUEST " " P1, P4
P1, Holder4 = 1.
P1 Holder1 self
, . 4.12.
, Holder
,
,
.

. 4.12. .

, , ,
" " , ,
-,
. ,
" "
O(N) .
Pi Pj
Pi. Pj
, ,
.
Pi
.
1.

Holder. : self
Pi.
.

2.

Using. : true false.


, Pi . ,
Using = true, Holder = self.

140

3.

Q. : self
Pi. Q
, Pi
REQUEST ,
. self Q,
Pi , .. .
, Q
, Q
Pi self.

4.

Asked. : true false.


Asked true,
Pi REQUEST ,
Holderi; Asked = false.
Asked
REQUEST, Q.


AssignPrivilege(),
,
MakeRequest(),
.
4.2 4.3.
4.2. .
void AssignPrivilege() {
/* */
if (Holder == self && !Using && !Q.empty()) {
/* Q */
Holder = Q.front();
Q.pop();
Asked = false;
/* self, */
/* c ID Holder */
if (Holder == self) {
Using = true;
/* */
}
else {
/* TOKEN c ID Holder */
}
}
}

141

4.3. .
void MakeRequest() {
/* */
if (Holder != self && !Asked && !Q.empty()) {
/* REQUEST c ID Holder */
Asked = true;
}
}

.
,
: (1) Holder = self,
(2) Using = false, (3) Q .
self Q,
, , ,
Q.
Q, ..
,
Holder , .
, Q , ,
self, , ,
TOKEN .
,
self , Using true.
Asked false, ..
REQUEST ,
Holder.
. ,
, REQUEST,

, ..
: (1) Holder self, (2) Q ,
(3) Asked = false.
Asked
REQUEST , Holder.
REQUEST Asked
true. ,
REQUEST ,
: Holder, Using
Q .

142


AssignPrivilege
MakeRequest ,
,
.
1.

. Pi, ,
self Q
AssignPrivilege , , MakeRequest. Pi
,

AssignPrivilege

,
. Pi, MakeRequest
.

2.

REQUEST.
REQUEST Pj Pi Pj
Q AssignPrivilege , ,
MakeRequest. Pi ,
AssignPrivilege

Pi

. Pi,
MakeRequest Pi Pj
.

3.

TOKEN. TOKEN
Pi Holder self
AssignPrivilege , , MakeRequest. C
AssignPrivilege Pi
.
, MakeRequest Pi
.

4.

. Pi Using
false AssignPrivilege , ,
MakeRequest. C AssignPrivilege Pi
,
MakeRequest Pi.

, ,
, Q self.
AssignPrivilege,
4.2.

,

, FIFO,
.

143

(. sequence numbers)
. ,

, . 4.13. . 4.13
,
, Pi.

. 4.13. .

. 4.13,
,
Pi REQUEST, TOKEN,
Pj TOKEN. ,
Pj , ..
,
TOKEN, Pj
REQUEST TOKEN.
, ..
.
, REQUEST Pj ,
TOKEN, Pi Qj
Pj. , Pj ,
AssignPrivilege . , Pi
Pj, , Qj , Askedj Pj
true, MakeRequest
, REQUEST
. TOKEN, ,
Pj,
, Qj.
Pi, Pj, ..
Qj.
Pj REQUEST TOKEN
.
144

.

. , ,
Holder self INITIALIZE
.
INITIALIZE Pi Holderi
, INITIALIZE,
INITIALIZE
,
INITIALIZE. INITIALIZE,
,
. Using
Asked false , Q .
,
, .. .


, ,
, ,
,
.
:

,
, ;

,
;

TOKEN ,
.

,
, .
Asked ,
REQUEST,
, Holder, ,
, , . ,
TOKEN ,
REQUEST ,
, .
, TOKEN
REQUEST, TOKEN
Pi Pj REQUEST
, .. Pj Pi.
, . 4.13,
145

. , TOKEN
Pi Pj REQUEST, Pi
. Pj Pi, Pj
REQUEST, ..
Asked true.
, ,
,

. ,
REQUEST , ,
Q , , ,

. , ,
TOKEN ,
.
, .. Q


FIFO.
( Q
)
.
, REQUEST
, , TOKEN,
, , .
. 4.14.
1,
,
. 4.14. P1
P2, P2 P3. ,
.
. 4.14, , ,
2 3
, REQUEST ,
Holder.
3 2 1, .. Asked2 = true, .
. 4.14. REQUEST,
P2 P1, P2, P3. . 4.14
1 2,
Holder , 2,
. Q 2 self,
,
. 4.14.
146

()

()

()

()

()

()

147

()

()

()
. 4.14. .

1
REQUEST 2. . 4.14
2 ,
Q, .. 3.
, 3 . 1
2, 2 3, . 4.14.
, ,
Q3 Q2 3 2
3, , 1,
. 3
TOKEN : 2 1,
. 4.14 . 4.14.
Holder ,

148

. ,
, 1 .
,
, ,
2D, D , ..
.
,
D REQUEST D TOKEN .

,
N 1 .
2(N 1) ,
, , -.

. ,
,

(N + 1)/3 , ,
.
2N/3, N ,
-.
, .
,
,
K.
, ,
O(logK-1 N). ,
K Q,
.

:
, , ,
, . , REQUEST,
,
,
Pi, Askedi = true.
REQUEST, Pi Holderi,
,
Pi. , Pj
Pi
Pj. ,
, Pi, ,
149

,
Pi (, Pi
Pj). ,
TOKEN , ,
.

, TOKEN N 1
( )
N . , TOKEN
REQUEST,
4(N 1) .
, , 4(N 1)/N 4.
.

REQUEST TOKEN.
,
AssignPrivilege,
MakeRequest.

, TOKEN REQUEST
,
.
.
,
, , ..
.

. ,
Q , ,
, , .
""
. ,
Pi ,
self Q, ,
,
. Pi
,
, .
,
, .. self, ,
Q. ""
,
150

,
. ,
. ,

,
. ""
,
, , ,
. ,
. 4.10 , 1
4, ,
, , ,
.
, ""
,
. ,
""
, . ,
Q FIFO
, Q,
self , ..
.
, , Q
, , , ,
, .

151



1.
2.
3.
4.
5.
6.
7.

. . . .
. .: , 2004. 848 .: .
., . .
. : , 2003. 877 .: .
. . . . .:
, 2009. 616 .
Kshemkalyani A. D., Singhal M. Distributed Computing: Principles,
Algorithms, and Systems. Cambridge University Press, 2008.
Stallings W. Operating Systems: Internals and design principles. Seventh
edition. Prentice Hall, 2011.
Tanenbaum A. S., van Steen M. Distributed Systems: Principles and
Paradigms. Second edition. Pearson Prentice Hall, 2007.
Tel G. Introduction to Distributed Algorithms. Second edition. Cambridge
University Press, 2000.

8.
9.

10.

11.

12.
13.
14.
15.

16.

. . . .:
, 2004. 320 .
.,
.

++. . . .:
"", 2004. 672 .: .
. .

. . . .:
"", 2003. 512 .: .
Chandy K. M., Lamport L. Distributed snapshots: determining global
states of distributed systems // ACM Transactions on Computer Systems,
3(1), 1985. P.6375.
Chandy K. M., Misra J. The Drinking Philosophers Problem // ACM
TOPLAS, 6:4, October 1984. P.632-646.
Chandy K. M., Misra J. Parallel program design: a foundation. AddisonWesley, 1988.
Charron-Bost B. Concerning the size of logical clocks in distributed
systems // Information Processing Letters, 39, 1991. P.1116.
Charron-Bost B., Tel G., Mattern F. Synchronous, asynchronous, and
causally ordered communication // Distributed Computing, 9(4), 1996.
P.173191.
Coulouris G., Dollimore J., Kindberg T., Blair G. Distributed Systems:
Concepts and Design. Fifth edition. Addison-Wesley, 2011.

152

17.
18.

19.
20.
21.

22.
23.
24.
25.

26.
27.
28.
29.
30.

Fidge C. Logical time in distributed computing systems // IEEE Computer,


August, 1991. P.2833.
Fowler J., Zwaenepoel W. Causal distributed breakpoints // Proceedings
of the 10th International Conference on Distributed Computing Systems,
1990. P.134141.
Garg V.K. Concurrent and distributed computing in Java. John Wiley &
Sons, 2004.
Ghosh S. Distributed systems: an algorithmic approach. Chapman and
Hall/CRC, 2007.
Jard C., Jourdan G.-C. Dependency tracking and filtering in distributed
computations // Brief Announcements of the ACM Symposium on PODC,
1994. A full presentation appeared as IRISA Technical Report No. 851,
1994.
Lamport L. Time, clocks and the ordering of events in a distributed
system // Communications of the ACM, 21, 1978. P.558564.
Lynch N. A. Distributed Algorithms. Morgan Kaufmann Publishers, 1996.
Rauber T., Rnger G. Parallel Programming For Multicore and Cluster
Systems. Springer, 2010.
Mattern F. Virtual time and global states of distributed systems //
Proceedings of the Parallel and Distributed Algorithms Conference,
North-Holland, 1988. P.215226.
Raymond K. Tree-based algorithm for distributed mutual exclusion //
ACM Transactions on Computer Systems, 7, 1989. P.6177.
Raynal M. A simple taxonomy of distributed mutual exclusion algorithms
// Operating Systems Review, 25(2), 1991. P.4750.
Ricart G., Agrawala A. K. An optimal algorithm for mutual exclusion in
computer networks // Communications of the ACM, 24(1), 1981. P.917.
Singhal M., Kshemkalyani A. An efficient implementation of vector
clocks // Information Processing Letters, 43, August, 1992. P.4752.
Suzuki I., Kasami T. A distributed mutual exclusion algorithm // ACM
Transactions on Computer Systems, 3(4), 1985. P.344349.

153

2009 ,
12 ,

.
20092018
. 2011

,

() -

,
. 70

.
5000 ,
230 36 .

, - .
,
9 14 .


, ,

.
,

-
,

,
. 2011
.




-
.
00408 05.11.99


250 .

..