Process Synchronization
Ms. Mary Sanjana Joseph
Department of Computer Science(UG)
Kristu Jayanti College(Autonomous)
K.Narayanapura ,Kothannur
Bengaluru-560077
Ms.Mary Sanjana Joseph,Dept.CS(UG)
IPC
 Communications in between several processes
 Inter-process communication is used for exchanging useful information
between numerous threads in one or more processes
 Serial Excecution
 Parallel Execution
Ms.Mary Sanjana Joseph,Dept.CS(UG)
What is Race Condition?
 More than one process tries to access and modify the same shared data or resources, huge chances of
a process getting the wrong result or data.
 Every process race to say that it has correct data or resources and this is called a race condition.
 The value of the shared data depends on the execution order of the process as many processes try to
modify the data or resources at the same time. The race condition is associated with the critical
section.
Ms.Mary Sanjana Joseph,Dept.CS(UG)
IPC
 Multiple processes or threads can run concurrently without interfering with each other.
 Multiple processes access shared resources without interfering with each other
 Process can be of two types:
 Independent Process: The execution of one process does not affect the execution of other processes.
 Cooperative Process: A process that can affect or be affected by other processes executing in the system
 To prevent the inconsistency, synchronization techniques
 Semaphores
 Monitors
 critical sections are used.
Ms.Mary Sanjana Joseph,Dept.CS(UG)
Critical Section
Critical Section refers to a part of a program where a process accesses shared resources—such
as variables, data structures, or devices—that can be used by only one process at a time to avoid
inconsistencies.
Ms.Mary Sanjana Joseph,Dept.CS(UG)
Entry and Exit Sections:
Entry Section: Code before the critical section that implements the mechanism to gain access.
Exit Section: Code following the critical section to release control of the shared resource.
Ms.Mary Sanjana Joseph,Dept.CS(UG)
Solution for the Critical Section
 Mutual Exclusion
If process Pi is executing in its critical section, then no other processes can be
executing in their critical sections.
 Progress
If no process is executing in its critical section and some processes wish to enter
their critical sections, then only those processes that are not executing in their
remainder sections can participate in deciding which will enter its critical section
next, and this selection cannot be postponed indefinitely.
 Bounded Wait
There exists a bound, or limit, on the number of times 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.
Ms.Mary Sanjana Joseph,Dept.CS(UG)
Approaches to Solving the Problem:
•Software-based: Peterson’s Algorithm, Dekker’s Algorithm (for two processes).
•Hardware-based: Test-and-Set, Compare-and-Swap, Disable Interrupts.
•Semaphores and Mutexes: Higher-level constructs provided by modern OSes.
•Monitors: High-level synchronization constructs that encapsulate shared variables
operations, and the synchronization between them

Process Synchronization in Operating Sysytem.pptx

  • 1.
    Process Synchronization Ms. MarySanjana Joseph Department of Computer Science(UG) Kristu Jayanti College(Autonomous) K.Narayanapura ,Kothannur Bengaluru-560077
  • 2.
    Ms.Mary Sanjana Joseph,Dept.CS(UG) IPC Communications in between several processes  Inter-process communication is used for exchanging useful information between numerous threads in one or more processes  Serial Excecution  Parallel Execution
  • 3.
    Ms.Mary Sanjana Joseph,Dept.CS(UG) Whatis Race Condition?  More than one process tries to access and modify the same shared data or resources, huge chances of a process getting the wrong result or data.  Every process race to say that it has correct data or resources and this is called a race condition.  The value of the shared data depends on the execution order of the process as many processes try to modify the data or resources at the same time. The race condition is associated with the critical section.
  • 4.
    Ms.Mary Sanjana Joseph,Dept.CS(UG) IPC Multiple processes or threads can run concurrently without interfering with each other.  Multiple processes access shared resources without interfering with each other  Process can be of two types:  Independent Process: The execution of one process does not affect the execution of other processes.  Cooperative Process: A process that can affect or be affected by other processes executing in the system  To prevent the inconsistency, synchronization techniques  Semaphores  Monitors  critical sections are used.
  • 5.
    Ms.Mary Sanjana Joseph,Dept.CS(UG) CriticalSection Critical Section refers to a part of a program where a process accesses shared resources—such as variables, data structures, or devices—that can be used by only one process at a time to avoid inconsistencies.
  • 6.
    Ms.Mary Sanjana Joseph,Dept.CS(UG) Entryand Exit Sections: Entry Section: Code before the critical section that implements the mechanism to gain access. Exit Section: Code following the critical section to release control of the shared resource.
  • 7.
    Ms.Mary Sanjana Joseph,Dept.CS(UG) Solutionfor the Critical Section  Mutual Exclusion If process Pi is executing in its critical section, then no other processes can be executing in their critical sections.  Progress If no process is executing in its critical section and some processes wish to enter their critical sections, then only those processes that are not executing in their remainder sections can participate in deciding which will enter its critical section next, and this selection cannot be postponed indefinitely.  Bounded Wait There exists a bound, or limit, on the number of times 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.
  • 8.
    Ms.Mary Sanjana Joseph,Dept.CS(UG) Approachesto Solving the Problem: •Software-based: Peterson’s Algorithm, Dekker’s Algorithm (for two processes). •Hardware-based: Test-and-Set, Compare-and-Swap, Disable Interrupts. •Semaphores and Mutexes: Higher-level constructs provided by modern OSes. •Monitors: High-level synchronization constructs that encapsulate shared variables operations, and the synchronization between them