In: Computer Science
Operating system:
A CS student assigned to work on deadlocks thinks of the following way to eliminate deadlocks. When a process requests a resource , it specifies a time limit. if the process blocks because the resource is not available , a timer is started. If the time limit is exceeded, the process is released and allowed to run again. If you were the professor, what grade would you give this proposal and why?
Suppose we have two process P1 and P2. And one instance each of resource R1 and R2.
Both the process requires one instance of R1 and one instance of R2 to execute.
Suppose P1 acquires R1 and gets preempted. Then P2 acquires R2 and gets preeempted. Then P1 again runs and gets blocked for trying to acquire R2 and P2 again gets blocked trying to acquire P2. Thus both are blocked and now both of them will restart again since they are in deadlock. Suppose both of them start again and the same situation arises. Thus the two process will repeatedly acquire resource, get blocked and restart.
This situation might happen. So I would rate 3/10 since there is a very rare of solving deadlock.
One of suggestion I would give is to acquire the resource in same order. That is first acquire R1, then R2 then R3 and so on......
If you have any questions comment down. Please don't simply downvote and leave. If you are satisfied with answer, please? upvote thanks