Information Technology Reference
In-Depth Information
Mutual
Exclusion
Implementation
Synchronization
Advantages
Disadvantages
Low-level im-
plementation,
Can cause
deadlock
Semaphores
High-level im-
plementation
Monitors
Message
Passing
FIGURE 17.5
A comparison between the three synchronization methods.
3. Hold and wait
4. No preemption
Eliminating any of these four conditions will eliminate deadlock. Mutual exclusion
applies to those resources that possibly no longer can be shared, such as printers,
disk drives, and so on (LaPlante, 2002). The circular wait condition will occur when
a chain of processes exist that holds resources needed by an other process. Circular
wait can be eliminated by imposing an explicit order on the resources and forcing
all processes to request all the resources listed. The hold and wait condition occurs
when processes request a resource and then lock it until that resource is filled. Also,
eliminating preemption will eliminate deadlock. This means that if a low-priority
task holds a resource protected by semaphore S, and if a higher priority interrupts,
then the lower priority task will cause the high-priority task to wait forever.
Once deadlock in the system has been detected, there are several ways to deal with
the problem. Some strategies include:
1. Preemption—take an already allocated resource away from a process and give
it to another process. This can present problems. Suppose the resource is a
printer and a print job is half completed. It is often difficult to restart such a job
without completely starting over.
2. Rollback—In situations in which deadlock is a real possibility, the system pe-
riodically can make a record of the state of each process, and when deadlock
occurs, it can roll everything back to the last checkpoint and restart but allocat-
ing resources differently so that deadlock does not occur. This means that all
work done after the checkpoint is lost and will have to be redone.
3. Kill one or more processes—this solution is the simplest and the crudest but is
also effective. 33
33 http://www.cs.rpi.edu/academics/courses/fall04/os/c10/index.html
 
Search WWH ::




Custom Search