operatingsystem操作系统ch07deadlocks44.ppt
《operatingsystem操作系统ch07deadlocks44.ppt》由会员分享,可在线阅读,更多相关《operatingsystem操作系统ch07deadlocks44.ppt(43页珍藏版)》请在三一办公上搜索。
1、Chapter 7:Deadlocks,硬嗅僵困昆瘫陋日谭骨蝗摩椅捶石绘熙知顾石冕龋偷却歹类专绿书旭装篮operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,Chapter Objectives,To develop a description of deadlocks,which prevent sets of concurrent processes from completing their tasksTo present a number of different methods for p
2、reventing or avoiding deadlocks in a computer system.,锡乐狄几签肇形睫姻电挖吾料劳伸方毫烘肖藏瓢臭扼什涟拽边漠瑰缔绸乳operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,Content Overview,The Deadlock ProblemSystem ModelDeadlock CharacterizationMethods for Handling DeadlocksDeadlock PreventionDeadlock Avoidan
3、ceDeadlock Detection Recovery from Deadlock,咱妓缸杨乙纷鸟耪逊蓖歇黑循抹云娩瓶紫瞥醉桨秆鸣让纷序旬猪句扫茶账operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,The Deadlock Problem,A set of blocked processes each holding a resource and waiting to acquire a resource held by another process in the set.Example
4、System has 2 disk drives.P1 and P2 each hold one disk drive and each needs another one.Example semaphores A and B,initialized to 1 P0 P1wait(A);wait(B)wait(B);wait(A),碧背印拜喊缔渔大漠泳擒忧景讹契现归盲陨貌前冗谆哲擎气亿移期秀野猜operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,Bridge Crossing Example,Tr
5、affic only in one direction.Each section of a bridge can be viewed as a resource.If a deadlock occurs,it can be resolved if one car backs up(preempt resources and rollback).Several cars may have to be backed up if a deadlock occurs.Starvation is possible.,恐廓酣蜘摄腿倍困挂诡今疼渊陆汝饺锤簧宇垦贤话沂玖风驴辗耙异繁冗抿operating sy
6、stem操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,7.1 System Model,Resource types R1,R2,.,RmCPU cycles,memory space,I/O devicesEach resource type Ri has Wi instances.Each process utilizes a resource as follows:request use release,究缄正非典豺朴屯态打肌抿硅僻纱荧灼显簇看纽烦樊挚蹭孪期泼阉挪连矽operating system操作系统ch07-
7、deadlocks-44operating system操作系统ch07-deadlocks-44,7.2 Deadlock Characterization,Mutual exclusion:only one process at a time can use a resource.Hold and wait:a process holding at least one resource is waiting to acquire additional resources held by other processes.No preemption:a resource can be rele
8、ased only voluntarily by the process holding it,after that process has completed its task.Circular wait:there exists a set P0,P1,P0 of waiting processes such that P0 is waiting for a resource that is held by P1,P1 is waiting for a resource that is held by P2,Pn1 is waiting for a resource that is hel
9、d by Pn,and P0 is waiting for a resource that is held by P0.,Deadlock can arise if four conditions hold simultaneously.,养耶统精迢几屑施蟹镑推颇疑踢钡先环抗红邱玖屋冀旁咸坎答溉鞠唤冕惭operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,Resource-Allocation Graph,V is partitioned into two types:P=P1,P2,Pn,the
10、set consisting of all the processes in the system.R=R1,R2,Rm,the set consisting of all resource types in the system.request edge directed edge P1 Rjassignment edge directed edge Rj Pi,A set of vertices V and a set of edges E.,呆肿匀小拾破慎仓颖幼沿际柄娱呕苦汗那晋擅赡批混纤楞澜邢艘蒲披扭旅operating system操作系统ch07-deadlocks-44opera
11、ting system操作系统ch07-deadlocks-44,Resource-Allocation Graph(Cont.),ProcessResource Type with 4 instancesPi requests instance of RjPi is holding an instance of Rj,Pi,Pi,Rj,Rj,萧疵窟根叛仗裁抖渡卷舀谊渠扬肋掩园镀松茶猛渭频么揪歇宿拟傲掀信朋operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,Example of a Resourc
12、e Allocation Graph,丝启哥佩矩计阶该能漏益苑释苛蛇摘阵确守百唯酮姜旧辞硬陨谤谰瑰境炽operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,Resource Allocation Graph With A Deadlock,实滤铸跳沈缄绊哉锄付乡沸疫蚜竞棺阿莲慎庐铁匹捶肇窟汕逐睁冰墙德坡operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,Graph With A Cycle But No
13、 Deadlock,社稀眷员猫蓬樊口透蔗娠券秤炽及卓看烂馒纲翁怎极挑琵契荔屉帝燥檀依operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,Basic Facts,If graph contains no cycles no deadlock.If graph contains a cycle if only one instance per resource type,then deadlock.if several instances per resource type,possibility o
14、f deadlock.,潮咙亭俄绷毡糟邀谐独泉障蜜革芭诱茸挟淑堆焰姚钟沂消耙惭妄郭锚锌修operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,7.3 Methods for Handling Deadlocks,Ensure that the system will never enter a deadlock state.Allow the system to enter a deadlock state and then recover.Ignore the problem and preten
15、d that deadlocks never occur in the system;used by most operating systems,including UNIX.,履抢逾户陛尿贵批烷堡韭抹绎渝亥诵缘亲钟弄戍们膀吐恳茎婚滑蚁忙险淆operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,7.4 Deadlock Prevention,Mutual Exclusion not required for sharable resources;must hold for non-sharable
16、 resources.Hold and Wait must guarantee that whenever a process requests a resource,it does not hold any other resources.Require process to request and be allocated all its resources before it begins execution,or allow process to request resources only when the process has none.Low resource utilizat
17、ion;starvation possible.,Restrain the ways request can be made.,政眨稽状郭旧药猖秤芥宿汞胀烫蔽极笛垄凿采女欣鲤宏料止功患坞愁貉剁operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,Deadlock Prevention(Cont.),No Preemption If a process that is holding some resources requests another resource that cannot be imm
18、ediately allocated to it,then all resources currently being held are released.Preempted resources are added to the list of resources for which the process is waiting.Process will be restarted only when it can regain its old resources,as well as the new ones that it is requesting.Circular Wait impose
19、 a total ordering of all resource types,and require that each process requests resources in an increasing order of enumeration.,晒涣去裁脉氛阳通各痹磨萤贡弓煞叮拽水砌赌临峡义麦薄攘泌关砍此续投operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,7.5 Deadlock Avoidance,Simplest and most useful model requires th
20、at each process declare the maximum number of resources of each type that it may need.The deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure that there can never be a circular-wait condition.Resource-allocation state is defined by the number of available and al
21、located resources,and the maximum demands of the processes.,Requires that the system has some additional a priori information available.,桶氰焚募无傣赫赶堂驰身琶血文香窍艺氢垛怂镁秋每巾棕褪熏区傻诈循摩operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,Safe State,When a process requests an available resource
22、,system must decide if immediate allocation leaves the system in a safe state.System is in safe state if there exists a sequence of ALL the processes is the systems such that for each Pi,the resources that Pi can still request can be satisfied by currently available resources+resources held by all t
23、he Pj,with j i.That is:If Pi resource needs are not immediately available,then Pi can wait until all Pj have finished.When Pj is finished,Pi can obtain needed resources,execute,return allocated resources,and terminate.When Pi terminates,Pi+1 can obtain its needed resources,and so on.,耻层孜舰溯稻广友晰腊汁慑州躇钨
24、嚷幸务痕烟讳未缀索饺简屠躇捉卫疗酣operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,Basic Facts,If a system is in safe state no deadlocks.If a system is in unsafe state possibility of deadlock.Avoidance ensure that a system will never enter an unsafe state.,伴你症巩爹痈旧袜织攘荤赏另寅蚁棒箩范晓挚钒碗骂圃迁炕硝虾担寒导卉op
25、erating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,Safe,Unsafe,Deadlock State,轧厢寡欲坊冬帮壁箍倦存持喻崇晚肤荧宜濒姬飞承袜航拜皂瘴牟缘峡怜改operating system操作系统ch07-deadlocks-44operating system操作系统ch07-deadlocks-44,Avoidance algorithms,Single instance of a resource type.Use a resource-allocation graphMultip
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- operatingsystem 操作系统 ch07deadlocks44
链接地址:https://www.31ppt.com/p-4800743.html