Tuesday, February 2, 2010

What is a dead lock?

When two computer programs sharing the same resource prevent each other from accessing the resource results in a deadlock. This deadlock results in finishing the program.
Example:
P1 requests R1 and receives it.
P2 requests R2 and receives it.
P1 requests resource R2 and is queued up, pending the release of R2.
P2 requests resource R1 and is queued up, pending the release of R1
Here, P and R is Program and Resource respectively.

What is a live lock?

A live lock is similar to a deadlock that the states of the processes involved in the live lock constantly change with regard to one another, none progressing. This happens when where a request for an exclusive lock is repeatedly denied because a series of overlapping shared locks keeps interfering.

What guidelines should you follow to help minimize deadlocks?

Prevent deadlocks:
Mutual exclusion:
 This means that no process will have exclusive rights on a resource. Processes should request all resources they will need before starting. This is to avoid “hold” and “Wait” situation.
No preemption: If a process that is holding a resource requests for more resources that cannot be immediately allocated to it, then all resources currently being held are released
Circular wait: imposes an ordering on the resources. The requests for ordering resources in an increasing order

0 Comments: