- 1、本文档共48页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Resource-Request Algorithm for Process Pi (Cont.) 3. Pretend to allocate requested resources to Pi by modifying the state as follows: Available = Available - Requesti; Allocationi = Allocationi + Requesti; Needi = Needi – Requesti;; If safe ? the resources are allocated to Pi. If unsafe ? Pi must wait, and the old resource-allocation state is restored Operating System Concepts Example of Banker’s Algorithm 5 processes P0 through P4; 3 resource types A (10 instances), B (5 instances), and C (7 instances). Snapshot at time T0: Allocation Max Available A B C A B C A B C P0 0 1 0 7 5 3 3 3 2 P1 2 0 0 3 2 2 P2 3 0 2 9 0 2 P3 2 1 1 2 2 2 P4 0 0 2 4 3 3 Operating System Concepts Example (Cont.) The content of the matrix. Need is defined to be Max – Allocation. Need A B C P0 7 4 3 P1 1 2 2 P2 6 0 0 P3 0 1 1 P4 4 3 1 The system is in a safe state since the sequence P1, P3, P4, P2, P0 satisfies safety criteria. Operating System Concepts Example P1 Request (1,0,2) (Cont.) Check that Request ? Available (that is, (1,0,2) ? (3,3,2) ? true. Allocation Need Available A B C A B C A B C P0 0 1 0 7 4 3 2 3 0 P1 3 0 2 0 2 0 P2 3 0 1 6 0 0 P3 2 1 1 0 1 1 P4 0 0 2 4 3 1 Operating System Concepts Example P1 Request (1,0,2) (Cont.) Executing safety algorithm shows that sequence P1, P3, P4, P0, P2 satisfies safety requirement. Can request for (3,3,0) by P4 be granted? Can request for (0,2,0) by P0 be granted? Operating System Concepts Traffic Example Is it safe state with only 3 crossings occupied? Is it OK if there is another queue is coming to occupy the 4th crossing? Operating System Concepts Deadlock Detection Allow system to enter deadlock state Detection algorithm Recovery scheme Operating System Concepts Single Instance of Each Resource Type Maintain wait-for graph Nodes are processes. Pi ? Pj if Pi is waiting for Pj. Periodically invoke an algorithm that searches for a cycle in the gr
文档评论(0)