Intro to Operating Systems

Only available on StudyMode
  • Topic: Lock, Race condition, Deadlock
  • Pages : 2 (382 words )
  • Download(s) : 92
  • Published : February 27, 2012
Open Document
Text Preview
Exercise 8: Compare and contrast multiprocessing and concurrent processing. Describe the role of process synchronization for both systems.

Exercise 10: SEE ANSWERS

Exercise 13: SEE ANSWERS

Advanced Exercise 16: SEE ANSWERS

ANSWERS:

Exercise 2:

a. Example of Deadlock: When two people are about to buy the same product at the same time.

b. Example of Starvation: When one person borrowed a pen from his classmate and his classmate gets his pen back.

c. Example of Race: When two guys have the same girlfriend.

Deadlocks can be resolved by (in this example) one of the two people substituting the one product that they are about to buy for a generic version of the same product.

Exercise 9:

1. Under the above policy, 2 processes can be run simultaneously or active at once. 2. The minimum number of tape drives that may be idle as a result of this policy is 3 (see diagram). The maximum number of tape drives that may be idle as a result of this policy is 5 (see diagram). [pic]

B1. The maximum number of jobs that can be in progress at once is 3. B2.The minimum number of tape drives that may be idle as a result of this policy is zero (0) (see diagram). The maximum number of tape drives that may be idle as a result of this policy is one (1) (see diagram). [pic]

Advanced Exercise 14:

An unsafe state may not necessarily lead to deadlock, it just means that we cannot guarantee that deadlock will not occur. Thus, it is possible that a system in an unsafe state may still allow all processes to complete without deadlock occurring. Consider the situation where a system has 12 resources allocated among processes P0, P1, and P2. There sources are allocated according to the following policy:

Max Current Need
P0 10 5 5
P1 4 2 2
P2 9 3 6

for (int i = 0; i < n; i++) {
// first find a thread that...
tracking img