Posts

Showing posts from August, 2011

Understanding and Terminating the Enemy- Deadlocks

Image
Concurrent programming is hard. And its even hard when you do it badly. Deadlocks are one of the classical enemies you must try to avoid when writing a concurrent program. Because if you face any deadlocks in your program its really hard to find and fix them. In this post i’m trying to explain what deadlocks are and I’ll explain how to debug a program to find and fix deadlocks. There are different definitions for deadlock personally i prefer the following definition since i feel its the perfect one. “A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause (including itself)” [1] There are four necessary conditions to be there in a program if its leading to a deadlock. Which means if a program ended up in a deadlock state it that program will satisfy following four conditions. Mutual exclusion : The resources that must involve in the problem must only have mutually exclusive access. Which means o