SlideShare a Scribd company logo
1 of 60
Download to read offline
By
CHITRAKANT BANCHHOR
IT, MITCOE, Pune
By
CHITRAKANT BANCHHOR
IT, MITCOE, Pune
••
••
CHITRAKANT BANCHHOR
Parallelism is the quality of occurring at the same timeParallelism is the quality of occurring at the same time
Two tasks are parallel if they are performed at the same time
Concurrency is an illusion of parallelism.Concurrency is an illusion of parallelism.
P1
P2
Principle
of
concurrency
Concurrency
in
single processor machine
Concurrency
in
multiple processor machine
Process 1:
Process 2:
Concurrency in Single processor systemConcurrency in Single processor system
Figure:Figure: Concurrent processing in Uniprocessor system
Time
Process 2:
Process 3:
Modern Operating Systems are multiprocessor systems.Modern Operating Systems are multiprocessor systems.
They run many process concurrently to achieve better resource utilization.They run many process concurrently to achieve better resource utilization.
Concurrent processing in Multiprocessor systemConcurrent processing in Multiprocessor system
Time
CHITRAKANT BANCHHOR
P0:
Read(A);
A = A – 100;
Write(A);
P1:
Read(A);
A = A + 200;
Write(A);
P0:
Read(A);
A = A – 100;
Write(A);
P1:
Read(A);
A = A + 200;
Write(A);
P0:
Read(A);
A = A – 100;
Write(A);
P1:
Read(A);
A = A + 200;
Write(A);
P0:
Read(A);
A = A – 100;
Write(A);
P1:
Read(A);
A = A + 200;
Write(A);
Critical section refers to the code segment of a process, whereby itCritical section refers to the code segment of a process, whereby it
accesses a shared resourceaccesses a shared resource
P1P0 P1
(a)(a) P0 followed by P1.P0 followed by P1.
(b) P1 followed by P0.(b) P1 followed by P0.
P1 P2 Pn
P1 P2 Pn
CHITRAKANT BANCHHOR
dodo
{{
Entry Section
Critical Section
Reminder Section
Exit Section
Critical Section
} while(1);} while(1);
If no process is in critical section, can decide quickly who entersIf no process is in critical section, can decide quickly who enters
Normally the upper bound is 1.Normally the upper bound is 1.
CHITRAKANT BANCHHOR
AlgorithmAlgorithm -- 11
int turn = 0; /* Initial value of turn can be set to 0 or 1*/
P0:P0:
do{
while (turn == 1); /* Keep looping as long as turn equals 1*/
/* This is entry section*/
<Critical Section><Critical Section>
turn = 1; /*Enable P1 to enter Critical Section*/
/*This is exit section*/
<Remainder Section><Remainder Section>
}while(1);
P1:P1:
do{
while (turn == 0); /* Keep looping as long as turn equals 0*/
/* This is the entry section*/
<Critical Section><Critical Section>
turn = 0; /*Enable P0 to enter Critical Section*/
/*This is the exit section*/
<Remainder Section><Remainder Section>
}while(1);
••
Thus the requirement of mutual exclusion is satisfiedThus the requirement of mutual exclusion is satisfied
SITUATION - I :
SITUATION I - 2:
typedef enum boolean { false, true };
boolean flag[2];
Mutual Exclusion satisfied.Mutual Exclusion satisfied.
Peterson's algorithm
int turn; /*Initial Value does not matter*/
boolean flag[2]; /*Initially set to false*/
CHITRAKANT BANCHHOR
int S = 1; /* Let S be a Binary semaphore, initialized to 1 */
void wait( int *S )
{
while( *S == 0 );
/* Keep looping here as long as S is 0*/
*S - -
}
void signal ( int *S )
{
*S++;
}
A process Pi can be synchronized for accessing of its critical section
as follows:
CHITRAKANT BANCHHORCHITRAKANT BANCHHOR

More Related Content

What's hot

Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process Synchronization
Wayne Jones Jnr
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
vinay arora
 
Process synchronization(deepa)
Process synchronization(deepa)Process synchronization(deepa)
Process synchronization(deepa)
Nagarajan
 
Synchronization
SynchronizationSynchronization
Synchronization
Mohd Arif
 
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
 
Print Testing
Print TestingPrint Testing
Print Testing
donwelch
 

What's hot (20)

Loops in R
Loops in RLoops in R
Loops in R
 
Monitors
MonitorsMonitors
Monitors
 
SYNCHRONIZATION
SYNCHRONIZATIONSYNCHRONIZATION
SYNCHRONIZATION
 
Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process Synchronization
 
Operating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksOperating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and Deadlocks
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
 
Mutual exclusion and sync
Mutual exclusion and syncMutual exclusion and sync
Mutual exclusion and sync
 
06 lcd slides 1 - PROCESS SYNCHRONIZATION POWERPOINT
06 lcd slides 1 - PROCESS SYNCHRONIZATION POWERPOINT06 lcd slides 1 - PROCESS SYNCHRONIZATION POWERPOINT
06 lcd slides 1 - PROCESS SYNCHRONIZATION POWERPOINT
 
Looping statements
Looping statementsLooping statements
Looping statements
 
Process synchronization(deepa)
Process synchronization(deepa)Process synchronization(deepa)
Process synchronization(deepa)
 
Peterson Critical Section Problem Solution
Peterson Critical Section Problem SolutionPeterson Critical Section Problem Solution
Peterson Critical Section Problem Solution
 
Synchronization
SynchronizationSynchronization
Synchronization
 
Os module 2 c
Os module 2 cOs module 2 c
Os module 2 c
 
OSCh7
OSCh7OSCh7
OSCh7
 
Parallel Programming In Java
Parallel Programming In JavaParallel Programming In Java
Parallel Programming In Java
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
 
Mutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's AlgorithmMutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's Algorithm
 
Concurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and SynchronizationConcurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and Synchronization
 
Print Testing
Print TestingPrint Testing
Print Testing
 
Looping (Computer programming and utilization)
Looping (Computer programming and utilization)Looping (Computer programming and utilization)
Looping (Computer programming and utilization)
 

Similar to Process synchronization 1

Process Synchronization -1.ppt
Process Synchronization -1.pptProcess Synchronization -1.ppt
Process Synchronization -1.ppt
jayverma27
 
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdfnotes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
SatyamMishra828076
 
A Presentation on Automatic conveyor belt system
A Presentation on Automatic conveyor belt systemA Presentation on Automatic conveyor belt system
A Presentation on Automatic conveyor belt system
DHRUVIT KHARADI
 

Similar to Process synchronization 1 (20)

Process Synchronization -1.ppt
Process Synchronization -1.pptProcess Synchronization -1.ppt
Process Synchronization -1.ppt
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
 
Cs problem [repaired]
Cs problem [repaired]Cs problem [repaired]
Cs problem [repaired]
 
Operating system 23 process synchronization
Operating system 23 process synchronizationOperating system 23 process synchronization
Operating system 23 process synchronization
 
Training – Going Async
Training – Going AsyncTraining – Going Async
Training – Going Async
 
MODULE 3 process synchronizationnnn.pptx
MODULE 3 process synchronizationnnn.pptxMODULE 3 process synchronizationnnn.pptx
MODULE 3 process synchronizationnnn.pptx
 
UNIT 2-UNDERSTANDING THE SYNCHRONIZATION PROCESS.pptx
UNIT 2-UNDERSTANDING THE SYNCHRONIZATION PROCESS.pptxUNIT 2-UNDERSTANDING THE SYNCHRONIZATION PROCESS.pptx
UNIT 2-UNDERSTANDING THE SYNCHRONIZATION PROCESS.pptx
 
03 conditions loops
03   conditions loops03   conditions loops
03 conditions loops
 
First Come First Serve
First Come First ServeFirst Come First Serve
First Come First Serve
 
Repetition, Basic loop structures, Loop programming techniques
Repetition, Basic loop structures, Loop programming techniquesRepetition, Basic loop structures, Loop programming techniques
Repetition, Basic loop structures, Loop programming techniques
 
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdfnotes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
notes_Lecture-8 (Computer Architecture) 3rd Semester 2k11 (1).pdf
 
Elements of Industrial Automation Week 08 Notes.pdf
Elements of Industrial Automation Week 08 Notes.pdfElements of Industrial Automation Week 08 Notes.pdf
Elements of Industrial Automation Week 08 Notes.pdf
 
OS Process Chapter 3.pdf
OS Process Chapter 3.pdfOS Process Chapter 3.pdf
OS Process Chapter 3.pdf
 
OS - Unit 3 Deadlock (Bankers Algorithm).pptx
OS - Unit 3 Deadlock (Bankers Algorithm).pptxOS - Unit 3 Deadlock (Bankers Algorithm).pptx
OS - Unit 3 Deadlock (Bankers Algorithm).pptx
 
Control structures.ppt
Control structures.pptControl structures.ppt
Control structures.ppt
 
A Presentation on Automatic conveyor belt system
A Presentation on Automatic conveyor belt systemA Presentation on Automatic conveyor belt system
A Presentation on Automatic conveyor belt system
 
RTAI - Earliest Deadline First
RTAI - Earliest Deadline FirstRTAI - Earliest Deadline First
RTAI - Earliest Deadline First
 
Reactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactorReactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactor
 
Loops in c++ programming language
Loops in c++ programming language Loops in c++ programming language
Loops in c++ programming language
 
Operating system 26 monitors
Operating system 26 monitorsOperating system 26 monitors
Operating system 26 monitors
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 

Recently uploaded (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 

Process synchronization 1