0% found this document useful (0 votes)
46 views3 pages

OSG202 Chuong 2 Present

hhhhhhhh

Uploaded by

hoduongtuanvu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views3 pages

OSG202 Chuong 2 Present

hhhhhhhh

Uploaded by

hoduongtuanvu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Independent processes and Cooperating Processes

- Independent process cannot affect or be affected by the execution of


another process
- Cooperating process can affect or be affected by the execution of another
process
- Advantages of process cooperation
o Information sharing
o Computation speed-up
o Modularity
o Convenience

(có thể thấy lợi ích của Cooperating process nhưng để vận dụng đc thì
cuang phải giải quyết nhiều vấn đề )

Problems of shared data:

- Concurrent access to shared data may result in data inconsistency


- Maintaining data consistency requires mechanisms to ensure the orderly
execution of cooperating processes
- Need of mechanism for processes to communicate and to synchronize their
actions
1. Race Conditions
a. Two processes want to access shared memory at same time and the
final result dependson thread scheduling algorithm, are called race
condition
(hai quy trình muốn truy cập vào cùng 1 vị trí bộ nhớ cùng lúc và kết
quả cuối cùng phụ thuộc vào thật toán lên lịch thread thì đc gọi là
race condition ).
(EX: trong lần chạy thứ 1 thì chúng ta chạy chương trình 1 sau đó mới đến
chương trình 2 thì ra kq đúng à 12.

Lần 2 thì chạy chương trình 2 sau đó chạy chương trình 1 nên kq đúng là 11

Lần 3 thì chương trình 1 đang chạy thì bị gián đoạn và chương trình 2 lại bắt đàu
chạy và input của y=5, sau đó chương trình 1 chạy tiếp và thay đổi biến
y=10,nhưng sau nữa chương trình 2 chạy xong và đổi biến y =6 nên ra kq sai)

b. Mutual exclusion is the way to prohibit more than one process from
accessing to shared data at the same time.(mutual exclusion là cách để
chống việc các quy trình truy cập cùng 1 dữ liệu cùng lúc, hay là cách
để chống vấn đề race condition).
2. Critical regions.
a. The Part of the program where the shared memory is accessed is
called Critical Regions (Critical Section)
(phần của chương trình mà bộ nhớ được chia se hay được dùng thì dgl
critical reagions hoặc critical section)
b. Four conditions to provide mutual exclusion:
i. No two processes simultaneously in critical region
ii. No assumptions made about speeds or numbers of CPUs
iii. No process running outside its critical region may block another
process
iv. No process must wait forever to enter its critical region

(phần sau ta sẽ tìm hiểu về các phương án để thực thi mutual


exclusion)

You might also like