2. PRECEDENCE GRAPHS1) DEFINITIONA precedence graph is a directed acyc dịch - 2. PRECEDENCE GRAPHS1) DEFINITIONA precedence graph is a directed acyc Việt làm thế nào để nói

2. PRECEDENCE GRAPHS1) DEFINITIONA

2. PRECEDENCE GRAPHS
1) DEFINITION
A precedence graph is a directed acyclic graph whose nodes correspond to individual
statements.
a) Example)
Consider the following program segment;
a := x + y;
b := z + 1;
c := a - b;
w := c + l;
3
Suppose we want to execute some of these statements concurrently.
The statement c := a - b cannot be executed before both a and b have been
assigned values. Similarly, w := c + 1 cannot be executed before the new values
of c has been computed. The statements a := x + y and b := z + 1 could be
executed concurrently since neither depends upon the other.
b) In the precedence graph, the following precedence relations exist (fig.-1);
* S2 and S3 can executed after S1 completes.
* S4 can be executed after S2 completes.
* S5 and S6 can be executed after S4 completes.
* S7 can executed only after S5, S6, and S3 complete.
2) CONCURRENCY CONDITIONS
A precedence graph is a directed acyclic graph whose nodes correspond to individual
statements. In other words, A edge from node Si to node Sj => Sj can be executed
only after statement Si has completed execution.
a) Define notation
* R(Si) = {al, a2, a3 ....., an}, the read set for Si, is the set of all variables
whose values are referenced in statement Si during the execution.
* W(Si) = {b1, b2, ..., bn}. the write set for Si, is the set of all variables whose
values are changed (written) by the execution of statement Si.
4
b) Examples
* The statement c:= a - b;
R(c := a - b) = {a, b}
W(c := a - b) = {c}
* The statement w := c + 1;
R(w := c + 1) = {c}
W(w := c + 1) = {w}
* The statement x := x + 1;
R(x := x + 2) = W(x := x + 2) = {x}
(the intersection of R(Si) and W(Si) need not be null)
* The statement read(a)
R(read(a)) = { }
W(read(a)) = {a}
c) Bernstein's conditions
Following three conditions must be satisfied for Two successive statements S1 and
S2 to be executed concurrently and still produce the same result.
i) R(S1) W(S2) = { }
ii) W(S1) R(S2) = { }
iii) W(S1) W(S2) = { }
* Questions: - two statement in a program be executed concurrently then produce
same result?
- precedencc graph can be correspond to program?
d) Examples of Bernstein's conditions
* S1 : a := x + y and S2 : b := z + 1
R(S1) = {x, y}
R(S2) = {z}
W(S1) = {a}
W(S2) = {b}
S1 and S2 can be executed concurrently (satisfy the Bernstein's conditions)
5
* S2 cannot be executed concurrently with S3: c:= a - b, since
W(S2) R(S3) = {b} R(S2) = {z}
R(S3) = {a, b}
W(S2) = {b}
W(S3) = {w}
3. SPECIFICATION
Limitation of precedence graph lies on its difficulty of using a programming language
since it is a two dimensional object.
1) THE FORK AND JOIN CONSTRUCTS
a) Introduction
The fork L instruction produces two concurrent executions in a program. One
execution starts at the statement labeled L, while the other is the continuation of
the execution at the statement following the fork instruction.
The join instruction provides the means to recombine two concurrent computations
into one. The join instruction has parameter (count) to specify the number of
computations which are to be joined.
count := count - 1;
IF count THEN quit;
where count is a non-negative integer variable, and quit is an instruction which
results in the termination of the execution.
Since computations may execute at different speeds, one may execute the join
before the other.
Join instruction: the join instruction must be executed automatically (two join
statements is equivalent to the serial execution of these two statements)
b) Example 1 :
count := 2;
S1;
FORK L1
S2
.
.
GO TO L2;
L1: S3;
L2: JOIN count; [* count := 2
A4;
6
Note: S2 and S3 can execute concurrently
d) Exercise: construct a precedence graph using a following FORK/JOIN program.
S1;
count := 3;
FORK L1;
S2;
S4;
FORK L2;
S5;
GO TO L3;
L2: S6;
GO TO L3;
L1: S3;
L3: JOIN count;
S7;
Note: statement "L1: S3" is not necessary GOTO L3 since L3 comes next step
count:= 3 (in degree of 3) at S7
Example 2:
Copies from a sequential file "f" to another file "g". By using double buffering with
"r" and "s", this program can read from "f' concurrently with writing "g".
VAR f, g: file of T;
r. s: T;
count: integer
BEGIN
reset (f);
READ (f, r);
WHILE not EOF (f) DO
BEGIN
count := 2;
s := r
FORK L1;
WRITE (g, s);
GOTO L2;
L1: READ (f, r);
L2: JOIN count;
END
WRITE (g. r)
END.
VAR f, g: file of T;
r, s: T;
BEGIN
reset (f);
READ (f, r);
WHILE not EOF (f) DO
BEGIN
s := r;
PARBEGIN
WRITE (g, s);
READ (f, r);
PAREND;
END
WRITE (g. r)
END.
8
3) THE CONCURRENT STATEMENT
a) Introduction
Limitation of FORK/JOIN: program has an awkward control structure (GO-TO
statement has undesirable effects)
A higher-level language construct for specifying concurrency is the
PARBEGIN/PAREND statement which has the following form:
PARBEGIN S1; S2; ...; Sn PAREND;
All statements enclosed between PARBEGIN and PAREND can be executed
concurrently.
b) Example:
S1;
PARBEGIN
S3;
BEGIN
S2;
S4;
PARBEGIN
S5;
S6;
PAREND;
END;
PAREND;
S7;
c) Strength of concurrent statement (PARBEGIN/PAP. END):
Early added to a modem block-structured high-level language and have the
advantages of structured control statements (add other mechanisms such as
semaphores).
9
3) COMPARISON
a) Introduction
The concurrent statement (PARBEGIN/PAREND) is not powerful enough to model
all possible precedence graph. On the other hand, in terms of modeling
precedence graphs, the FORK/JOIN construct is more powerful than the concurrent
statement.
b) Example:
Can you construct an equivalent program using PARBEGIN/PARENT) to the
following precedence graph ?
* Precedence graph with no corresponding concurrent statement
* FORK/JOIN construct for above precedence graph
S1;
countl := 2;
FORK L1;
S2;
S4;
count2 := 2;
FORK L2;
S5;
GO TO L3;
L1: S3;
L2: JOIN countl;
S6;
L3: JOIN count2;
S7:
0/5000
Từ: -
Sang: -
Kết quả (Việt) 1: [Sao chép]
Sao chép!
2. ưu tiên đồ thị
1) định nghĩa
thị ưu tiên là một đồ thị acyclic đạo diễn có các nút tương ứng với cá nhân
báo cáo.
một) ví dụ)
xem xét đoạn chương trình sau đây;
một: = xy;
b: = z 1;
c: = a - b;
w: = c l;
3
giả sử chúng ta muốn thực hiện một số các báo cáo này đồng thời.
c tuyên bố: = một - b không thể được thực hiện trước khi cả hai một và b đã
gán giá trị. Tương tự, w: = c 1 không thể được thực hiện trước khi các giá trị mới
c đã được tính toán. Những điều khoản một: = x y và b: = z 1 có thể
thực hiện đồng thời vì không phụ thuộc vào khác.
b) trong biểu đồ được ưu tiên, các mối quan hệ được ưu tiên sau tồn tại (hình 1);
* S2 và S3 có thể thực hiện sau khi hoàn tất S1.
* S4 có thể được thực hiện sau khi hoàn tất S2.
* S5 và S6 có thể được thực hiện sau khi hoàn tất S4.
* S7 có thể thực hiện chỉ sau khi S5, S6 và S3 hoàn chỉnh.
2) điều kiện CONCURRENCY
thị ưu tiên là một đồ thị acyclic đạo diễn có các nút tương ứng với cá nhân
báo cáo. In other words, có thể được thực hiện một cạnh từ nút Si để node Sj => Sj
chỉ sau khi tuyên bố Si đã hoàn thành thực hiện.
một) xác định ký hiệu
* R(Si) = {al, a2, a3..., một}, đọc đặt cho Si, là tập hợp của tất cả các biến
có giá trị được tham chiếu trong tuyên bố Si trong thực hiện.
* W(Si) = {b1, b2,..., bn}. viết đặt cho Si, là tập hợp của tất cả các biến có
giá trị đang thay đổi (văn) bởi thực hiện tuyên bố Si.
4
b) ví dụ
* c: tuyên bố = a - b;
R (c: = a - b) = {a, b}
W (c: = a - b) = {c}
* w tuyên bố: = c 1;
R (w: = c 1) = {c}
W(w:= c 1) = {w}
* câu x: = x 1;
R (x: = x 2) = W (x: = x 2) = {x}
(giao điểm của R(Si) và W(Si) cần phải được null)
* tuyên bố read(a)
R(read(a)) = {}
W(read(a)) = {một}
điều kiện c) Bernstein
sau ba điều kiện phải được hài lòng cho hai báo cáo kế tiếp S1 và
S2 được thực hiện đồng thời và vẫn còn sản xuất các kết quả tương tự.
tôi) R(S1) W(S2) = {}
II) W(S1) R(S2) = {}
iii) W(S1) W(S2) = {}
* câu hỏi: - hai tuyên bố trong một chương trình được thực hiện đồng thời sản xuất sau đó
cùng một kết quả?
-đồ thị precedencc có thể tương ứng với chương trình?
d) điều kiện ví dụ của Bernstein
* S1: một: = x y và S2: b: = z 1
R(S1) = {x, y}
R(S2) = {z}
W(S1) = {a}
W(S2) = {b}
S1 và S2 có thể được thực hiện đồng thời (đáp ứng điều kiện của Bernstein)
5
* S2 không thể được thực hiện đồng thời với S3: c: = a - b, since
W(S2) R(S3) = {b} R(S2) = {z}
R(S3) = {a, b}
W(S2) = {b}
W(S3) = {w}
3. Đặc điểm kỹ thuật
các giới hạn của đồ thị được ưu tiên nằm trên khó khăn của việc sử dụng một ngôn ngữ lập trình
vì nó là một hai chiều đối tượng.
1) THE FORK và tham gia xây dựng
một) giới thiệu
hướng dẫn ngã ba L sản xuất hai vụ xử tử đồng thời trong một chương trình. Một
thực hiện bắt đầu lúc tuyên bố có nhãn L, trong khi các khác là việc tiếp tục
thực hiện tại các tuyên bố sau hướng dẫn fork.
hướng dẫn tham gia cung cấp các phương tiện để tái tính toán đồng thời hai
thành một. Hướng dẫn tham gia có tham số (bá tước) để chỉ định số
tính toán được dự định được gia nhập.
tính: = tính - 1;
nếu tính <>sau đó bỏ;
đó tính là một số nguyên không âm biến, và bỏ thuốc lá là một hướng dẫn mà
dẫn đến việc chấm dứt của thực hiện.
kể từ khi tính toán có thể thực hiện ở tốc độ khác nhau, một trong những có thể thực hiện tham gia
trước khác.
tham gia giảng dạy: hướng dẫn tham gia phải được thực hiện tự động (hai tham gia
báo cáo là tương đương để thực hiện nối tiếp các báo cáo hai)
b) ví dụ 1:
tính := 2;
S1;
FORK L1
S2
.
.
đi để L2;
L1: S3;
L2: tham gia tính; [* tính: = 2
A4;
6
ghi chú: S2 và S3 có thể thực hiện đồng thời
d) Tập thể dục: xây dựng một biểu đồ được ưu tiên bằng cách sử dụng một sau FORK/tham gia chương trình.
S1;
tính: = 3;
FORK L1;
S2;
S4;
FORK L2;
S5;
đi để L3;
L2: S6;
đi để L3;
L1: S3;
L3: tham gia tính;
S7;
ghi chú: tuyên bố "L1: S3" không phải là cần thiết GOTO L3 kể từ khi L3 đến bước tiếp theo
tính:= 3 (trong mức độ 3) tại S7
ví dụ 2:
bản sao từ một tập tin trình tự "f" vào một tập tin "g". Bằng cách sử dụng bộ đệm đôi với
"r" và "s", chương trình này có thể đọc từ "f' đồng thời với văn bản"g".
VAR f, g: tập tin của T;
r. s: T;
tính: số nguyên
bắt đầu
đặt lại (f);
đọc (f, r);
trong khi không EOF (f) làm
bắt đầu
tính: = 2;
s: = r
FORK L1;
viết (g, s);
GOTO L2;
L1: đọc (f, r);
L2: tham gia tính;
cuối
viết (g. r)
cuối.
VAR f, g: tập tin của T;
r, s: T;
bắt đầu
đặt lại (f);
đọc (f, r);
trong khi không EOF (f) làm
bắt đầu
s: = r;
PARBEGIN
viết (g, s);
đọc (f, r);
PAREND;
cuối
viết (Project r)
cuối.
8
3) THE tuyên bố đồng thời
một) giới thiệu
giới hạn của ngã ba/tham gia: chương trình có một cấu trúc điều khiển khó khăn (GO TO
tuyên bố có tác dụng không mong muốn)
một xây dựng ngôn ngữ cao cấp để chỉ định concurrency là các
Tuyên bố PARBEGIN/PAREND có dạng sau:
PARBEGIN S1; S2; ...; SN PAREND;
báo cáo tất cả bao bọc giữa PARBEGIN và PAREND có thể được thực thi
đồng thời.
b) ví dụ:
S1;
PARBEGIN
S3;
bắt đầu
S2;
S4;
PARBEGIN < ==>
S5;
S6;
PAREND;
kết thúc;
PAREND;
S7;
c) sức mạnh của đồng thời tuyên bố (PARBEGIN/PAP. Kết thúc):
sớm bổ sung vào một modem khối cấu trúc cao cấp ngôn ngữ và có các
lợi thế của cấu trúc điều khiển báo cáo (Thêm các cơ chế khác chẳng hạn như
semaphores).
9
3) so sánh
một) giới thiệu
tuyên bố đồng thời (PARBEGIN/PAREND) không phải là đủ mạnh để mô hình
tất cả có thể ưu tiên đồ thị. On the other Hand, trong điều khoản của mô hình
đồ thị được ưu tiên, ngã ba/tham gia xây dựng là mạnh hơn so với đồng thời
tuyên bố.
b) ví dụ:
Bạn có thể xây dựng một chương trình tương đương bằng cách sử dụng PARBEGIN/phụ huynh) để các
sau đồ thị ưu tiên?
* đồ thị được ưu tiên với không có tuyên bố đồng thời tương ứng
* FORK/tham gia xây dựng cho trên đồ thị ưu tiên
S1;
countl: = 2;
FORK L1;
S2;
S4;
count2: = 2;
FORK L2;
S5;
đi để L3;
L1: S3;
L2: tham gia countl;
S6;
L3: tham gia count2;
S7:
đang được dịch, vui lòng đợi..
Kết quả (Việt) 2:[Sao chép]
Sao chép!
2. PRECEDENCE GRAPHS
1) DEFINITION
A precedence graph is a directed acyclic graph whose nodes correspond to individual
statements.
a) Example)
Consider the following program segment;
a := x + y;
b := z + 1;
c := a - b;
w := c + l;
3
Suppose we want to execute some of these statements concurrently.
The statement c := a - b cannot be executed before both a and b have been
assigned values. Similarly, w := c + 1 cannot be executed before the new values
of c has been computed. The statements a := x + y and b := z + 1 could be
executed concurrently since neither depends upon the other.
b) In the precedence graph, the following precedence relations exist (fig.-1);
* S2 and S3 can executed after S1 completes.
* S4 can be executed after S2 completes.
* S5 and S6 can be executed after S4 completes.
* S7 can executed only after S5, S6, and S3 complete.
2) CONCURRENCY CONDITIONS
A precedence graph is a directed acyclic graph whose nodes correspond to individual
statements. In other words, A edge from node Si to node Sj => Sj can be executed
only after statement Si has completed execution.
a) Define notation
* R(Si) = {al, a2, a3 ....., an}, the read set for Si, is the set of all variables
whose values are referenced in statement Si during the execution.
* W(Si) = {b1, b2, ..., bn}. the write set for Si, is the set of all variables whose
values are changed (written) by the execution of statement Si.
4
b) Examples
* The statement c:= a - b;
R(c := a - b) = {a, b}
W(c := a - b) = {c}
* The statement w := c + 1;
R(w := c + 1) = {c}
W(w := c + 1) = {w}
* The statement x := x + 1;
R(x := x + 2) = W(x := x + 2) = {x}
(the intersection of R(Si) and W(Si) need not be null)
* The statement read(a)
R(read(a)) = { }
W(read(a)) = {a}
c) Bernstein's conditions
Following three conditions must be satisfied for Two successive statements S1 and
S2 to be executed concurrently and still produce the same result.
i) R(S1) W(S2) = { }
ii) W(S1) R(S2) = { }
iii) W(S1) W(S2) = { }
* Questions: - two statement in a program be executed concurrently then produce
same result?
- precedencc graph can be correspond to program?
d) Examples of Bernstein's conditions
* S1 : a := x + y and S2 : b := z + 1
R(S1) = {x, y}
R(S2) = {z}
W(S1) = {a}
W(S2) = {b}
S1 and S2 can be executed concurrently (satisfy the Bernstein's conditions)
5
* S2 cannot be executed concurrently with S3: c:= a - b, since
W(S2) R(S3) = {b} R(S2) = {z}
R(S3) = {a, b}
W(S2) = {b}
W(S3) = {w}
3. SPECIFICATION
Limitation of precedence graph lies on its difficulty of using a programming language
since it is a two dimensional object.
1) THE FORK AND JOIN CONSTRUCTS
a) Introduction
The fork L instruction produces two concurrent executions in a program. One
execution starts at the statement labeled L, while the other is the continuation of
the execution at the statement following the fork instruction.
The join instruction provides the means to recombine two concurrent computations
into one. The join instruction has parameter (count) to specify the number of
computations which are to be joined.
count := count - 1;
IF count <> THEN quit;
where count is a non-negative integer variable, and quit is an instruction which
results in the termination of the execution.
Since computations may execute at different speeds, one may execute the join
before the other.
Join instruction: the join instruction must be executed automatically (two join
statements is equivalent to the serial execution of these two statements)
b) Example 1 :
count := 2;
S1;
FORK L1
S2
.
.
GO TO L2;
L1: S3;
L2: JOIN count; [* count := 2
A4;
6
Note: S2 and S3 can execute concurrently
d) Exercise: construct a precedence graph using a following FORK/JOIN program.
S1;
count := 3;
FORK L1;
S2;
S4;
FORK L2;
S5;
GO TO L3;
L2: S6;
GO TO L3;
L1: S3;
L3: JOIN count;
S7;
Note: statement "L1: S3" is not necessary GOTO L3 since L3 comes next step
count:= 3 (in degree of 3) at S7
Example 2:
Copies from a sequential file "f" to another file "g". By using double buffering with
"r" and "s", this program can read from "f' concurrently with writing "g".
VAR f, g: file of T;
r. s: T;
count: integer
BEGIN
reset (f);
READ (f, r);
WHILE not EOF (f) DO
BEGIN
count := 2;
s := r
FORK L1;
WRITE (g, s);
GOTO L2;
L1: READ (f, r);
L2: JOIN count;
END
WRITE (g. r)
END.
VAR f, g: file of T;
r, s: T;
BEGIN
reset (f);
READ (f, r);
WHILE not EOF (f) DO
BEGIN
s := r;
PARBEGIN
WRITE (g, s);
READ (f, r);
PAREND;
END
WRITE (g. r)
END.
8
3) THE CONCURRENT STATEMENT
a) Introduction
Limitation of FORK/JOIN: program has an awkward control structure (GO-TO
statement has undesirable effects)
A higher-level language construct for specifying concurrency is the
PARBEGIN/PAREND statement which has the following form:
PARBEGIN S1; S2; ...; Sn PAREND;
All statements enclosed between PARBEGIN and PAREND can be executed
concurrently.
b) Example:
S1;
PARBEGIN
S3;
BEGIN
S2;
S4;
PARBEGIN <==>
S5;
S6;
PAREND;
END;
PAREND;
S7;
c) Strength of concurrent statement (PARBEGIN/PAP. END):
Early added to a modem block-structured high-level language and have the
advantages of structured control statements (add other mechanisms such as
semaphores).
9
3) COMPARISON
a) Introduction
The concurrent statement (PARBEGIN/PAREND) is not powerful enough to model
all possible precedence graph. On the other hand, in terms of modeling
precedence graphs, the FORK/JOIN construct is more powerful than the concurrent
statement.
b) Example:
Can you construct an equivalent program using PARBEGIN/PARENT) to the
following precedence graph ?
* Precedence graph with no corresponding concurrent statement
* FORK/JOIN construct for above precedence graph
S1;
countl := 2;
FORK L1;
S2;
S4;
count2 := 2;
FORK L2;
S5;
GO TO L3;
L1: S3;
L2: JOIN countl;
S6;
L3: JOIN count2;
S7:
đang được dịch, vui lòng đợi..
 
Các ngôn ngữ khác
Hỗ trợ công cụ dịch thuật: Albania, Amharic, Anh, Armenia, Azerbaijan, Ba Lan, Ba Tư, Bantu, Basque, Belarus, Bengal, Bosnia, Bulgaria, Bồ Đào Nha, Catalan, Cebuano, Chichewa, Corsi, Creole (Haiti), Croatia, Do Thái, Estonia, Filipino, Frisia, Gael Scotland, Galicia, George, Gujarat, Hausa, Hawaii, Hindi, Hmong, Hungary, Hy Lạp, Hà Lan, Hà Lan (Nam Phi), Hàn, Iceland, Igbo, Ireland, Java, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Kurd, Kyrgyz, Latinh, Latvia, Litva, Luxembourg, Lào, Macedonia, Malagasy, Malayalam, Malta, Maori, Marathi, Myanmar, Mã Lai, Mông Cổ, Na Uy, Nepal, Nga, Nhật, Odia (Oriya), Pashto, Pháp, Phát hiện ngôn ngữ, Phần Lan, Punjab, Quốc tế ngữ, Rumani, Samoa, Serbia, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenia, Somali, Sunda, Swahili, Séc, Tajik, Tamil, Tatar, Telugu, Thái, Thổ Nhĩ Kỳ, Thụy Điển, Tiếng Indonesia, Tiếng Ý, Trung, Trung (Phồn thể), Turkmen, Tây Ban Nha, Ukraina, Urdu, Uyghur, Uzbek, Việt, Xứ Wales, Yiddish, Yoruba, Zulu, Đan Mạch, Đức, Ả Rập, dịch ngôn ngữ.

Copyright ©2025 I Love Translation. All reserved.

E-mail: