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

Operating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksOperating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and Deadlocks
Mukesh Chinta
 
Ch7 Process Synchronization galvin
Ch7 Process Synchronization galvinCh7 Process Synchronization galvin
Ch7 Process Synchronization galvin
Shubham Singh
 
Concurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and SynchronizationConcurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and Synchronization
Anas Ebrahim
 
Mutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's AlgorithmMutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's Algorithm
Souvik Roy
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.
MOHIT DADU
 
Process synchronization in operating system
Process synchronization in operating systemProcess synchronization in operating system
Process synchronization in operating system
Ruaha Catholic university
 
Os module 2 c
Os module 2 cOs module 2 c
Os module 2 c
Gichelle Amon
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
Ritu Ranjan Shrivastwa
 
Operating systems question bank
Operating systems question bankOperating systems question bank
Operating systems question bank
anuradha raheja
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
Sonali Chauhan
 
Critical section operating system
Critical section  operating systemCritical section  operating system
Critical section operating system
Muhammad Baqar Kazmi
 
Operating system critical section
Operating system   critical sectionOperating system   critical section
Operating system critical section
Harshana Madusanka Jayamaha
 
OS_Ch7
OS_Ch7OS_Ch7
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
vinay arora
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlocks
tech2click
 
6 Synchronisation
6 Synchronisation6 Synchronisation
6 Synchronisation
Dr. Loganathan R
 
Operating System Process Synchronization
Operating System Process SynchronizationOperating System Process Synchronization
Operating System Process Synchronization
Haziq Naeem
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
sgpraju
 
Peterson Critical Section Problem Solution
Peterson Critical Section Problem SolutionPeterson Critical Section Problem Solution
Peterson Critical Section Problem Solution
Bipul Chandra Kar
 
Process synchronization
Process synchronizationProcess synchronization
Process synchronization
Ali Ahmad
 

What's hot (20)

Operating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksOperating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and Deadlocks
 
Ch7 Process Synchronization galvin
Ch7 Process Synchronization galvinCh7 Process Synchronization galvin
Ch7 Process Synchronization galvin
 
Concurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and SynchronizationConcurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and Synchronization
 
Mutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's AlgorithmMutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's Algorithm
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.
 
Process synchronization in operating system
Process synchronization in operating systemProcess synchronization in operating system
Process synchronization in operating system
 
Os module 2 c
Os module 2 cOs module 2 c
Os module 2 c
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
Operating systems question bank
Operating systems question bankOperating systems question bank
Operating systems question bank
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
 
Critical section operating system
Critical section  operating systemCritical section  operating system
Critical section operating system
 
Operating system critical section
Operating system   critical sectionOperating system   critical section
Operating system critical section
 
OS_Ch7
OS_Ch7OS_Ch7
OS_Ch7
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
 
Process Synchronization And Deadlocks
Process Synchronization And DeadlocksProcess Synchronization And Deadlocks
Process Synchronization And Deadlocks
 
6 Synchronisation
6 Synchronisation6 Synchronisation
6 Synchronisation
 
Operating System Process Synchronization
Operating System Process SynchronizationOperating System Process Synchronization
Operating System Process Synchronization
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
 
Peterson Critical Section Problem Solution
Peterson Critical Section Problem SolutionPeterson Critical Section Problem Solution
Peterson Critical Section Problem Solution
 
Process synchronization
Process synchronizationProcess synchronization
Process synchronization
 

Similar to Process synchronization

critical section problem.pptx
critical section problem.pptxcritical section problem.pptx
critical section problem.pptx
vtu19163
 
Lecture 9 - Process Synchronization.pptx
Lecture 9 - Process Synchronization.pptxLecture 9 - Process Synchronization.pptx
Lecture 9 - Process Synchronization.pptx
EhteshamulIslam1
 
Analysis of mutual exclusion algorithms with the significance and need of ele...
Analysis of mutual exclusion algorithms with the significance and need of ele...Analysis of mutual exclusion algorithms with the significance and need of ele...
Analysis of mutual exclusion algorithms with the significance and need of ele...
Govt. P.G. College Dharamshala
 
Lecture - 24-25.pptx
Lecture - 24-25.pptxLecture - 24-25.pptx
Lecture - 24-25.pptx
FarHana74914
 
Producer Consumer Problem in C explained.ppt
Producer Consumer Problem in C explained.pptProducer Consumer Problem in C explained.ppt
Producer Consumer Problem in C explained.ppt
ossama8
 
Operating System- INTERPROCESS COMMUNICATION.docx
Operating System- INTERPROCESS COMMUNICATION.docxOperating System- INTERPROCESS COMMUNICATION.docx
Operating System- INTERPROCESS COMMUNICATION.docx
minaltmv
 
Inter-Process communication in Operating System.ppt
Inter-Process communication in Operating System.pptInter-Process communication in Operating System.ppt
Inter-Process communication in Operating System.ppt
NitihyaAshwinC
 
Algorithm 1 User-Level Distributed Matrix Factorization Init Server Initial...
Algorithm 1 User-Level Distributed Matrix Factorization Init   Server Initial...Algorithm 1 User-Level Distributed Matrix Factorization Init   Server Initial...
Algorithm 1 User-Level Distributed Matrix Factorization Init Server Initial...
Sara Perez
 
Object Oriented Programming using C++.pptx
Object Oriented Programming using C++.pptxObject Oriented Programming using C++.pptx
Object Oriented Programming using C++.pptx
parveen837153
 
Final Project IEEE format
Final Project IEEE formatFinal Project IEEE format
Final Project IEEE format
Faizan Ahmed
 
Presentation5
Presentation5Presentation5
Presentation5
Natasha Bains
 
Test case optimization in configuration testing using ripper algorithm
Test case optimization in configuration testing using ripper algorithmTest case optimization in configuration testing using ripper algorithm
Test case optimization in configuration testing using ripper algorithm
eSAT Journals
 
Operations on Processes and Cooperating processes
Operations on Processes and Cooperating processesOperations on Processes and Cooperating processes
Operations on Processes and Cooperating processes
VishnuMenon59
 
Chapter 6-Consistency and Replication.ppt
Chapter 6-Consistency and Replication.pptChapter 6-Consistency and Replication.ppt
Chapter 6-Consistency and Replication.ppt
sirajmohammed35
 
operating system for computer engineering ch3.ppt
operating system for computer engineering ch3.pptoperating system for computer engineering ch3.ppt
operating system for computer engineering ch3.ppt
gezaegebre1
 
Kallio Chipster Bosc2009
Kallio Chipster Bosc2009Kallio Chipster Bosc2009
Kallio Chipster Bosc2009
bosc
 
Process synchronization
Process synchronizationProcess synchronization
Process synchronization
lodhran-hayat
 
Process synchronizationfinal
Process synchronizationfinalProcess synchronizationfinal
Process synchronizationfinal
marangburu42
 
Secure Authorised De-duplication using Convergent Encryption Technique
Secure Authorised De-duplication using Convergent Encryption TechniqueSecure Authorised De-duplication using Convergent Encryption Technique
Secure Authorised De-duplication using Convergent Encryption Technique
Eswar Publications
 
1. Mini seminar intro
1. Mini seminar intro1. Mini seminar intro
1. Mini seminar intro
Leonid Maslov
 

Similar to Process synchronization (20)

critical section problem.pptx
critical section problem.pptxcritical section problem.pptx
critical section problem.pptx
 
Lecture 9 - Process Synchronization.pptx
Lecture 9 - Process Synchronization.pptxLecture 9 - Process Synchronization.pptx
Lecture 9 - Process Synchronization.pptx
 
Analysis of mutual exclusion algorithms with the significance and need of ele...
Analysis of mutual exclusion algorithms with the significance and need of ele...Analysis of mutual exclusion algorithms with the significance and need of ele...
Analysis of mutual exclusion algorithms with the significance and need of ele...
 
Lecture - 24-25.pptx
Lecture - 24-25.pptxLecture - 24-25.pptx
Lecture - 24-25.pptx
 
Producer Consumer Problem in C explained.ppt
Producer Consumer Problem in C explained.pptProducer Consumer Problem in C explained.ppt
Producer Consumer Problem in C explained.ppt
 
Operating System- INTERPROCESS COMMUNICATION.docx
Operating System- INTERPROCESS COMMUNICATION.docxOperating System- INTERPROCESS COMMUNICATION.docx
Operating System- INTERPROCESS COMMUNICATION.docx
 
Inter-Process communication in Operating System.ppt
Inter-Process communication in Operating System.pptInter-Process communication in Operating System.ppt
Inter-Process communication in Operating System.ppt
 
Algorithm 1 User-Level Distributed Matrix Factorization Init Server Initial...
Algorithm 1 User-Level Distributed Matrix Factorization Init   Server Initial...Algorithm 1 User-Level Distributed Matrix Factorization Init   Server Initial...
Algorithm 1 User-Level Distributed Matrix Factorization Init Server Initial...
 
Object Oriented Programming using C++.pptx
Object Oriented Programming using C++.pptxObject Oriented Programming using C++.pptx
Object Oriented Programming using C++.pptx
 
Final Project IEEE format
Final Project IEEE formatFinal Project IEEE format
Final Project IEEE format
 
Presentation5
Presentation5Presentation5
Presentation5
 
Test case optimization in configuration testing using ripper algorithm
Test case optimization in configuration testing using ripper algorithmTest case optimization in configuration testing using ripper algorithm
Test case optimization in configuration testing using ripper algorithm
 
Operations on Processes and Cooperating processes
Operations on Processes and Cooperating processesOperations on Processes and Cooperating processes
Operations on Processes and Cooperating processes
 
Chapter 6-Consistency and Replication.ppt
Chapter 6-Consistency and Replication.pptChapter 6-Consistency and Replication.ppt
Chapter 6-Consistency and Replication.ppt
 
operating system for computer engineering ch3.ppt
operating system for computer engineering ch3.pptoperating system for computer engineering ch3.ppt
operating system for computer engineering ch3.ppt
 
Kallio Chipster Bosc2009
Kallio Chipster Bosc2009Kallio Chipster Bosc2009
Kallio Chipster Bosc2009
 
Process synchronization
Process synchronizationProcess synchronization
Process synchronization
 
Process synchronizationfinal
Process synchronizationfinalProcess synchronizationfinal
Process synchronizationfinal
 
Secure Authorised De-duplication using Convergent Encryption Technique
Secure Authorised De-duplication using Convergent Encryption TechniqueSecure Authorised De-duplication using Convergent Encryption Technique
Secure Authorised De-duplication using Convergent Encryption Technique
 
1. Mini seminar intro
1. Mini seminar intro1. Mini seminar intro
1. Mini seminar intro
 

Recently uploaded

Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
RamseyBerglund
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
David Douglas School District
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
TechSoup
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
سمير بسيوني
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
Steve Thomason
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
nitinpv4ai
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 

Recently uploaded (20)

Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
 
A Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two HeartsA Visual Guide to 1 Samuel | A Tale of Two Hearts
A Visual Guide to 1 Samuel | A Tale of Two Hearts
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 

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"); }}