What do you mean by deadlock? Give
two examples of deadlock prevention.
Deadlock
is a potential problem in any operating system. It occurs when a group of
processes each have been granted exclusive access to some resources, and
each one wants yet another resource that belongs to another process in the
group. All of them are blocked and none will ever run again.
Deadlock
can be defined as: “A set of processes is deadlocked if each process in the set
is waiting for an event that only another process in the set can cause.”
Examples:
§ Two processes each want
to record a scanned document on a CD. Process A requests permission to use the
scanner and is granted it. Process B is programmed differently and request the
CD recorder first and is also granted it. Now A asks for the CD recorder, but
the request is denied until B releases it. Unfortunately, instead of releasing
the CD recorder B asks for the scanner. All this point both processes are
blocked and will remain so forever.
§ In a database system, for
example, a program may have to lock several records it is using, to avoid race
conditions. If process A locks record R1 and Process B locks record R2, and
then each process tries to lock the other one’s record, we also have a deadlock
Thus
deadlocks can occur on hardware resources or on software resources.
Condition
for deadlock:
1. Mutual exclusive condition: only one process at a time can use a
resource
2. Hold and wait: a process holding at
least one resource is waiting to acquire additional resources held by other
processes.
3. No preemption condition: a resource can be
released only voluntarily by the process holding it, after that process has
completed its task.
4. Circular wait: there exists a set {P0,
P1,P2,P3} of waiting processes such that P0 is waiting. For a resource that is
held by P1, P1 is waiting for a resource that is held by P2, P2 is waiting for
a resource held by P3, P3 is waiting for a resource that is held by P0.
No comments:
Post a Comment