retagged by
9,651 views
35 votes
35 votes

Consider a computer system with multiple shared resource types, with one instance per resource type. Each instance can be owned by only one process at a time. Owning and freeing of resources are done by holding a global lock $(L)$. The following scheme is used to own a resource instance:

function OWNRESOURCE(Resource R)
    Acquire lock L // a global lock
    if R is available then
        Acquire R    
        Release lock L
    else
        if R is owned by another process P then     
        Terminate P, after releasing all resources owned by P    
        Acquire R    
        Restart P   
        Release lock L   
        end if   
    end if    
end function

Which of the following choice(s) about the above scheme is/are correct?

  1. The scheme ensures that deadlocks will not occur
  2. The scheme may lead to live-lock
  3. The scheme may lead to starvation
  4. The scheme violates the mutual exclusion property
retagged by

2 Answers

Best answer
53 votes
53 votes

A system is in Deadlock when all the processes are in Waiting state. This is similar to a traffic jam where no vehicle moves.

A system is in Livelock when the processes do repeated work without any progress for the system (still no useful work). This is similar to a traffic jam where some vehicles reverses and then move forward hitting the same block again.

Now, both deadlock and livelock are mutually exclusive – at any point of time only one can happen in a system. But both of them imply no progress for system and hence starvation for the processes involved.

Now, coming to the given question, any process can kick out another process and then acquire the nedeed resource and this can go in a cyclic fashion ensuring a livelock. There is no possibility of a deadlock as at any time a process is free to kick out another process. Since there is a possibility of livelock, starvation possibility is also there. So, options A, B and C are TRUE. 

A process is acquiring the resource owned by another process only after terminating the other process. Hence there is no violation of mutual exclusion property here.

Correct Answer: A;B;C. 

selected by
1 votes
1 votes
  1. Deadlock won’t occur because if any process requires the same resource which is being used by some other process then the older process will be first terminated then the resource will be acquired by this process and then the older process will be restarted. So at any time no process is waiting for other to do some task.
  2. As mentioned by @zxy123, in live lock the processes can’t proceed towards their completion. This can happen if every process is made to restart(before its completion) by other processes.
  3. Because of the reason mentioned in (2), the processes may restart indefinitely leading to starvation.
  4. At any time, no resource is held by more than one process. So it is false.
Answer:

Related questions