6.1.1 Reusable resources( 1/3) ● Resources category Reusable resources(可重用资源) 特点: Used by only one process at a time and not depleted(耗尽) by that use 1F8: Processes obtain resources that they later release for reuse by other processes 举例: Processors,I/ o channels, main and secondary memory, devices, and data structures such as files, databases, and semaphores Deadlock occurs if each process holds one resource and requests the other
6.1.1 Reusable Resources(1/3) • Resources category • Reusable Resources(可重用资源) • 特点:Used by only one process at a time and not depleted(耗尽) by that use • 使用:Processes obtain resources that they later release for reuse by other processes • 举例:Processors, I/O channels, main and secondary memory, devices, and data structures such as files, databases, and semaphores • Deadlock occurs if each process holds one resource and requests the other 12
6.1.1 Reusable resources( 2/ 3) Interleaves the execution: p0 p1 g0 ql p2 92 Process p Process Q Step Action Step Action Request d) Request t) Lock①D) Lock (T pppppp Request (T) Request①D Lock ( T Lock D) Perform function Perform function 456 Unlock①D) Unlock T Unlock T) qqq 456 Unlock①D) Figure 6.4 Example of Two Processes Competing for Reusable Resources
6.1.1 Reusable Resources(2/3) • Interleaves the execution: p0 p1 q0 q1 p2 q2 13
6.1.1 Reusable resources( 3/ 3) How could deadlock occur when 200k bytes of memory is available for allocation by he system Process 1 needs 140k in 80k, 60k blocks Process 2 needs 150k in 70k,80k blocks Answer Process 1 Process 2 Request 80K bytes Request 70K bytes Request 60K bytes Request 80K bytes
6.1.1 Reusable Resources(3/3) • How could deadlock occur when • 200K bytes of memory is available for allocation by the system • Process 1 needs 140k in 80k,60k blocks • Process 2 needs 150k in 70k,80k blocks • Answer: 14
6.1 Principles of Deadlock ·6.1.0 Intro 6.1.1 Reusable resources 6.1.2 Consumable resources 6. 1.3 Resource Allocation Graphs 6.1. 4 The Conditions for deadlock 15
6.1 Principles of Deadlock • 6.1.0 Intro • 6.1.1 Reusable Resources • 6.1.2 Consumable Resources • 6.1.3 Resource Allocation Graphs • 6.1.4 The Conditions for Deadlock 15
6.1.2 Consumable resources (1/2 Resources catego Consumable resources(可消费资源) ·特点: Created( produced) and destroyed (consumed)by a process 举例: Interrupts, signals, messages,and information in i/o buffers Deadlock may occur · design error May take a rare combination of events to cause deadlock(很少的事件组合也可能导致死锁)
6.1.2 Consumable Resources(1/2) • Resources category • Consumable Resources(可消费资源) • 特点:Created (produced) and destroyed (consumed) by a process • 举例:Interrupts, signals, messages, and information in I/O buffers • Deadlock may occur • design error • May take a rare combination of events to cause deadlock(很少的事件组合也可能导致死锁) 16