To synchronize processes, we put extra code before Critical Section is called entry and after Critical Section(CS) is called exit. This synchronization mechanism avoids critical section problems or race conditions.
Example: Process Synchronization as a solution of critical section problem
Note: Non- Critical Section (NCS): The portion of the program text, where the independent code of the processes will be placed.
This synchronization procedure using entry and exit code before and after Critical Section (CS) ensures that if one process is inside its Critical Section then no other processes are allowed to go inside its own Critical Section or at a time only one process is allowed to go inside the Critical Section.
So, to avoid race condition, only one process should be allowed in the Critical Section.
Synchronization mechanism:
Contributed by