SlideShare a Scribd company logo
Process Synchronization
Name: Saad Ahmed
Roll No: 17bscs-75
Monday, March
11, 2019
1
Objectives:
 What is Process Synchronization
 Types of Process
 Critical Section
 Solution of critical Section
 Example of Synchronization in java
Monday, March
11, 2019
2
Process Synchronization
 Process synchronization means sharing system resources by
processes in such a way that, Concurrent access to shared
data is handled thereby minimizing the chance of inconsistent
data.
 Maintaining data consistency demands mechanisms to
ensure synchronized execution of cooperating process.
 At times when more then one thread try to access a shared
resources, we need to ensure that resources will be used by
only one thread at a time. The process by which this is
achieved is called synchronization.
Monday, March
11, 2019
3
Monday, March
11, 2019
4
Process
Independent
Process
Cooperative
Process
Execution of one
process does not
effect the execution
of other
Execution of one
process effect the
execution of other
process
Critical Section
 Critical Section is just a code segment which contain some variables
and data
 Consider a system consists of ‘n’ processes.
 Each process has segment of code called a critical section, in which the
process may be changing common variables, updating a table , writing a
file. When one process is executing in its critical section , no other
process can allowed to execute in its critical section .
Monday, March
11, 2019
5
Problem of Critical section
P1 P2
int x= shared; int y=shared;
X++; y--;
Sleep(1); Sleep(1);
Shared=x; shared=y;
Monday, March
11, 2019
6
Solution of Critical Section
 Mutual Exclusion :
Mutual exclusion is assured as only one process can access the critical section at a
time.
 Progress:
Progress is also assured , as a process outside the critical section does not block
other process from entering the critical section.
 Bounded Waiting:
Bounded waiting is preserved as every process get a fair chance
Monday, March
11, 2019
7
Java Program of Non Synchronization
Monday, March
11, 2019
8
class First{
public void display(String msg, String ff){
System.out.println(msg);
try{
Thread.sleep(1000);
}
catch (InterruptedException nbn){
nbn.printStackTrace();
}
System.out.println(ff);
}
}
class Second extends Thread{
String msg,msg2;
First ff1;
Second(First ff2, String str, String str2){
ff1= ff2;
msg= str;
msg2= str2;
start();
}
public void run(){
ff1.display(msg,msg2); }}
public class Main {
public static void main(String[] args) {
First fnew = new First();
Second ss1= new Second(fnew,"Wellcome","in BSCS");
Second ss2= new Second(fnew,"Wellcome ","in Math");
}
}
Output:
Monday, March
11, 2019
9
Java program of Synchronize
Monday, March
11, 2019
10
class First{
public void display(String msg,String msg2){
System.out.println(msg);
try{
Thread.sleep(1000);}
catch (InterruptedException nbn)
{ nbn.printStackTrace(); }
System.out.println(msg2);
}}
class Second extends Thread{
String msg,msg2;
First ff1;
Second(First ff2, String str2,String str3){
ff1= ff2;
msg= str2;
msg2= str3;
start(); }
public void run(){
synchronized (ff1)
{
ff1.display(msg,msg2);
} }}
public class Main {
public static void main(String[] args) {
First fnew = new First();
Second ss1= new Second(fnew,"Wellcome","In Bscs");
Second ss2= new Second(fnew,"Wellcome ","In Math"); }}
Output:
Monday, March
11, 2019
11

More Related Content

What's hot (20)

PDF
Operating Systems - Process Synchronization and Deadlocks
Mukesh Chinta
 
PPT
Ch7 Process Synchronization galvin
Shubham Singh
 
PPTX
Concurrency: Mutual Exclusion and Synchronization
Anas Ebrahim
 
PPTX
Mutual Exclusion using Peterson's Algorithm
Souvik Roy
 
PPTX
Critical section problem in operating system.
MOHIT DADU
 
PPTX
Process synchronization in operating system
Ruaha Catholic university
 
PPT
Os module 2 c
Gichelle Amon
 
PPTX
Process synchronization in Operating Systems
Ritu Ranjan Shrivastwa
 
PPTX
Operating systems question bank
anuradha raheja
 
PPT
Process Synchronization
Sonali Chauhan
 
DOCX
Critical section operating system
Muhammad Baqar Kazmi
 
PPTX
Operating system critical section
Harshana Madusanka Jayamaha
 
PPT
Process Synchronization
vinay arora
 
PPT
Process Synchronization And Deadlocks
tech2click
 
PDF
6 Synchronisation
Dr. Loganathan R
 
DOCX
Operating System Process Synchronization
Haziq Naeem
 
PPT
OS Process Synchronization, semaphore and Monitors
sgpraju
 
PPT
Peterson Critical Section Problem Solution
Bipul Chandra Kar
 
PPTX
Process synchronization
Ali Ahmad
 
Operating Systems - Process Synchronization and Deadlocks
Mukesh Chinta
 
Ch7 Process Synchronization galvin
Shubham Singh
 
Concurrency: Mutual Exclusion and Synchronization
Anas Ebrahim
 
Mutual Exclusion using Peterson's Algorithm
Souvik Roy
 
Critical section problem in operating system.
MOHIT DADU
 
Process synchronization in operating system
Ruaha Catholic university
 
Os module 2 c
Gichelle Amon
 
Process synchronization in Operating Systems
Ritu Ranjan Shrivastwa
 
Operating systems question bank
anuradha raheja
 
Process Synchronization
Sonali Chauhan
 
Critical section operating system
Muhammad Baqar Kazmi
 
Operating system critical section
Harshana Madusanka Jayamaha
 
Process Synchronization
vinay arora
 
Process Synchronization And Deadlocks
tech2click
 
6 Synchronisation
Dr. Loganathan R
 
Operating System Process Synchronization
Haziq Naeem
 
OS Process Synchronization, semaphore and Monitors
sgpraju
 
Peterson Critical Section Problem Solution
Bipul Chandra Kar
 
Process synchronization
Ali Ahmad
 

Similar to Process synchronization (20)

PPTX
process synchronization topic of operating system
jarmanjeetsinghpb786
 
PDF
CSI-503 - 4. Process synchronization
ghayour abbas
 
PDF
OperatingSystem-Unit2_Process Management
SonaShaiju1
 
PPTX
Chapter 5 - Operating Synchronization.pptx
MujtabaVlogs
 
PPT
Ch7
Bilal Arshad
 
PPTX
Synchronization in os.pptx
AbdullahBhatti53
 
PPTX
Lecture 9 - Process Synchronization.pptx
EhteshamulIslam1
 
PDF
Lecture 5- Process Synchonization_revised.pdf
Amanuelmergia
 
PPTX
Operating system 23 process synchronization
Vaibhav Khanna
 
PPTX
operating system notes of unit 3 explanation
yashkushwah671
 
PPTX
Process Synchronization in Operating Sysytem.pptx
marysj3
 
PDF
CH05.pdf
ImranKhan880955
 
PPTX
MODULE 3 process synchronizationnnn.pptx
senthilkumar969017
 
PDF
OS Process synchronization Unit3 synchronization
subhamchy2005
 
PPTX
synchronization in operating system structure
gaurav77712
 
PPTX
Critical Section in Operating System
Chandnigupta80
 
PPTX
Critical Section Problem - Ramakrishna Reddy Bijjam
Ramakrishna Reddy Bijjam
 
PPTX
Synchronization
S.M.Mustofa Kauser
 
PPTX
operating system notes about deadlock 3.pptx
panditestmail
 
PDF
Slides for OS 06-Sync.pdf
GeekyHassan
 
process synchronization topic of operating system
jarmanjeetsinghpb786
 
CSI-503 - 4. Process synchronization
ghayour abbas
 
OperatingSystem-Unit2_Process Management
SonaShaiju1
 
Chapter 5 - Operating Synchronization.pptx
MujtabaVlogs
 
Synchronization in os.pptx
AbdullahBhatti53
 
Lecture 9 - Process Synchronization.pptx
EhteshamulIslam1
 
Lecture 5- Process Synchonization_revised.pdf
Amanuelmergia
 
Operating system 23 process synchronization
Vaibhav Khanna
 
operating system notes of unit 3 explanation
yashkushwah671
 
Process Synchronization in Operating Sysytem.pptx
marysj3
 
CH05.pdf
ImranKhan880955
 
MODULE 3 process synchronizationnnn.pptx
senthilkumar969017
 
OS Process synchronization Unit3 synchronization
subhamchy2005
 
synchronization in operating system structure
gaurav77712
 
Critical Section in Operating System
Chandnigupta80
 
Critical Section Problem - Ramakrishna Reddy Bijjam
Ramakrishna Reddy Bijjam
 
Synchronization
S.M.Mustofa Kauser
 
operating system notes about deadlock 3.pptx
panditestmail
 
Slides for OS 06-Sync.pdf
GeekyHassan
 
Ad

Recently uploaded (20)

PPTX
Capitol Doctoral Presentation -July 2025.pptx
CapitolTechU
 
DOCX
A summary of SPRING SILKWORMS by Mao Dun.docx
maryjosie1
 
PDF
CHILD RIGHTS AND PROTECTION QUESTION BANK
Dr Raja Mohammed T
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
How to Configure Lost Reasons in Odoo 18 CRM
Celine George
 
PDF
'' IMPORTANCE OF EXCLUSIVE BREAST FEEDING ''
SHAHEEN SHAIKH
 
PPTX
How to Create Rental Orders in Odoo 18 Rental
Celine George
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PPTX
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPTX
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
PPTX
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Capitol Doctoral Presentation -July 2025.pptx
CapitolTechU
 
A summary of SPRING SILKWORMS by Mao Dun.docx
maryjosie1
 
CHILD RIGHTS AND PROTECTION QUESTION BANK
Dr Raja Mohammed T
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
How to Configure Lost Reasons in Odoo 18 CRM
Celine George
 
'' IMPORTANCE OF EXCLUSIVE BREAST FEEDING ''
SHAHEEN SHAIKH
 
How to Create Rental Orders in Odoo 18 Rental
Celine George
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Ad

Process synchronization

  • 1. Process Synchronization Name: Saad Ahmed Roll No: 17bscs-75 Monday, March 11, 2019 1
  • 2. Objectives:  What is Process Synchronization  Types of Process  Critical Section  Solution of critical Section  Example of Synchronization in java Monday, March 11, 2019 2
  • 3. Process Synchronization  Process synchronization means sharing system resources by processes in such a way that, Concurrent access to shared data is handled thereby minimizing the chance of inconsistent data.  Maintaining data consistency demands mechanisms to ensure synchronized execution of cooperating process.  At times when more then one thread try to access a shared resources, we need to ensure that resources will be used by only one thread at a time. The process by which this is achieved is called synchronization. Monday, March 11, 2019 3
  • 4. Monday, March 11, 2019 4 Process Independent Process Cooperative Process Execution of one process does not effect the execution of other Execution of one process effect the execution of other process
  • 5. Critical Section  Critical Section is just a code segment which contain some variables and data  Consider a system consists of ‘n’ processes.  Each process has segment of code called a critical section, in which the process may be changing common variables, updating a table , writing a file. When one process is executing in its critical section , no other process can allowed to execute in its critical section . Monday, March 11, 2019 5
  • 6. Problem of Critical section P1 P2 int x= shared; int y=shared; X++; y--; Sleep(1); Sleep(1); Shared=x; shared=y; Monday, March 11, 2019 6
  • 7. Solution of Critical Section  Mutual Exclusion : Mutual exclusion is assured as only one process can access the critical section at a time.  Progress: Progress is also assured , as a process outside the critical section does not block other process from entering the critical section.  Bounded Waiting: Bounded waiting is preserved as every process get a fair chance Monday, March 11, 2019 7
  • 8. Java Program of Non Synchronization Monday, March 11, 2019 8 class First{ public void display(String msg, String ff){ System.out.println(msg); try{ Thread.sleep(1000); } catch (InterruptedException nbn){ nbn.printStackTrace(); } System.out.println(ff); } } class Second extends Thread{ String msg,msg2; First ff1; Second(First ff2, String str, String str2){ ff1= ff2; msg= str; msg2= str2; start(); } public void run(){ ff1.display(msg,msg2); }} public class Main { public static void main(String[] args) { First fnew = new First(); Second ss1= new Second(fnew,"Wellcome","in BSCS"); Second ss2= new Second(fnew,"Wellcome ","in Math"); } }
  • 10. Java program of Synchronize Monday, March 11, 2019 10 class First{ public void display(String msg,String msg2){ System.out.println(msg); try{ Thread.sleep(1000);} catch (InterruptedException nbn) { nbn.printStackTrace(); } System.out.println(msg2); }} class Second extends Thread{ String msg,msg2; First ff1; Second(First ff2, String str2,String str3){ ff1= ff2; msg= str2; msg2= str3; start(); } public void run(){ synchronized (ff1) { ff1.display(msg,msg2); } }} public class Main { public static void main(String[] args) { First fnew = new First(); Second ss1= new Second(fnew,"Wellcome","In Bscs"); Second ss2= new Second(fnew,"Wellcome ","In Math"); }}