Process Synchronization & Deadlock

« Previous
Next »

Process Synchronization

• In a computer, multiple processes are executing at the same time. The processes that share the resources have to communicate with one another to prevent a situation where one process disrupts another process.
• When two or more processes execute at the same time, independent of each other, they are called concurrent processes.
• A situation where multiple processes access and manipulate the same data concurrently, in which the final result depends on the order of process execution, is called a race condition. To handle such situations, synchronization and coordination of the processes is required.


• In a multiprogramming environment, multiple processes may try to access a resource. A deadlock is a situation when a process waits endlessly for a resource and the requested resource is being used by another process that is waiting for some other resource.
• A deadlock arises when the four necessary conditions hold true simultaneously in a system.

Deadlock conditions are as follows :

Deadlock conditions

» Mutual Exclusion — Only one process at a time can use the resource. Any other process requesting the resource has to wait until the resource is released.
» No Pre-emption — A process releases the resource by itself. A process cannot remove the resource from another process.
» Hold and Wait — A process holds a resource while requesting another resource, which may be currently held by another process.
» Circular Wait — In this situation, a process P1 waits for a resource held by another process P2, and the process P2 waits for a resource held by process P1.

Deadlock handling can be done by deadlock avoidance and deadlock prevention

» Deadlock Prevention is a set of method that ensures that at least one of the above four necessary conditions required for deadlock, does not hold true.
» Deadlock Avoidance requires that the operating system be given information in advance regarding the resources a process will request and use. This information is used by the operating system to schedule the allocation of resources so that no process waits for a resource.

« Previous
Next »