In multiprogramming environment, several processes may compete for a finite number of resources. A process requests resources; if the resources are not available at that time, the process enters a waiting state. Sometimes, a waiting process is never again able to change state, beacause the resources it has requested are held by other waiting processes. This situation is calle deadlocks.
Perhaps the best illustration of a deadlock can be draw from a law pass by the Kanas legislature early in the 20th century. It said, in part: “When two trains approach each other at a crossing, both shall come to full stop and neither shall start up again until the other has gone”.
Here, We describe methods that an operating system can use to prevent or deal with deadlocks. Although some application can identify programs that may deadlock, operating systems typically do not provide deadlock prevention facilities, and it remains the responsibility of programers to ensure that they design deadlock-free programs.
System Model –
A system consists of a finite number of resources to be distribute among a number of competing processes. The resources may be partition into several types (or classes), each consisting of some number of isentical instances. CPU cycles, files, and I/O devices (such as printers and DVD drivers) are examples of resources types. If a system has two CPU’s, then the resource type CPU has two instances. Similarly, the resource type printer may have five instances.
Under the normal mode of operation, a process may utilize a resource in only the following sequence:
- Request: The process requests the resource. If the request cannot be grant immediately (for example, the resource is being use by another process), then the requesting process must wait until it can aquire the resource.
- Use: The process can operate on the resource (for example, if the resource is a printer, the process can print on the printer).
- Release: The process releases the resource.