deadlock prevention: practical examplesyajin.org/os2019fall/ppt/08_deadlock_1.pdf · deadlock...

9
Operating Systems (Fall/Winter 2019) Deadlock Prevention: Practical Examples Yajin Zhou (http://yajin.org ) Zhejiang University Acknowledgement: some pages are based on the slides from Zhi Wang(fsu).

Upload: others

Post on 01-Oct-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Deadlock Prevention: Practical Examplesyajin.org/os2019fall/ppt/08_deadlock_1.pdf · Deadlock Prevention: Practical Examples Created Date: 11/12/2019 12:34:54 AM

Operating Systems (Fall/Winter 2019)

Deadlock Prevention: Practical Examples

Yajin Zhou (http://yajin.org)

Zhejiang University

Acknowledgement: some pages are based on the slides from Zhi Wang(fsu).

Page 2: Deadlock Prevention: Practical Examplesyajin.org/os2019fall/ppt/08_deadlock_1.pdf · Deadlock Prevention: Practical Examples Created Date: 11/12/2019 12:34:54 AM

Conditions for Deadlock

• Mutual exclusion

• Hold and wait

• No preemption

• Circular wait

Page 3: Deadlock Prevention: Practical Examplesyajin.org/os2019fall/ppt/08_deadlock_1.pdf · Deadlock Prevention: Practical Examples Created Date: 11/12/2019 12:34:54 AM

Circular Wait

• Most practical one, provide a total ordering to obtain the lock

• In complex systems, partial ordering

https://github.com/torvalds/linux/blob/master/mm/filemap.c

Any tool to check this?

Page 4: Deadlock Prevention: Practical Examplesyajin.org/os2019fall/ppt/08_deadlock_1.pdf · Deadlock Prevention: Practical Examples Created Date: 11/12/2019 12:34:54 AM

Circular Wait

• Dynamic lock

Page 5: Deadlock Prevention: Practical Examplesyajin.org/os2019fall/ppt/08_deadlock_1.pdf · Deadlock Prevention: Practical Examples Created Date: 11/12/2019 12:34:54 AM

Circular Wait

Page 6: Deadlock Prevention: Practical Examplesyajin.org/os2019fall/ppt/08_deadlock_1.pdf · Deadlock Prevention: Practical Examples Created Date: 11/12/2019 12:34:54 AM

Hold and wait

Page 7: Deadlock Prevention: Practical Examplesyajin.org/os2019fall/ppt/08_deadlock_1.pdf · Deadlock Prevention: Practical Examples Created Date: 11/12/2019 12:34:54 AM

No Preemption

• actually does not add preemption, but giving up the lock

Page 8: Deadlock Prevention: Practical Examplesyajin.org/os2019fall/ppt/08_deadlock_1.pdf · Deadlock Prevention: Practical Examples Created Date: 11/12/2019 12:34:54 AM

Mutual Exclusion

• Lock-free: use powerful hardware instruction

Page 9: Deadlock Prevention: Practical Examplesyajin.org/os2019fall/ppt/08_deadlock_1.pdf · Deadlock Prevention: Practical Examples Created Date: 11/12/2019 12:34:54 AM

Mutual Exclusion