SlideShare a Scribd company logo
1 of 14
Process Synchronization
 Race Conditions
 The Critical Section
 Semaphores
 Classic Synchronization Problems
*Property of STI J0024
 Race conditions usually occur if two or more processes are allowed to modify
the same shared variable at the same time.
 To prevent race conditions, the operating system must perform process
synchronization to guarantee that only one process is updating a shared variable
at any one time.
*Property of STI J0024
 part of the process that contains the instruction or instructions that access a
shared variable or resource
Process P1
.
.
.
mov ax, counter
inc ax
mov counter, ax
.
.
.
Process P2
.
.
.
mov ax, counter
inc ax
mov counter, ax
.
.
.
Critical
Section of
Process
P1
Critical
Section of
Process
P2
Figure 6.1 Critical Sections for Process P1 and P2
*Property of STI J0024
Software solutions to the critical section problem:
SOLUTION 1
Process P0
.
.
.
while (TurnToEnter != 0) { };
TurnToEnter = 1;
.
.
.
critical section
Process P1
.
.
.
while (TurnToEnter != 1) { };
TurnToEnter = 0;
.
.
.
critical section
Figure 6.2 Critical Sections of Processes P1 and P2 for Solution 1
*Property of STI J0024
SOLUTION 2
Process P0
.
.
.
WantToEnter[0] = true;
while (WantToEnter[1] == true) { };
WantToEnter[0] = false;
.
.
.
critical section
Process P1
.
.
.
WantToEnter[1] = true;
while (WantToEnter[0] == true) { };
WantToEnter[1] = false;
.
.
.
critical section
Figure 6.3 Critical Section P1 and P2 for Solution 2
*Property of STI J0024
SOLUTION 3 (Peterson’s Algorithm)
Process P0
.
.
.
WantToEnter[0] = true;
TurnToEnter = 1;
while (WantToEnter[1] == true && TurnToEnter == 1) { };
WantToEnter[0] = false;
.
.
.
critical section
Process P1
.
.
.
WantToEnter[1] = true;
TurnToEnter = 0;
while (WantToEnter[0] == true && TurnToEnter == 0) { };
WantToEnter[1] = false;
.
.
.
critical section
Figure 6.4 Critical Sections of Processes P1 and P2 for Solution 3
*Property of STI J0024
SOLUTION TO THE CRITICAL SECTION PROBLEM INVOLVING SEVERAL
PROCESS ( Bakery Algorithm)
Process Pi
.
.
.
choosing[i] = true;
number[i] = max(number[0], ... , number[n – 1]) + 1;
choosing[i] = false;
for (j = 1; j < n; j++) {
while (choosing[j] == true) { }
while ((number[j] != 0) &&
((number[j] < number[i]) || (number[j] == number[i]) && (j < i))) { };
}
number[i] = 0;
.
.
.
critical section
Figure 6.5 Critical Section of Process P1 for the Bakery Algorithm
*Property of STI J0024
Hardware solutions to the critical section problem:
 Disabling interrupts
 Special hardware instructions
boolean test_and_set (boolean &i)
{
boolean val;
if (*i == false) {
val = false;
*i = true;
} else
val = true;
return val;
}
These instructions are
executed atomically
(uninterruptible)
Figure 6.6 Definition of test_and set instruction
*Property of STI J0024
.
.
.
while (test_and_set (&lock) == true) { };
*lock := false;
.
.
.
critical section
Process Pi
Figure 6.7 Using the test_and_set instruction to solve
the critical section problem
*Property of STI J0024
Semaphore is a tool that can easily be used to solve more complex synchronization
problems and does not use busy waiting.
.
.
.
wait(mutex);
signal(mutex);
.
.
.
critical section
Process Pi
Figure 6.8 Using Semaphores to Solve the
Critical Section Problem
*Property of STI J0024
The Dining Philosophers Problem
Restrictions:
1. A philosopher cannot start eating unless he has both forks.
2. A philosopher cannot pick up both forks at the same time. He has to do it one
at a time.
3. He cannot get the fork that is being used by the philosopher to his right or to
his left.
Figure 6.9 The Dining Philosophers Problem
*Property of STI J0024
.
.
.
wait(LeftFork);
wait(RightFork);
eat;
signal(RightFork);
signal(LeftFork);
.
.
.
Figure 6.10 Solution to the Dining Philosophers Problem
*Property of STI J0024
The Readers and Writers Problem
.
.
.
wait(wrt);
signal(wrt);
.
.
.
start writing data
Writer Process
Figure 6.11 Using Semaphores to Implement a Writer Process
*Property of STI J0024
.
.
.
wait(mutex);
readcount++;
if readcount ==1
wait(wrt);
signal(mutex);
wait(mutex);
readcount--;
If readcount == 0
signal(wrt);
signal(mutex);
.
.
.
start reading data
Reader Process
Figure 6.12 Using Semaphores to Implement a Reader Process

More Related Content

What's hot

Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationWayne Jones Jnr
 
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
 
Operating System-Ch6 process synchronization
Operating System-Ch6 process synchronizationOperating System-Ch6 process synchronization
Operating System-Ch6 process synchronizationSyaiful Ahdan
 
Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"Ra'Fat Al-Msie'deen
 
Semaphores OS Basics
Semaphores OS BasicsSemaphores OS Basics
Semaphores OS BasicsShijin Raj P
 
Synchronization
SynchronizationSynchronization
SynchronizationMohd Arif
 
Ch7 Process Synchronization galvin
Ch7 Process Synchronization galvinCh7 Process Synchronization galvin
Ch7 Process Synchronization galvinShubham Singh
 
Lec11 semaphores
Lec11 semaphoresLec11 semaphores
Lec11 semaphoresanandammca
 
ITFT_Semaphores and bounded buffer
ITFT_Semaphores and bounded bufferITFT_Semaphores and bounded buffer
ITFT_Semaphores and bounded bufferSneh Prabha
 
Critical Section Problem - Ramakrishna Reddy Bijjam
Critical Section Problem - Ramakrishna Reddy BijjamCritical Section Problem - Ramakrishna Reddy Bijjam
Critical Section Problem - Ramakrishna Reddy BijjamRamakrishna Reddy Bijjam
 
Mutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's AlgorithmMutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's AlgorithmSouvik Roy
 
Process synchronization
Process synchronizationProcess synchronization
Process synchronizationAli Ahmad
 

What's hot (20)

Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process Synchronization
 
Os module 2 c
Os module 2 cOs module 2 c
Os module 2 c
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.
 
Operating System-Ch6 process synchronization
Operating System-Ch6 process synchronizationOperating System-Ch6 process synchronization
Operating System-Ch6 process synchronization
 
Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"
 
SYNCHRONIZATION
SYNCHRONIZATIONSYNCHRONIZATION
SYNCHRONIZATION
 
Semaphores OS Basics
Semaphores OS BasicsSemaphores OS Basics
Semaphores OS Basics
 
Synchronization
SynchronizationSynchronization
Synchronization
 
Ch7 Process Synchronization galvin
Ch7 Process Synchronization galvinCh7 Process Synchronization galvin
Ch7 Process Synchronization galvin
 
Behavioral modeling
Behavioral modelingBehavioral modeling
Behavioral modeling
 
OSCh7
OSCh7OSCh7
OSCh7
 
Lec11 semaphores
Lec11 semaphoresLec11 semaphores
Lec11 semaphores
 
OS_Ch7
OS_Ch7OS_Ch7
OS_Ch7
 
ITFT_Semaphores and bounded buffer
ITFT_Semaphores and bounded bufferITFT_Semaphores and bounded buffer
ITFT_Semaphores and bounded buffer
 
Critical Section Problem - Ramakrishna Reddy Bijjam
Critical Section Problem - Ramakrishna Reddy BijjamCritical Section Problem - Ramakrishna Reddy Bijjam
Critical Section Problem - Ramakrishna Reddy Bijjam
 
Monitors
MonitorsMonitors
Monitors
 
Mutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's AlgorithmMutual Exclusion using Peterson's Algorithm
Mutual Exclusion using Peterson's Algorithm
 
Process synchronization
Process synchronizationProcess synchronization
Process synchronization
 
Operating System
Operating SystemOperating System
Operating System
 
Mutual exclusion
Mutual exclusionMutual exclusion
Mutual exclusion
 

Viewers also liked

Gibbscam solution for mill/turn machine
Gibbscam solution for mill/turn machineGibbscam solution for mill/turn machine
Gibbscam solution for mill/turn machinettehnologie
 
Dolphin CAD/CAM USA CNC Programming Software
Dolphin CAD/CAM USA CNC Programming SoftwareDolphin CAD/CAM USA CNC Programming Software
Dolphin CAD/CAM USA CNC Programming Softwaredolphincadcam
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating SystemsRitu Ranjan Shrivastwa
 
Cnc programming handbook - Peter Schmid
Cnc programming handbook - Peter SchmidCnc programming handbook - Peter Schmid
Cnc programming handbook - Peter SchmidMaxwell Chikara
 
Operating Systems - Synchronization
Operating Systems - SynchronizationOperating Systems - Synchronization
Operating Systems - SynchronizationEmery Berger
 
Cnc Programming Basics
Cnc Programming BasicsCnc Programming Basics
Cnc Programming Basicsshlxtn
 
CNC PROGRAMMING FOR BEGAINER Part 1
CNC PROGRAMMING FOR BEGAINER Part 1CNC PROGRAMMING FOR BEGAINER Part 1
CNC PROGRAMMING FOR BEGAINER Part 1Parveen Kumar
 
Vehicle Body Engineering - Introduction
Vehicle Body Engineering - IntroductionVehicle Body Engineering - Introduction
Vehicle Body Engineering - IntroductionRajat Seth
 

Viewers also liked (8)

Gibbscam solution for mill/turn machine
Gibbscam solution for mill/turn machineGibbscam solution for mill/turn machine
Gibbscam solution for mill/turn machine
 
Dolphin CAD/CAM USA CNC Programming Software
Dolphin CAD/CAM USA CNC Programming SoftwareDolphin CAD/CAM USA CNC Programming Software
Dolphin CAD/CAM USA CNC Programming Software
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
Cnc programming handbook - Peter Schmid
Cnc programming handbook - Peter SchmidCnc programming handbook - Peter Schmid
Cnc programming handbook - Peter Schmid
 
Operating Systems - Synchronization
Operating Systems - SynchronizationOperating Systems - Synchronization
Operating Systems - Synchronization
 
Cnc Programming Basics
Cnc Programming BasicsCnc Programming Basics
Cnc Programming Basics
 
CNC PROGRAMMING FOR BEGAINER Part 1
CNC PROGRAMMING FOR BEGAINER Part 1CNC PROGRAMMING FOR BEGAINER Part 1
CNC PROGRAMMING FOR BEGAINER Part 1
 
Vehicle Body Engineering - Introduction
Vehicle Body Engineering - IntroductionVehicle Body Engineering - Introduction
Vehicle Body Engineering - Introduction
 

Similar to 06 lcd slides 1 - PROCESS SYNCHRONIZATION POWERPOINT

15- Bakery-Algorithm.pptx
15- Bakery-Algorithm.pptx15- Bakery-Algorithm.pptx
15- Bakery-Algorithm.pptxmobeenahmed49
 
ParallelProgrammingBasics_v2.pdf
ParallelProgrammingBasics_v2.pdfParallelProgrammingBasics_v2.pdf
ParallelProgrammingBasics_v2.pdfChen-Hung Hu
 
20200630 Rakuten QA meetup #2 "Improve test automation operation"
20200630 Rakuten QA meetup #2 "Improve test automation operation"20200630 Rakuten QA meetup #2 "Improve test automation operation"
20200630 Rakuten QA meetup #2 "Improve test automation operation"Sadaaki Emura
 
Using Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side EffectsUsing Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side EffectsGlobalLogic Ukraine
 
Planet-HTML5-Game-Engine Javascript Performance Enhancement
Planet-HTML5-Game-Engine Javascript Performance EnhancementPlanet-HTML5-Game-Engine Javascript Performance Enhancement
Planet-HTML5-Game-Engine Javascript Performance Enhancementup2soul
 
딥러닝 중급 - AlexNet과 VggNet (Basic of DCNN : AlexNet and VggNet)
딥러닝 중급 - AlexNet과 VggNet (Basic of DCNN : AlexNet and VggNet)딥러닝 중급 - AlexNet과 VggNet (Basic of DCNN : AlexNet and VggNet)
딥러닝 중급 - AlexNet과 VggNet (Basic of DCNN : AlexNet and VggNet)Hansol Kang
 
Basic Tutorial for Robotic Arm
Basic Tutorial for Robotic ArmBasic Tutorial for Robotic Arm
Basic Tutorial for Robotic ArmYu Wei Chen
 
Mitsubishi ac servos melservo j4 solutions press-fit machine-dienhathe.vn
Mitsubishi ac servos melservo j4 solutions press-fit machine-dienhathe.vnMitsubishi ac servos melservo j4 solutions press-fit machine-dienhathe.vn
Mitsubishi ac servos melservo j4 solutions press-fit machine-dienhathe.vnDien Ha The
 
R&D of Equipment
R&D of EquipmentR&D of Equipment
R&D of EquipmentTomoya Ito
 
"Quantum" performance effects
"Quantum" performance effects"Quantum" performance effects
"Quantum" performance effectsSergey Kuksenko
 
Project single cyclemips processor_verilog
Project single cyclemips processor_verilogProject single cyclemips processor_verilog
Project single cyclemips processor_verilogHarsha Yelisala
 
Online test program generator for RISC-V processors
Online test program generator for RISC-V processorsOnline test program generator for RISC-V processors
Online test program generator for RISC-V processorsRISC-V International
 
Operator Overloading
Operator Overloading  Operator Overloading
Operator Overloading Sardar Alam
 

Similar to 06 lcd slides 1 - PROCESS SYNCHRONIZATION POWERPOINT (20)

Ch7
Ch7Ch7
Ch7
 
2621008 - C++ 3
2621008 -  C++ 32621008 -  C++ 3
2621008 - C++ 3
 
15- Bakery-Algorithm.pptx
15- Bakery-Algorithm.pptx15- Bakery-Algorithm.pptx
15- Bakery-Algorithm.pptx
 
ParallelProgrammingBasics_v2.pdf
ParallelProgrammingBasics_v2.pdfParallelProgrammingBasics_v2.pdf
ParallelProgrammingBasics_v2.pdf
 
20200630 Rakuten QA meetup #2 "Improve test automation operation"
20200630 Rakuten QA meetup #2 "Improve test automation operation"20200630 Rakuten QA meetup #2 "Improve test automation operation"
20200630 Rakuten QA meetup #2 "Improve test automation operation"
 
Using Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side EffectsUsing Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side Effects
 
Planet-HTML5-Game-Engine Javascript Performance Enhancement
Planet-HTML5-Game-Engine Javascript Performance EnhancementPlanet-HTML5-Game-Engine Javascript Performance Enhancement
Planet-HTML5-Game-Engine Javascript Performance Enhancement
 
ICIC2015_327
ICIC2015_327ICIC2015_327
ICIC2015_327
 
딥러닝 중급 - AlexNet과 VggNet (Basic of DCNN : AlexNet and VggNet)
딥러닝 중급 - AlexNet과 VggNet (Basic of DCNN : AlexNet and VggNet)딥러닝 중급 - AlexNet과 VggNet (Basic of DCNN : AlexNet and VggNet)
딥러닝 중급 - AlexNet과 VggNet (Basic of DCNN : AlexNet and VggNet)
 
Basic Tutorial for Robotic Arm
Basic Tutorial for Robotic ArmBasic Tutorial for Robotic Arm
Basic Tutorial for Robotic Arm
 
EEE.pptx
EEE.pptxEEE.pptx
EEE.pptx
 
Mitsubishi ac servos melservo j4 solutions press-fit machine-dienhathe.vn
Mitsubishi ac servos melservo j4 solutions press-fit machine-dienhathe.vnMitsubishi ac servos melservo j4 solutions press-fit machine-dienhathe.vn
Mitsubishi ac servos melservo j4 solutions press-fit machine-dienhathe.vn
 
R&D of Equipment
R&D of EquipmentR&D of Equipment
R&D of Equipment
 
ch6_EN_BK_syn1.pdf
ch6_EN_BK_syn1.pdfch6_EN_BK_syn1.pdf
ch6_EN_BK_syn1.pdf
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
"Quantum" performance effects
"Quantum" performance effects"Quantum" performance effects
"Quantum" performance effects
 
Project single cyclemips processor_verilog
Project single cyclemips processor_verilogProject single cyclemips processor_verilog
Project single cyclemips processor_verilog
 
Online test program generator for RISC-V processors
Online test program generator for RISC-V processorsOnline test program generator for RISC-V processors
Online test program generator for RISC-V processors
 
project report
project reportproject report
project report
 
Operator Overloading
Operator Overloading  Operator Overloading
Operator Overloading
 

More from Anne Lee

Week 17 slides 1 7 multidimensional, parallel, and distributed database
Week 17 slides 1 7 multidimensional, parallel, and distributed databaseWeek 17 slides 1 7 multidimensional, parallel, and distributed database
Week 17 slides 1 7 multidimensional, parallel, and distributed databaseAnne Lee
 
Data mining
Data miningData mining
Data miningAnne Lee
 
Data warehousing
Data warehousingData warehousing
Data warehousingAnne Lee
 
Database backup and recovery
Database backup and recoveryDatabase backup and recovery
Database backup and recoveryAnne Lee
 
Database monitoring and performance management
Database monitoring and performance managementDatabase monitoring and performance management
Database monitoring and performance managementAnne Lee
 
transportation and assignment models
transportation and assignment modelstransportation and assignment models
transportation and assignment modelsAnne Lee
 
Database Security Slide Handout
Database Security Slide HandoutDatabase Security Slide Handout
Database Security Slide HandoutAnne Lee
 
Database Security Handout
Database Security HandoutDatabase Security Handout
Database Security HandoutAnne Lee
 
Database Security - IG
Database Security - IGDatabase Security - IG
Database Security - IGAnne Lee
 
03 laboratory exercise 1 - WORKING WITH CTE
03 laboratory exercise 1 - WORKING WITH CTE03 laboratory exercise 1 - WORKING WITH CTE
03 laboratory exercise 1 - WORKING WITH CTEAnne Lee
 
02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES
02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES
02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLESAnne Lee
 
01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION
01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION
01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATIONAnne Lee
 
Indexes - INSTRUCTOR'S GUIDE
Indexes - INSTRUCTOR'S GUIDEIndexes - INSTRUCTOR'S GUIDE
Indexes - INSTRUCTOR'S GUIDEAnne Lee
 
07 ohp slides 1 - INDEXES
07 ohp slides 1 - INDEXES07 ohp slides 1 - INDEXES
07 ohp slides 1 - INDEXESAnne Lee
 
07 ohp slide handout 1 - INDEXES
07 ohp slide handout 1 - INDEXES07 ohp slide handout 1 - INDEXES
07 ohp slide handout 1 - INDEXESAnne Lee
 
Wk 16 ses 43 45 makrong kasanayan sa pagsusulat
Wk 16 ses 43 45 makrong kasanayan sa pagsusulatWk 16 ses 43 45 makrong kasanayan sa pagsusulat
Wk 16 ses 43 45 makrong kasanayan sa pagsusulatAnne Lee
 
Wk 15 ses 40 42 makrong kasanayan sa pagbabasa
Wk 15 ses 40 42 makrong kasanayan sa pagbabasaWk 15 ses 40 42 makrong kasanayan sa pagbabasa
Wk 15 ses 40 42 makrong kasanayan sa pagbabasaAnne Lee
 
Wk 13 ses 35 37 makrong kasanayan sa pagsasalita
Wk 13 ses 35 37 makrong kasanayan sa pagsasalitaWk 13 ses 35 37 makrong kasanayan sa pagsasalita
Wk 13 ses 35 37 makrong kasanayan sa pagsasalitaAnne Lee
 
Wk 12 ses 32 34 makrong kasanayan sa pakikinig
Wk 12 ses 32 34 makrong kasanayan sa pakikinigWk 12 ses 32 34 makrong kasanayan sa pakikinig
Wk 12 ses 32 34 makrong kasanayan sa pakikinigAnne Lee
 
Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1
Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1
Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1Anne Lee
 

More from Anne Lee (20)

Week 17 slides 1 7 multidimensional, parallel, and distributed database
Week 17 slides 1 7 multidimensional, parallel, and distributed databaseWeek 17 slides 1 7 multidimensional, parallel, and distributed database
Week 17 slides 1 7 multidimensional, parallel, and distributed database
 
Data mining
Data miningData mining
Data mining
 
Data warehousing
Data warehousingData warehousing
Data warehousing
 
Database backup and recovery
Database backup and recoveryDatabase backup and recovery
Database backup and recovery
 
Database monitoring and performance management
Database monitoring and performance managementDatabase monitoring and performance management
Database monitoring and performance management
 
transportation and assignment models
transportation and assignment modelstransportation and assignment models
transportation and assignment models
 
Database Security Slide Handout
Database Security Slide HandoutDatabase Security Slide Handout
Database Security Slide Handout
 
Database Security Handout
Database Security HandoutDatabase Security Handout
Database Security Handout
 
Database Security - IG
Database Security - IGDatabase Security - IG
Database Security - IG
 
03 laboratory exercise 1 - WORKING WITH CTE
03 laboratory exercise 1 - WORKING WITH CTE03 laboratory exercise 1 - WORKING WITH CTE
03 laboratory exercise 1 - WORKING WITH CTE
 
02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES
02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES
02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES
 
01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION
01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION
01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION
 
Indexes - INSTRUCTOR'S GUIDE
Indexes - INSTRUCTOR'S GUIDEIndexes - INSTRUCTOR'S GUIDE
Indexes - INSTRUCTOR'S GUIDE
 
07 ohp slides 1 - INDEXES
07 ohp slides 1 - INDEXES07 ohp slides 1 - INDEXES
07 ohp slides 1 - INDEXES
 
07 ohp slide handout 1 - INDEXES
07 ohp slide handout 1 - INDEXES07 ohp slide handout 1 - INDEXES
07 ohp slide handout 1 - INDEXES
 
Wk 16 ses 43 45 makrong kasanayan sa pagsusulat
Wk 16 ses 43 45 makrong kasanayan sa pagsusulatWk 16 ses 43 45 makrong kasanayan sa pagsusulat
Wk 16 ses 43 45 makrong kasanayan sa pagsusulat
 
Wk 15 ses 40 42 makrong kasanayan sa pagbabasa
Wk 15 ses 40 42 makrong kasanayan sa pagbabasaWk 15 ses 40 42 makrong kasanayan sa pagbabasa
Wk 15 ses 40 42 makrong kasanayan sa pagbabasa
 
Wk 13 ses 35 37 makrong kasanayan sa pagsasalita
Wk 13 ses 35 37 makrong kasanayan sa pagsasalitaWk 13 ses 35 37 makrong kasanayan sa pagsasalita
Wk 13 ses 35 37 makrong kasanayan sa pagsasalita
 
Wk 12 ses 32 34 makrong kasanayan sa pakikinig
Wk 12 ses 32 34 makrong kasanayan sa pakikinigWk 12 ses 32 34 makrong kasanayan sa pakikinig
Wk 12 ses 32 34 makrong kasanayan sa pakikinig
 
Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1
Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1
Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1
 

Recently uploaded

Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 

Recently uploaded (20)

Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 

06 lcd slides 1 - PROCESS SYNCHRONIZATION POWERPOINT

  • 1. Process Synchronization  Race Conditions  The Critical Section  Semaphores  Classic Synchronization Problems
  • 2. *Property of STI J0024  Race conditions usually occur if two or more processes are allowed to modify the same shared variable at the same time.  To prevent race conditions, the operating system must perform process synchronization to guarantee that only one process is updating a shared variable at any one time.
  • 3. *Property of STI J0024  part of the process that contains the instruction or instructions that access a shared variable or resource Process P1 . . . mov ax, counter inc ax mov counter, ax . . . Process P2 . . . mov ax, counter inc ax mov counter, ax . . . Critical Section of Process P1 Critical Section of Process P2 Figure 6.1 Critical Sections for Process P1 and P2
  • 4. *Property of STI J0024 Software solutions to the critical section problem: SOLUTION 1 Process P0 . . . while (TurnToEnter != 0) { }; TurnToEnter = 1; . . . critical section Process P1 . . . while (TurnToEnter != 1) { }; TurnToEnter = 0; . . . critical section Figure 6.2 Critical Sections of Processes P1 and P2 for Solution 1
  • 5. *Property of STI J0024 SOLUTION 2 Process P0 . . . WantToEnter[0] = true; while (WantToEnter[1] == true) { }; WantToEnter[0] = false; . . . critical section Process P1 . . . WantToEnter[1] = true; while (WantToEnter[0] == true) { }; WantToEnter[1] = false; . . . critical section Figure 6.3 Critical Section P1 and P2 for Solution 2
  • 6. *Property of STI J0024 SOLUTION 3 (Peterson’s Algorithm) Process P0 . . . WantToEnter[0] = true; TurnToEnter = 1; while (WantToEnter[1] == true && TurnToEnter == 1) { }; WantToEnter[0] = false; . . . critical section Process P1 . . . WantToEnter[1] = true; TurnToEnter = 0; while (WantToEnter[0] == true && TurnToEnter == 0) { }; WantToEnter[1] = false; . . . critical section Figure 6.4 Critical Sections of Processes P1 and P2 for Solution 3
  • 7. *Property of STI J0024 SOLUTION TO THE CRITICAL SECTION PROBLEM INVOLVING SEVERAL PROCESS ( Bakery Algorithm) Process Pi . . . choosing[i] = true; number[i] = max(number[0], ... , number[n – 1]) + 1; choosing[i] = false; for (j = 1; j < n; j++) { while (choosing[j] == true) { } while ((number[j] != 0) && ((number[j] < number[i]) || (number[j] == number[i]) && (j < i))) { }; } number[i] = 0; . . . critical section Figure 6.5 Critical Section of Process P1 for the Bakery Algorithm
  • 8. *Property of STI J0024 Hardware solutions to the critical section problem:  Disabling interrupts  Special hardware instructions boolean test_and_set (boolean &i) { boolean val; if (*i == false) { val = false; *i = true; } else val = true; return val; } These instructions are executed atomically (uninterruptible) Figure 6.6 Definition of test_and set instruction
  • 9. *Property of STI J0024 . . . while (test_and_set (&lock) == true) { }; *lock := false; . . . critical section Process Pi Figure 6.7 Using the test_and_set instruction to solve the critical section problem
  • 10. *Property of STI J0024 Semaphore is a tool that can easily be used to solve more complex synchronization problems and does not use busy waiting. . . . wait(mutex); signal(mutex); . . . critical section Process Pi Figure 6.8 Using Semaphores to Solve the Critical Section Problem
  • 11. *Property of STI J0024 The Dining Philosophers Problem Restrictions: 1. A philosopher cannot start eating unless he has both forks. 2. A philosopher cannot pick up both forks at the same time. He has to do it one at a time. 3. He cannot get the fork that is being used by the philosopher to his right or to his left. Figure 6.9 The Dining Philosophers Problem
  • 12. *Property of STI J0024 . . . wait(LeftFork); wait(RightFork); eat; signal(RightFork); signal(LeftFork); . . . Figure 6.10 Solution to the Dining Philosophers Problem
  • 13. *Property of STI J0024 The Readers and Writers Problem . . . wait(wrt); signal(wrt); . . . start writing data Writer Process Figure 6.11 Using Semaphores to Implement a Writer Process
  • 14. *Property of STI J0024 . . . wait(mutex); readcount++; if readcount ==1 wait(wrt); signal(mutex); wait(mutex); readcount--; If readcount == 0 signal(wrt); signal(mutex); . . . start reading data Reader Process Figure 6.12 Using Semaphores to Implement a Reader Process