1 / 15

Deadlock problem and solution

Deadlock problem and solution. Speaker: Mrak Date: 2012-12-12. Outline. Introduction Deadlock Prevention Deadlock Avoidance Deadlock Detection & Recovery Conclusion Reference. Deadlock introduction. Deadlock DEF: 系統中有 processes 呈現一種互相等待對方資源釋放出來的情況 (circular waiting) 使的這些 process 皆

varana
Download Presentation

Deadlock problem and solution

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Deadlock problem and solution Speaker: Mrak Date: 2012-12-12

  2. Outline • Introduction • Deadlock Prevention • Deadlock Avoidance • Deadlock Detection & Recovery • Conclusion • Reference

  3. Deadlock introduction • Deadlock DEF: • 系統中有processes呈現一種互相等待對方資源釋放出來的情況(circular waiting) • 使的這些process皆 無法往下執行,使 的CPU utilization降 低。 Fig . 1

  4. Deadlock introduction • Mutual exclusion • Fig. 1.1 • Hold&wait • No preemption • Circular waiting • Fig. 2

  5. Deadlock prevention • Howtoprevention-破除下列四點 • Mutual exclusion • Hold&wait • No preemption • priority • Circular waiting • Unique resource ID • Ascending

  6. Deadlock prevention • Circular waiting • Example:

  7. Deadlock prevention • Circular waiting • PF :ascending (Fig. 3) • p1 < p2 <……< pn < p1 • => p1 < p1 --><--

  8. Deadlock avoidance • DEF • 當某process提出資源申請後,OS必須持行一個algorithm(Banker’s)以判斷定process提出的申請後,系統是否除與安全的狀況(不會進入死結)

  9. Deadlock avoidance-banker’s • Example P1提出Request = (1,0,2) 是否核准 Setp1:check Request(P1)<= Need(P1) Setp2:check Request(P1)<=Available Setp3:Allocation+=Request Need-=Request Available-=Request Setp4:run safety algorithm (1,0,2) <= (1,2,2) (1,0,2) <= (3,3,2) (2,0,0) + (1,0,2) =(3,0,2) (1,2,2) - (1,0,2) =(0,2,0) (3,3,2) - (1,0,2) =(2,3,0)

  10. Deadlock avoidance-Safety algorithm Step1:work=available; Finish = Step2:可找到P1滿足 (i)Finish[1]=false (ii)Need1 < work go step3 (0,2,0) < (2,3,0) Step3:Finish[1]=True 且work+=Allocation1 if Finish中還有false goto step 3 else goto step4 Step4:check Finish 皆為True 傳回safe state Sate sequence = p1 , p3 , p4 , p0 , p2

  11. Deadlock Detection & Recovery • Detection DEF: • 每X秒偵測deadlock是否存在,若存在必須恢復正常 Step1: work=Available Finish[i] = if Allocation ≠ 0 set false (0,0,0) if Allocation = 0 set true Step2: 如果找到Pi滿足 (i) Finish[i] = False (ii) Requesti <=work then goto step 3 else goto step 4 Step3:set Finish[i] = true work += Allocationi then goto step 2 Step4: check Finish Array if all is true , No Deadlock

  12. Deadlock Detection & Recovery • Recovery DEF: • Case 1 : kill all process in Deadlock • Case 2 : kill one process each time,then Detection

  13. Conclusion • Deadlock Prevention與Deadlock Avoidance的resources utilization 保證系統不會有deadlock • Deadlock Detection & Recovery resources utilization 但系統可能進入deadlock

  14. reference • https://docs.google.com/a/mail1.ncnu.edu.tw/viewer?a=v&q=cache:t-E9tdn2zpIJ:sjchen.im.nuu.edu.tw/OS/97Spring/Ch_6.pdf+&hl=zh-TW&pid=bl&srcid=ADGEESixtvIiw8J9u-2S89vjdn-umwFUUphLv6k6Z7vT3dflJV1GxvKKTBpqF6C7V4S-C1qV_Hb5WDNVAaArSi9z4Ne4pmoESx5siFAv_edb7WFDgXGX-s4njkpON-u1zcQDqIFWy-jn&sig=AHIEtbTNMCCDDCa0kjMpauyT9mndv7ZxWA[聯合大學] • http://kramli.staff.ui.ac.id/files/2011/02/Chapter-06-OS-Concurrency-Deadlock-and-Starvation.pdf[Manatee Community College]

  15. Q&A

More Related