Process Synchronization | Set 2
Last Updated :
02 Jan, 2025
Process Synchronization is a technique which is used to coordinate the process that use shared Data. There are two types of Processes in an Operating Systems:-
- Independent Process - The process that does not affect or is affected by the other process while its execution then the process is called Independent Process. Example The process that does not share any shared variable, database, files, etc.
- Cooperating Process - The process that affect or is affected by the other process while execution, is called a Cooperating Process. Example The process that share file, variable, database, etc are the Cooperating Process.
We have already introduced Different Terms in Process Synchronization.
Process Synchronization is mainly used for Cooperating Process that shares the resources.Let us consider an example of //racing condition image

It is the condition where several processes tries to access the resources and modify the shared data concurrently and outcome of the process depends on the particular order of execution that leads to data inconsistency, this condition is called
Race Condition : This condition can be avoided using the technique called Synchronization or Process Synchronization, in which we allow only one process to enter and manipulates the shared data in Critical Section. //diagram of the view of CS

This setup can be defined in various regions like:
- Entry Section - It is part of the process which decide the entry of a particular process in the Critical Section, out of many other processes.
- Critical Section - It is the part in which only one process is allowed to enter and modify the shared variable.This part of the process ensures that only no other process can access the resource of shared data.
- Exit Section - This process allows the other process that are waiting in the Entry Section, to enter into the Critical Sections. It checks that a process that after a process has finished execution in Critical Section can be removed through this Exit Section.
- Remainder Section - The other parts of the Code other than Entry Section, Critical Section and Exit Section are known as Remainder Section.
Critical Section problems must satisfy these three requirements:
- Mutual Exclusion - It states that no other process is allowed to execute in the critical section if a process is executing in critical section.
- Progress - When no process is in the critical section, then any process from outside that request for execution can enter in the critical section without any delay. Only those process can enter that have requested and have finite time to enter the process.
- Bounded Waiting - An upper bound must exist on the number of times a process enters so that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted.
Process Synchronization are handled by two approaches:
- Software Approach - In Software Approach, Some specific Algorithm approach is used to maintain synchronization of the data. Like in Approach One or Approach Two, for a number of two process, a temporary variable like (turn) or boolean variable (flag) value is used to store the data. When the condition is True then the process in waiting State, known as Busy Waiting State. This does not satisfy all the Critical Section requirements. Another Software approach known as Peterson's Solution is best for Synchronization. It uses two variables in the Entry Section so as to maintain consistency, like Flag (boolean variable) and Turn variable(storing the process states). It satisfy all the three Critical Section requirements. //Image of Peterson's Algorithm

- Hardware Approach - The Hardware Approach of synchronization can be done through Lock & Unlock technique.Locking part is done in the Entry Section, so that only one process is allowed to enter into the Critical Section, after it complete its execution, the process is moved to the Exit Section, where Unlock Operation is done so that another process in the Lock Section can repeat this process of Execution.This process is designed in such a way that all the three conditions of the Critical Sections are satisfied. //Image of Lock

Using Interrupts -
These are easy to implement.When Interrupt are disabled then no other process is allowed to perform Context Switch operation that would allow only one process to enter into the Critical State. //Image of Interrupts

Test_and_Set Operation -
This allows boolean value (True/False) as a hardware Synchronization, which is atomic in nature i.e no other interrupt is allowed to access.This is mainly used in Mutual Exclusion Application. Similar type operation can be achieved through Compare and Swap function. In this process, a variable is allowed to accessed in Critical Section while its lock operation is ON.Till then, the other process is in Busy Waiting State. Hence Critical Section Requirements are achieved.
A solution to a process synchronization problem should meet three important criteria:
• Correctness: Data access synchronization and control synchronization should be performed in accordance with synchronization requirements of the problem.
• Maximum concurrency: A process should be able to operate freely except when it needs to wait for other processes to perform synchronization actions.
• No busy waits: To avoid performance degradation, synchronization should be performed through blocking rather than through busy waits
Similar Reads
Process Synchronization
On the basis of synchronization, processes are categorized as one of the following two types: Independent Process : Execution of one process does not affects the execution of other processes. Cooperative Process : Execution of one process affects the execution of other processes. Process synchroniza
4 min read
Semaphores in Process Synchronization
Semaphores are a tool used in operating systems to help manage how different processes (or programs) share resources, like memory or data, without causing conflicts. A semaphore is a special kind of synchronization data that can be used only through specific synchronization primitives. Semaphores ar
15+ min read
Monitors in Process Synchronization
Monitors are a higher-level synchronization construct that simplifies process synchronization by providing a high-level abstraction for data access and synchronization. Monitors are implemented as programming language constructs, typically in object-oriented languages, and provide mutual exclusion,
3 min read
Synchronization Examples
The Synchronization is an important concept in operating systems that ensures the smooth and coordinated execution of processes and threads. It is the task of coordinating the execution of processes in such a way that no two processes can access the same shared data and resource. It is a critical pa
6 min read
Introduction of Process Synchronization
Process Synchronization is used in a computer system to ensure that multiple processes or threads can run concurrently without interfering with each other.The main objective of process synchronization is to ensure that multiple processes access shared resources without interfering with each other an
10 min read
Dekker's algorithm in Process Synchronization
Prerequisite - Process Synchronization, Inter Process Communication To obtain such a mutual exclusion, bounded waiting, and progress there have been several algorithms implemented, one of which is Dekker's Algorithm. To understand the algorithm let's understand the solution to the critical section p
15+ min read
Critical Section in Synchronization
A critical section is a segment of a program where shared resources, such as memory, files, or ports, are accessed by multiple processes or threads. To prevent issues like data inconsistency and race conditions, synchronization techniques ensure that only one process or thread accesses the critical
8 min read
Peterson's Algorithm in Process Synchronization
Peterson's Algorithm is a classic solution to the critical section problem in process synchronization. It ensures mutual exclusion meaning only one process can access the critical section at a time and avoids race conditions. The algorithm uses two shared variables to manage the turn-taking mechanis
15+ min read
Sleeping Barber problem in Process Synchronization
The Sleeping Barber problem is a classic problem in process synchronization that is used to illustrate synchronization issues that can arise in a concurrent system. The problem is as follows: There is a barber shop with one barber and a number of chairs for waiting customers. Customers arrive at ran
9 min read
FIFO Barbershop in Process synchronization
Overview :In process synchronization, there exists a Sleeping Barber problem, as discussed here. But in the above solution, there is no guarantee that the customers are served in the order they arrive in the barbershop, i.e. there is no guarantee that the customers enter a FIFO manner(First-in First
5 min read