Home | Projects | Notes > Operating Systems > Review Questions

Review Questions

 

Computer System Overview

 

Operating System Overview

 

The Process

review-question-process-state-analysis

 

 

Threads

 

Concurrency

 

Deadlock

a) Verify that the Available vector has been correctly calculated.

Resource vector R - Allocation vector A (Allocation matrix converted to a vector) = Available vector V

b) Calculate the Need matrix (CA)

CA=(753421223442233141213433)

c) Show that the current state is safe, that is, show a safe sequence of processes. In addition, to the sequence show how the Available (working vector) changes as each process terminates.

See if you can satisfy any process (based on Need matrix; CA) with currently available resources. If you can find such process, zero out its row in both CA and A and add the retrieved resources (previously allocated to that process) to the Available vector V. If you can find at least 1 sequence where there are enough resources for all processes to finish, one by one, this is a safe state. In this case it's safe!

d) Given the request (3, 2, 3, 3) from Process P5. Should this request be granted? Why or why not?

No. It will result in an unsafe state. Suppose the request has been granted. Recalculate the Allocation matrix A, Need matrix CA, and Available vector V accordingly. Perform the tracking and you'll end up in an unsafe state.

 

problem_6_6

 

a) P0 get(A), get (B) P1 get(D), get(E) P2 get(C), get(F). Now, as soon as P2 get(D) gets called, a circular wait is formed.

problem-6-6-diagram

b) If you impose a strict ordering by resource name, then that would prevent the circular deadlock. Reorder P1 to get B, get D, get E and then reorder P2 to get C, get D, get F.

Above is the solution but I think it still does not prevent the deadlock. Draw in this order:

P0 - get A, B P1 - get B, D P2 - get C, D Now, as soon as P0 - get(C) is called a circular wait is formed.

Check it again!

 

 

References

Stallings, W. (2018). Operating Systems: Internals and Design Principles (9th ed.). Pearson Education, Inc.