/    /  OS – Intro to Process Synchronization

Introduction to Process Synchronization

 

Process Synchronization refers to the task of coordinating the execution of processes in a way that no two processes can have access to the same shared data and resources. It is necessary for multi-process systems, as there are multiple processes running simultaneously.

 

Based on synchronization, the processes can be categorized into two types:

    1. Independent process: In this, the execution of one process doesn’t affect the execution of other processes.

 

  • Cooperative process: In this, the execution of one process affects the execution of other processes.

 

The problem of process synchronization occurs mainly in a cooperative process as the resources are shared.

How does process synchronization work?

Let’s assume a process P1 is changing the data in a memory location, and process P2 is trying to read the data from the same memory location, there is a probability that the data read will be faulty. 

Here’s where process synchronization comes into play.

Race Condition:

When multiple processes are executing the same code or accessing the same memory location, there are chances that the data will be wrong. All the processes will compete to prove their output is right, this condition is known as Race Condition. It happens when the result of multiple thread execution in the critical section differs according to the order in which the threads execute.

Reference

Process Synchronization of Operating system.