Recovery through Pre-emption
In some cases, it may be possible to temporarily take a resource away from its current process and give it to another process. In many cases, manual intervention may be required, especially in batch-processing operating systems running on mainframes.
Taking a resource away from a process for allocating it to another process, and then returning the resource back is highly dependent on the nature of the resource. Recovering this way is frequently difficult or impossible. Choosing the process to suspend depends largely on which ones have resources that can easily be taken back.
Recovery through Rollback
If the system designers and machine operators know that deadlocks are likely, they can arrange to have processes checkpointed periodically. Checkpointing a process means that its state is written to a file so that it can be restarted later. The checkpoint contains not only the memory image but also the resource state, that is, which resources are currently assigned to the process. To be most effective, new checkpoints should not overwrite old ones but should be written to new files, so as the process executes, a whole sequence of checkpoint files is accumulated.
When a deadlock is detected, it is easy to see which resources are needed. To do the recovery, a process that owns a needed resource is rolled back to a point in time before it acquired some other resource by starting one of its earlier checkpoints.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.