OPERATING SYSTEMS [UNIT -3]
DEADLOCKS - System Model
In a 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, because the resources it has
requested are held by other waiting processes. This situation is called a
Deadlock.
SYSTEM MODEL
A system consists of a finite number of resources to be distributed among a
number of competing processes. The resources may be partitioned into several
types (or classes), each consisting of some number of identical instances. CPU
cycles, files, and I/O devices (such as printers and DVD drives) are examples of
resource types. If a system has two CPUs, then the resource type CPU has two
instances. Similarly, the resource type printer may have five instances.
If a process requests an instance of a resource type, the allocation of any
instance of the type should satisfy the request. If it does not, then the instances
are not identical, and the resource type classes have not been defined properly.
For example, a system may have two printers. These two printers may be
defined to be in the same resource class if no one cares which printer prints
which output. However, if one printer is on the ninth floor and the other is in the
basement, then people on the ninth floor may not see both printers as equivalent,
and separate resource classes may need to be defined for each printer.
A process must request a resource before using it and must release the resource
after using it. A process may request as many resources as it requires to carry
out its designated task. Obviously, the number of resources requested may not
exceed the total number of resources available in the system. In other words, a
process cannot request three printers if the system has only two.
Under the normal mode of operation, a process may utilize a resource in only
the following sequence:
1) Request. The process requests the resource. If the request cannot be
granted immediately (for example, if the resource is being used by
another process), then the requesting process must wait until it can
acquire the resource.
2) Use. The process can operate on the resource (for example, if the resource
is a printer, the process can print on the printer).
3) Release. The process releases the resource.