Monday 17 April 2017

DECEMBER 2015 - PAPER III - Q NO 39

DECEMBER 2015 – PAPER III – Q.NO 39

This question is based on the concept of deadlock avoidance. In order to understand the theory behind this concept, refer to my earlier post on the same topic.

http://ugcnetsolved-computerscience.blogspot.in/2017/04/deadlock-avoidance.html

Let us try to understand the question and solve it based on the theory given above.

Consider a system with twelve magnetic tape drives and three processes p1,p2 and p3. Process p1 requires maximum ten tape drives, process p2 may need as many as four tape drives and p3 may need upto nine tape drives. Suppose that at time t1, process p1 is holding five tape drives, process p2 is holding two tape drives and process p3 is holding three tape drives. At time t1, system is in :
(1) Safe state
(2) Unsafe state
(3) Deadlocked state
(4) Starvation state

Explanation:-

Below is a table given depicting the maximum needs and current needs of each process.

MAXIMUM NEEDS CURRENT NEEDS
p0 10 5
p1 4 2
p2 9 3

Remember, there is no specific formula to solve this problem. It is more of understanding, logic and common sense for solving this.

Total number of magnetic tapes = 12

Already allocated = 10

Number of free magnetic tapes = 12 – 10 =2

From the table, we can understand that process p2 requires 2 more tapes for completion and since two tapes are free, they are allocated to process p2.

Process p2 completes its execution, and returns all the four tapes to the sytem.

So, number of free tape drives = 4.

Since process p1 is allocated 5 tape drives, but has a maximum of 10, it may then request 5 more tape drives. Since they are unavailable, process p1 must wait. Similarly, process p3 may request an additional 6 tape drives and have to wait, resulting in a deadlock. So the system is in deadlocked state.

The correct option is 3.

1 comment:

  1. Its p1 process which requires 2 more. Not p2.

    Just thought of telling u the correction :)

    ReplyDelete