Synchronization
Dr Nishant Jain, MITS-DU Gwalior
Dr Nishant Jain, MITS-DU Gwalior
,✓ Process Synchronization means coordinating the execution of processes such
that no two processes access the same shared resources and data.
✓ It is required in a multi-process system where multiple processes run together,
and more than one process tries to gain access to the same shared resource or
data at the same time.
For example: A process P1 tries changing data in a particular memory location. At
the same time another process P2 tries reading data from the same memory
location. Thus, there is a high probability that the data being read by the second
process is incorrect.
Dr Nishant Jain, MITS-DU Gwalior
, Sections of a Program
1. Entry Section: This decides the entry of any
process.
2. Critical Section: This allows a process to enter
and modify the shared variable.
3. Exit Section: This allows the process waiting in
the Entry Section, to enter the Critical Sections and
makes sure that the process is removed through
this section once it’s done executing.
4. Remainder Section: Parts of the Code, not
present in the above three sections are collectively
called Remainder Section.
Dr Nishant Jain, MITS-DU Gwalior
, Critical Section Problem
▪ A Critical Section is a code segment that accesses shared variables and must
be executed as an atomic action.
▪ It means that in a group of cooperating processes, at a given point of time,
only one process must be executing its critical section.
▪ If any other process also wants to execute its critical section, it must wait
until the first one finishes.
▪ The entry to the critical section is mainly handled by wait() function while
the exit from the critical section is controlled by the signal() function.
Dr Nishant Jain, MITS-DU Gwalior