792 views
0 votes
0 votes
One way to prevent deadlocks is to eliminate the hold-and-wait condition. In the text it was proposed that before asking for a new resource, a process must first release whatever resources it already holds (assuming that is possible). However, doing so introduces the danger that it may get the new resource but lose some of the existing ones to competing processes. Propose an improvement to this scheme.

2 Answers

0 votes
0 votes
Assuming that preemption is possible, (its default as question itself assumes it).

Problem with given algorithm: Requesting process may lose what it already has. This may lead to it never getting all resources it may need. So we have to think of a way to stop this.

New Algorithm: When we request new resource if it can be available and can be given to it then it will get it and no one can get what resources it already previously has.

Is deadlock possible? No. Also there is no danger that the new resource is acquired but existing ones lost.

Other way: (not answer to this question as its asking for improvement of given scheme and not new scheme)

A resource can get all required resources before it start execution. This will avoid deadlock, but will result in reduced throughputs as resources are held by processes even when they are not needed. They could have been used by other processes during this time.
0 votes
0 votes
One improvement can be to release only those resources which form a cycle (and hence a deadlock) at the moment. In that way, the probability of losing resources it already held can be reduced.

Related questions

251
views
0 answers
0 votes
admin asked Oct 30, 2019
251 views
Local Area Networks utilize a media access method called CSMA/CD, in which stations sharing a bus can sense the medium and detect transmissions as well as ... you suggest a solution to this anomaly?Can starvation occur with this scenario?
218
views
0 answers
0 votes
admin asked Oct 30, 2019
218 views
Assume two processes are issuing a seek command to reposition the mechanism to access the disk and enable a read command. Each process is interrupted before ... or a livelock? What methods would you recommend to handle the anomaly?
519
views
1 answers
0 votes
admin asked Oct 30, 2019
519 views
Explain the differences between deadlock, livelock, and starvation.
265
views
0 answers
0 votes
admin asked Oct 30, 2019
265 views
Main memory units are preempted in swapping and virtual memory systems. The processor is preempted in time-sharing environments. Do you think that these ... handle resource deadlock or for other purposes? How high is their overhead?