Professional Documents
Culture Documents
Chapter 3 Problems
Chapter 3 Problems
PROBLEM 1
List 5 real applications (you haved used) that use IPC
PROBLEM 2
List 5 applications / situations in real worlds that need synchronization
PROBLEM 3
For all the classical synchronization problems, run step by step a certain sequence of instructions among
the processes. Update the state of the used semaphores, and prove such sequence meets all the
requirements of the synchronization constraints.
PROBLEM 4: BARRIER
Barrier is a synchronization problem with the following constraints:
+ We have N processes
+ We need a point at which all the processes MUST reach in order to continue next instructions
+ Figure b) 3 processes reach the barrier, they MUST wait for process C which hasn’t reached the barrier
+ Figure c) when all the processes reach the barrier, all of them can proceed with their next instructions
Use the semaphore to solve this synchronization problem. Write the program is pseudo-code like those
in the slides Hint: used counting semaphore.
(Ví dụ trong thực tế, chuyến xe bus chở khách du lịch đi về, cần phải đảm bảo mọi người lên xe thì xe
mới khởi hành đi về được)
Hint: divide the bridge into 2 sides, each side is a shared resource. (Chia cây cầu thành 2 nửa, mỗi nửa là
một tài nguyên chia sẻ => bài toán trở về bài toán cổ điển: bữa ăn tối của triết gia với 2 người)
PROBLEM 6: CROSSROAD
This is a real-word problem: crossroad is a place where two roads meet and cross each other
Suppose each road has two lanes, and the road only allow us to move straight forward (no turning left or
right).
2
Hint: divide the crossroad into 4 conners, each conner is a shared resource (Chia ngã 4 thành 4 nửa, mỗi
góc là một tài nguyên chia sẻ=> bài toán trở về bài toán cổ điển: bữa ăn tối của triết gia với 4 người, chỉ
có điều tài nguyên bây giờ không phải là tài nguyên bên trái và bên phải nữa)