This can be simply defined as a situation where there are two or more (a set of) processes or threads are mutually blocking each other (Sams 2008, p.114). Consider an example consist of two threads. Thread 1 is waiting for thread 2 to release its lock to perform an action. This event will understand by looking at the following diagram.
Neither thread will not be able to release any locks. So the execution of the action will be jammed in this circumstance (Sams 2008, p.319). This state can consider as a deadlock kind of a situation.
Mutually blocking for an event can be:
· Blocking for access to a certain section
· Blocking for a resource
· If two programs are sharing the same resource at once, results both programs not function well.
· Mutual exclusion: Resources can not be shared in this phase
· Acquired piece meal: Not taking the resources at once that are needed to complete a certain task
· No preemption: Resources can not be taken away from process while it is functioning
· Resources are not given up (Circular wait): a certain process does not give up its resources until it has satisfied all its outstanding requests for resources. To get more clearer idea of this, see above diagram (Figure D1.1) (Matthews 2001, p.321)
· Ignore the problem altogether
· Detection and recovery
· Avoidance by careful resource allocation
· Prevention by structurally negating one of the four necessary conditions (How to overcome from Deadlocks 2004)
A deadlock can be avoided if more information on executing a process is described. System will see whether it will lead to deadlock situation when the request of a user is fulfilled. In another words system is looking for safe state to fulfill the request of the user. System is calculating this by considering the number and type of all resources in existence, available, and requested (Anon 2006, p.105).
Utilizing the resources in such a way that will not lead to deadlock situation is described in this section. The following steps will lead to help from causing deadlocks.
· Eliminate mutual exclusion clause means all process can access to any resource & proves unfeasible for resources that cannot be spooled, and even with spooled resources deadlock could still occur.
· Requesting resources before starting a task. So there will be no waiting time for resources in between several processes. That will assist to get rid off from deadlock situation.
· Removing no preemption condition may be hard to ignore because each process should have at least few resources to perform a given task.
Deadlock detection and clean up is used by employing an algorithm that tracks the circular waiting and kills one or more of the processes. Deadlock can be removed easily with that feat. It should be noted that this problem is undecidable in general, because the halting problem can be rephrased as a deadlock scenario (Bantz 2006, p. 79).
Ubuntu 8.10 is well equipped with deadlock detection methods & avoids causing deadlocks as we mentioned above.