Lists of Long Descriptive type Questions that may be asked in Written Exams.
- (1) How deadlock can be prevented? OR Explain deadlock prevention.
Question-1 How deadlock can be prevented? OR Explain deadlock prevention.
Deadlock can be prevented by attacking the one of the four conditions that leads to deadlock.
1) Attacking the Mutual Exclusion Condition
o No deadlock if no resource is ever assigned exclusively to a single process.
o Some devices can be spooled such as printer, by spooling printer output; several processes can generate output at the same time.
o Only the printer daemon process uses physical printer.
o Thus deadlock for printer can be eliminated.
o Not all devices can be spooled.
- Avoid assigning a resource when that is not absolutely necessary.
- Try to make sure that as few processes as possible actually claim the resource.
2) Attacking the Hold and Wait Condition
o Require processes to request all their resources before starting execution.
o A process is allowed to run if all resources it needed is available. Otherwise nothing will be allocated and it will just wait.
o Problem with this strategy is that a process may not know required resources at start of run.
o Resource will not be used optimally.
o It also ties up resources other processes could be using.
o Variation: A process must give up all resources before making a new request. Process is then granted all prior resources as well as the new ones only if all required resources are available.
o Problem: what if someone grabs the resources in the meantime how can the processes save its state?
3) Attacking the No Preemption Condition
o This is not a possible option.
o When a process P0 request some resource R which is held by another process P1 then resource R is forcibly taken away from the process P1 and allocated to P0.
o Consider a process holds the printer, halfway through its job; taking the printer away from this process without having any ill effect is not possible.
4) Attacking the Circular Wait Condition
o To provide a global numbering of all the resources.
o Now the rule is this: processes can request resources whenever they want to,but all requests must be made in numerical order.
o A process need not acquire them all at once.
o Circular wait is prevented if a process holding resource n cannot wait for resource m, if m > n.
o No way to complete a cycle.
o A process may request 1st a CD ROM drive, then tape drive. But it may not request 1st a plotter, then a Tape drive.
o Resource graph can never have cycle
You may be interested in:
Operating System Short Descriptive Questions and Answers
Operating System Multiple Choice Questions Answers (MCQs)
Windows Operating System Online Tests
Linux Operating System Online Tests