chapter6 操作系统概要1.ppt

chapter6 操作系统概要1

该图是对死锁现象的一种非形式的说明,横轴和纵轴分别表示进程P和进程Q的进展(用完成的指令条数来度量)。 从该空间的原点开始的任何一条阶梯形折线为二进程的共同进展路径,这条进展路径只能前进,因为指令的执行是不能倒退的。 Unsafe state is not a deadlocked state. * Deadlock Detection with Multiple Resources of Each Type (5) Example: Deadlock Detection with Multiple Resources of Each Type (6) For example( E,A,C,R are as shown): First, there are 2 first resources,1 second resource (see A), so, only the third one can be satisfied; so the third process go get resources and executes and then release all its resources, so giving A=(2 2 2 0)=(0+2,1+1,2+0,0+0) At this point, process 2 can run and return its resources ,so, A=(4 2 2 1) Now, the remaining process can run, there is no deadlock E=(4 2 3 1) 0 0 1 0 2 0 0 1 0 1 2 0 2 0 0 1 1 0 1 0 2 1 0 0 C= R= A=(2 1 0 0) 6.4.3 Recovery from Deadlock 死锁恢复的方法Recovery from Deadlock 剥夺法恢复Recovery through preemption 临时将某些资源从其持有者手里转移到另一个进程中 往往需要人工干预 回退法恢复Recovery through rollback 如果死锁行为都类似 为进程设置检查点checkpoint,将进程的状态写入特定文件中以备重启:memory image、resource state 周期地对进程进行检查 杀死进程来恢复Recovery through killing processes 一种是杀死环中的某个进程:不能保证死锁的解除 一种是杀死环外的某个进程 原则是尽量杀死不重要或可重复执行不带副作用的进程 6.4.3 Recovery from Deadlock 1. Recovery through preemption In some cases it may be possible to temporarily take a resource away from its current owner and give it to another process. 2. Recovery through rollback (回滚) The system designers and machine operators 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. 6.4.3 Recovery from Deadlock 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 that resource by starting one of its earlier checkpoints. 3. Recovery through killing processes The crudest way to break a deadlock is to kill one or more processes. One possibility is to kill a process in the cycle. A process not in the cycle ca

文档评论(0)

1亿VIP精品文档

相关文档