admin 管理员组文章数量: 1184232
8.1 List three examples of deadlocks that are not related to a computersystem environment.
a.两辆车从相反方向穿过一座单行道桥。
b.一个人从梯子上下来,而另一个人在爬梯子。
c.两列列车在同一轨道上相互靠近。
8.2 Suppose that a system is in an unsafe state. Show that it is possible for the threads to complete their execution without entering a deadlocked state.
不安全状态不一定会导致死锁,它只是意味着我们不能保证死锁不会发生。因此,处于不安全状态的系统可能仍然允许完成所有process而不发生死锁。考虑这样一种情况,即系统在process P0、P1和P2之间分配了12个资源。资源按照以下策略分配
目前有两种可用资源。由于process P1可能完成,此系统处于不安全状态,因此总共释放了四个资源。但我们不能保证P0和P2 process 能够完成。然而,流程可能会在请求任何进一步的资源之前释放资源。例如,process P2可以释放一个资源,从而将资源总数增加到五个。这允许process P0完成,这将释放总共九个资源,从而允许process P2也完成.
8.3 Consider the following snapshot of a system:
Answer the following questions using the banker’s algorithm:
a. What is the content of the matrix Need?
b. Is the system in a safe state?
c. If a request from thread T1 arrives for (0,4,2,0), can the request be granted immediately?
a、 过程P0到P4的需求值分别为(0、0、0、0)、(0、7、5、0)、(1、0、0、2)、(0、0、2、0)和(0、6、4、2)。
b、对当可用值等于(1、5、2、0)时,可以运行processP0或P3。一旦流程P3运行,它就会释放其资源,从而允许所有其他现有流程运行。
c、这将导致可用的值为(1、1、0、0)。可以完成的process的一个顺序是P0、P2、P3、P1和P4.
8.4 A possible method for preventing deadlocks is to have a single, higher-order resource that must be requested before any other resource. For example, if multiple threads attempt to access the synchronization objects A ··· E, deadlock is possible. (Such synchronization objects may include mutexes, semaphores, condition variables, and the like.) We can prevent deadlock by adding a sixth object F. Whenever a thread wants to acquire the synchronization lock for any object A ··· E, it must first acquire the lock for object F. This solution is known as containment: the locks for objec
版权声明:本文标题:操作系统恐龙书第十版课后答案 ch08 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1758310505a3084299.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论