- 1、本文档共22页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
操作系统习题课_1
习题课 A computer system has 8 printers that were competed by K process, and each process can take up no more than 3 printers. What is the minimum value of K to must cause the system deadlock? What is the minimum value of K to may be cause the system deadlock? 先看一个简单的例子: 8个资源,K个进程,每个进程使用N ?3个资源 K=1 ? K=2 ? K=3 ? K=4: Suppose an infinite capacity warehouse can hold two type goods A and B. But the number of A and B must satisfy the inequality as follow: -M?the number of A-the number of B?N Here, M and N are positive integer. Please description A and B storage process by semaphores and PV operation. 问题分析: 已知条件 -M≤A物品数量-B物品数量≤N?可以拆成两个不等式,即 A物品数量-B物品数量≤N, B物品数量-A物品数量≤M。 这两个不等式的含义是:仓库中A物品可以比B物品多,但不能超过N个;B物品可以比A物品多,但不能超过M个。 若只放入A,而不放入B,则A最多可放N次后阻塞;若只放入B,不放入A,则B最多放M次后阻塞; 每放入一次A,就多一次放入B的机会。同理,每放入一次B,就对一次放入A的机会。 Semaphore s=?,pa=?,pb=? CoBegin Procedure A; Procedure B; While (true) { While (true) { P(sa); P(sb); P(s); P(s); //A产品入库 //B产品入库 V(s); V(s); V(sb); V(sa); } CoEnd; In an electronic funds transfer system, there are hundreds of identical processes that work as follows. Each process reads an input line specifying an amount of money, the account to be credited, and the account to be debited. Then it locks both accounts and transfers the money, releasing the locks when done. With many processes running in parallel, there is a very real danger that having locked account x it will be unable to lock y because y has been locked by a process now waiting for x. Devise a scheme that avoids deadlocks. Do not release an account record until you have completed the transactions. Two Approaches to avoid Deadlock Do not start a process if its demands might lead to deadlock Do not grant an incremental resource request to a process if this allocation might lead to deadlock To avoid circular wait, number the resourc
文档评论(0)