SlideShare ist ein Scribd-Unternehmen logo
1 von 15
ACKNOWLEDGEMENT
We have no words to express our deepest gratitude to ALLAH who
blessed and enabled us to complete this project. Its great privilege to
mention the feelings of obligations towards our affectionate parents
and department, who prayed, encouraged and inspired us for higher
education and are supporting financially and morally throughout our
studies.
We find it very difficult to select the appropriate words to express our
gratitude to our teacher Prof. Umar and his useful encouragement and
dynamic supervision.
Course Instructor:
-----------------------------------
DECLARATION
We hereby declare that this project report entitled “Process Synchronization” is written by us
and is our own effort and that no part has been copied and taken from any other source.
Submitted by Signature with Date
Haziq Naeem (107) ----------------------------------------
Muhammad Adeel (83) ----------------------------------------
TABLE OF CONTENTS
Sr# Contents Page#
1 Introduction 1
2 Synchronization 2
2.1 Critical Section Problem 2
2.2 Locks 4
2.3 Petersons Solution 5
2.4 Semaphores 5
2.5 Major Problems of Synchronization 6
3 Windows vs Linux Synchronization 8
4 Activity Chart 9
5 Conclusion 9
6 References 9
FIGURES TABLE
Fig# Contents Page#
1 Synchronization 1
2 Synchronization 2
3 Critical Section Problem 3
4 Locks 4
5 Petersons Solution 5
6 Major Problems of Synchronization 7
7 Major Problems of Synchronization 7
8 Major Problems of Synchronization 8
9 Activity Chart 9
1. Introduction
Synchronization is the mutual understanding between two processes or more.
In simple words synchronization means sharing system resources. i.e. Track of a train, they are
mutually synchronized with each other.
2. Synchronization
Access to two or more processes to share data can result in data inconsistency. for this a
mechanism is used called “Synchronization”.
Synchronization is the mutual understanding between two processes or more.
In simple words synchronization means sharing system resources. i.e. Track of a train, they are
mutually synchronized with each other.
(Figure 1)
Example:
Synchronizing Traffic
In a one way tunnel the tunnel can only be used when no oncoming traffic is present and when
the traffic is already flowing in the right way.
(Figure 2)
Problems:
 Deadlock: Two or more than two process waiting for an event
 Starvation: Indefinite blocking. Process that required resource which is never
allocated.
2.1. Critical SectionProblem
Only one process executed at a time in critical section. Only one process is allowed to start or
execute in its critical section. So every process 1st request permission to entering in critical
section.
Three section involved in critical section:
i. Entering Section
ii. Exit Section
iii. Remainder Section
If one process started working, other processes will have to wait until first will finished.
(Figure 3)
We discuss the critical section problem now we will discuss the solution of critical section
problem.
Solutions of Critical Section Problem:
Three kinds of solutions involved in critical section problem
i. Mutual Exclusion
ii. Progress
iii. Bounded Waiting
i. Mutual Exclusion
One processes execute no other process will interfere in it.
For example, if a process named A1 and other Process named A2. If A1 executes in its critical
section, then A2 not allowed to interfere in it.
ii. Progress
If no process executed in its critical section, then those process only requested to execute in
its critical section which are in remainder section and the rest are placed in queue.
iii. Bounded Waiting
When a process makes request or a process request granted to enter in a critical section then a
limit or bound exists on the number of times that the other processes are allowed to enter its
critical section.
For example, a process AB requested to enter in its critical section bounded waiting restricted
that this process enter only two times in its critical section after request made and before request
granted to its critical section
Another example of bounded waiting is the limits of downloading on websites
2.2. Locks
Lock means to prevent someone to do something. Any solution to critical section problem
requires some form of lock.
Acquire: Before entering its critical section
Release: After exits the critical section
A software tool is built for this known as “Mutex Lock”. Also known as spin lock.
(Figure 4)
Synchronization Hardware:
Many systems provide the support of hardware for critical section.
 Uniprocessors can disable interrupts:
System clock kept updated by interrupts
 Modern machines are non-interrupt able:
Allow us to test and modify content of a word or to swap contents of two words.
2.3. Peterson’s Solution
It is a software based solution to critical section problem.
 Provides good algorithm description of solving.
 Describe the complexities in designing software (three critical section solutions).
 Could not be work on modern non-interrupt able machines.
The solution is for two processes. Load and store instructions are non-interrupt able.
(Figure 5)
2.4. Semaphores
Semaphores is a variable that is used to manage or control access to a common resource by
multiple processes in a similar or concurrent system.
It is basically a synchronization tool. Two operations are involved in it. Wait and Signal
represented as P() and V().
Wait: increasing the value of its arguments as soon as it will become non minus
Signal: decreasing the value of its arguments as an individual operation
Properties:
 It is very simple
 Works with many processes
 Each critical section has different semaphores
 Can have same critical section with same semaphores
Types of semaphores:
i. Counting Semaphores
ii. Binary Semaphores
i. Binary Semaphores
It is a type of semaphores used to implement bounded concurrency
The value of binary semaphores can only range from 0 to 1.
ii. Counting Semaphores
A type of semaphores which is also known as mutex. It is used to implement mutual exclusion
value of counting semaphores over an unrestricted range.
For example Bank account
2.5. MajorProblems of Synchronization
There are three major problems of synchronization
i. Bound Buffer Problems
ii. Reader-Writer Problem
iii. Dinning Philosophers Problem
i. Bound Buffer Problem
In bound buffer there are two concepts involved. Producer and consumer
This problem explains these two processes which share common buffer used as a queue.
Producer produce the data take it into the buffer and again started Whereas Consumer delete
or remove data one by one If buffer is full then more data can’t be stored and consumer not
able to remove data from an empty buffer.
The solution for producer is to discard data or go to sleep if the buffer is full. If consumer
removes something into the buffer, then notifies the producer will start again to fill the buffer.
Now for consumer, if consumer finds buffer empty then it can go to sleep. When producer puts
any data in buffer the consumer awakes.
The solution of this problem is semaphores and improper solution will result as a deadlock.
ii. Readers-Writers Problem
Readers: Don’t perform any updates only read the data
Writers: Performing both reading and writing
Problem is that multiple readers to read the data but only one writer can access data at that
time.
iii. Dining Philosophers Problems
Invented by E.W. Dijkstra.
Problem:
Imagine there are five philosophers who only eat and think. They are sitting on a circular table
to eat spaghetti and have only five chopsticks to eat. Each philosopher thins and when he felt
hungry he picks up chopsticks and eat spaghetti, after finish eating he puts down the chopsticks
and starts to think again.
(Figure 6)
Analysis of problem:
(Figure 7)
Solution:
(Figure 8)
3. Windows vs Linux Synchronization
Windows Linux
Uses interrupts to protect access to
global resources on unipolar systems
Disables interrupts to implement
short critical sections
Provides dispatcher objects which
may act as semaphores
Provides semaphores
Uses spin locks on multiprocessor
systems
Provides spin locks
4. Activity Chart
(Figure 9)
5. Conclusion
Synchronization is a mechanism for the mutual understanding between two or more processes.
It Includes critical section problems, locks, Peterson’s solution, semaphores and major
problems of synchronization.
As very thing has positive and negative sights, synchronization has more positive ones.
It is a major technique / mechanism used in the operating systems. It gives access to prevent
from deadlocks and starvation, due to this mechanism the data integrity and consistency
increases, it collaborates data and improve the efficiency of the work.
6. References
Critical Section:
http://web.stanford.edu/class/cs140/cgi-bin/lecture.php?topic=locks
https://cseweb.ucsd.edu/classes/fa05/cse120/lectures/120-l5.pdf
Semaphores:
https://en.wikipedia.org/wiki/Semaphore_(programming)
http://www.personal.kent.edu/~rmuhamma/OpSystems/Myos/semaphore.htm
https://en.wikibooks.org/wiki/Operating_System_Design/Processes/Semaphores
Dining Philosophers Problems:
https://www.cs.mtu.edu/~shene/NSF-3/e-Book/MUTEX/TM-example-philos-1.html
Locks:
http://cse.stfx.ca/~mlin/cs375/lectures/syn3.ppt
Imp of Sync:
http://users.csc.calpoly.edu/~fkurfess/Courses/COMP-346/W00/Slides/05-ProcSync.ppt
=======================

Weitere ähnliche Inhalte

Was ist angesagt?

Chapter 12 transactions and concurrency control
Chapter 12 transactions and concurrency controlChapter 12 transactions and concurrency control
Chapter 12 transactions and concurrency controlAbDul ThaYyal
 
Deadlock Avoidance - OS
Deadlock Avoidance - OSDeadlock Avoidance - OS
Deadlock Avoidance - OSMsAnita2
 
Aggrement protocols
Aggrement protocolsAggrement protocols
Aggrement protocolsMayank Jain
 
Grasp patterns and its types
Grasp patterns and its typesGrasp patterns and its types
Grasp patterns and its typesSyed Hassan Ali
 
Dining philosopher problem operating system
Dining philosopher problem operating system Dining philosopher problem operating system
Dining philosopher problem operating system anushkashastri
 
Distributed Mutual Exclusion and Distributed Deadlock Detection
Distributed Mutual Exclusion and Distributed Deadlock DetectionDistributed Mutual Exclusion and Distributed Deadlock Detection
Distributed Mutual Exclusion and Distributed Deadlock DetectionSHIKHA GAUTAM
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Ravindra Raju Kolahalam
 
Methods for handling deadlock
Methods for handling deadlockMethods for handling deadlock
Methods for handling deadlocksangrampatil81
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-SystemsVenkata Sreeram
 
INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxLECO9
 
Deadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbianDeadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbiansaad symbian
 
Chapter 14 replication
Chapter 14 replicationChapter 14 replication
Chapter 14 replicationAbDul ThaYyal
 
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
 
deadlock avoidance
deadlock avoidancedeadlock avoidance
deadlock avoidancewahab13
 

Was ist angesagt? (20)

Chapter 12 transactions and concurrency control
Chapter 12 transactions and concurrency controlChapter 12 transactions and concurrency control
Chapter 12 transactions and concurrency control
 
Deadlock Avoidance - OS
Deadlock Avoidance - OSDeadlock Avoidance - OS
Deadlock Avoidance - OS
 
Aggrement protocols
Aggrement protocolsAggrement protocols
Aggrement protocols
 
Grasp patterns and its types
Grasp patterns and its typesGrasp patterns and its types
Grasp patterns and its types
 
Replication in Distributed Systems
Replication in Distributed SystemsReplication in Distributed Systems
Replication in Distributed Systems
 
Dining philosopher problem operating system
Dining philosopher problem operating system Dining philosopher problem operating system
Dining philosopher problem operating system
 
Semaphores
SemaphoresSemaphores
Semaphores
 
Distributed Mutual Exclusion and Distributed Deadlock Detection
Distributed Mutual Exclusion and Distributed Deadlock DetectionDistributed Mutual Exclusion and Distributed Deadlock Detection
Distributed Mutual Exclusion and Distributed Deadlock Detection
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
Methods for handling deadlock
Methods for handling deadlockMethods for handling deadlock
Methods for handling deadlock
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptx
 
Desktop and multiprocessor systems
Desktop and multiprocessor systemsDesktop and multiprocessor systems
Desktop and multiprocessor systems
 
Bankers algorithm
Bankers algorithmBankers algorithm
Bankers algorithm
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbianDeadlock detection and recovery by saad symbian
Deadlock detection and recovery by saad symbian
 
Chapter 14 replication
Chapter 14 replicationChapter 14 replication
Chapter 14 replication
 
Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"Operating Systems - "Chapter 5 Process Synchronization"
Operating Systems - "Chapter 5 Process Synchronization"
 
deadlock avoidance
deadlock avoidancedeadlock avoidance
deadlock avoidance
 
Distributed deadlock
Distributed deadlockDistributed deadlock
Distributed deadlock
 

Andere mochten auch

Unit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process SynchronizationUnit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process Synchronizationcscarcas
 
Operating Systems - Synchronization
Operating Systems - SynchronizationOperating Systems - Synchronization
Operating Systems - SynchronizationEmery Berger
 
Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationWayne Jones Jnr
 
Process synchronization(deepa)
Process synchronization(deepa)Process synchronization(deepa)
Process synchronization(deepa)Nagarajan
 
Web Tech
Web TechWeb Tech
Web TechRupsee
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitorssgpraju
 

Andere mochten auch (8)

Unit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process SynchronizationUnit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process Synchronization
 
Web technology
Web technologyWeb technology
Web technology
 
Operating Systems - Synchronization
Operating Systems - SynchronizationOperating Systems - Synchronization
Operating Systems - Synchronization
 
Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process Synchronization
 
Process synchronization(deepa)
Process synchronization(deepa)Process synchronization(deepa)
Process synchronization(deepa)
 
Web Tech
Web TechWeb Tech
Web Tech
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
 
Process synchronization in operating system
Process synchronization in operating systemProcess synchronization in operating system
Process synchronization in operating system
 

Ähnlich wie Operating System Process Synchronization

Process synchronization
Process synchronizationProcess synchronization
Process synchronizationlodhran-hayat
 
Operating System- INTERPROCESS COMMUNICATION.docx
Operating System- INTERPROCESS COMMUNICATION.docxOperating System- INTERPROCESS COMMUNICATION.docx
Operating System- INTERPROCESS COMMUNICATION.docxminaltmv
 
04 threads-pbl-2-slots
04 threads-pbl-2-slots04 threads-pbl-2-slots
04 threads-pbl-2-slotsmha4
 
04 threads-pbl-2-slots
04 threads-pbl-2-slots04 threads-pbl-2-slots
04 threads-pbl-2-slotsmha4
 
Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10Kuwait10
 
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.pptossama8
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process CommunicationAdeel Rasheed
 
Processes, Threads and Scheduler
Processes, Threads and SchedulerProcesses, Threads and Scheduler
Processes, Threads and SchedulerMunazza-Mah-Jabeen
 
parallel Questions & answers
parallel Questions & answersparallel Questions & answers
parallel Questions & answersMd. Mashiur Rahman
 
Lecture 5- Process Synchonization_revised.pdf
Lecture 5- Process Synchonization_revised.pdfLecture 5- Process Synchonization_revised.pdf
Lecture 5- Process Synchonization_revised.pdfAmanuelmergia
 
Bt0070, operating systems
Bt0070, operating systemsBt0070, operating systems
Bt0070, operating systemssmumbahelp
 
Os sample mid exam
Os sample mid examOs sample mid exam
Os sample mid examMesfin123
 
A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...
A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...
A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...Neelamani Samal
 
Introduction to Java Enterprise Edition
Introduction to Java Enterprise EditionIntroduction to Java Enterprise Edition
Introduction to Java Enterprise EditionAbdalla Mahmoud
 
critical section problem.pptx
critical section problem.pptxcritical section problem.pptx
critical section problem.pptxvtu19163
 

Ähnlich wie Operating System Process Synchronization (20)

Process synchronization
Process synchronizationProcess synchronization
Process synchronization
 
Operating System- INTERPROCESS COMMUNICATION.docx
Operating System- INTERPROCESS COMMUNICATION.docxOperating System- INTERPROCESS COMMUNICATION.docx
Operating System- INTERPROCESS COMMUNICATION.docx
 
Process coordination
Process coordinationProcess coordination
Process coordination
 
04 threads-pbl-2-slots
04 threads-pbl-2-slots04 threads-pbl-2-slots
04 threads-pbl-2-slots
 
04 threads-pbl-2-slots
04 threads-pbl-2-slots04 threads-pbl-2-slots
04 threads-pbl-2-slots
 
Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10Software Engineering with Objects (M363) Final Revision By Kuwait10
Software Engineering with Objects (M363) Final Revision By Kuwait10
 
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
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
Processes, Threads and Scheduler
Processes, Threads and SchedulerProcesses, Threads and Scheduler
Processes, Threads and Scheduler
 
parallel Questions & answers
parallel Questions & answersparallel Questions & answers
parallel Questions & answers
 
Critical section operating system
Critical section  operating systemCritical section  operating system
Critical section operating system
 
Lecture 5- Process Synchonization_revised.pdf
Lecture 5- Process Synchonization_revised.pdfLecture 5- Process Synchonization_revised.pdf
Lecture 5- Process Synchonization_revised.pdf
 
Bt0070, operating systems
Bt0070, operating systemsBt0070, operating systems
Bt0070, operating systems
 
Adsa u4 ver 1.0
Adsa u4 ver 1.0Adsa u4 ver 1.0
Adsa u4 ver 1.0
 
Os sample mid exam
Os sample mid examOs sample mid exam
Os sample mid exam
 
Ipc feb4
Ipc feb4Ipc feb4
Ipc feb4
 
A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...
A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...
A fault tolerant tokenbased atomic broadcast algorithm relying on responsive ...
 
Design pattern-presentation
Design pattern-presentationDesign pattern-presentation
Design pattern-presentation
 
Introduction to Java Enterprise Edition
Introduction to Java Enterprise EditionIntroduction to Java Enterprise Edition
Introduction to Java Enterprise Edition
 
critical section problem.pptx
critical section problem.pptxcritical section problem.pptx
critical section problem.pptx
 

Kürzlich hochgeladen

9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
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 ImpactPECB
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
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 . pdfQucHHunhnh
 
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 .pdfchloefrazer622
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
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 13Steve Thomason
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
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. Mahajanpragatimahajan3
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 

Kürzlich hochgeladen (20)

9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
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
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
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
 
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
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
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
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
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...
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
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
 
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
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 

Operating System Process Synchronization

  • 1. ACKNOWLEDGEMENT We have no words to express our deepest gratitude to ALLAH who blessed and enabled us to complete this project. Its great privilege to mention the feelings of obligations towards our affectionate parents and department, who prayed, encouraged and inspired us for higher education and are supporting financially and morally throughout our studies. We find it very difficult to select the appropriate words to express our gratitude to our teacher Prof. Umar and his useful encouragement and dynamic supervision. Course Instructor: -----------------------------------
  • 2. DECLARATION We hereby declare that this project report entitled “Process Synchronization” is written by us and is our own effort and that no part has been copied and taken from any other source. Submitted by Signature with Date Haziq Naeem (107) ---------------------------------------- Muhammad Adeel (83) ----------------------------------------
  • 3. TABLE OF CONTENTS Sr# Contents Page# 1 Introduction 1 2 Synchronization 2 2.1 Critical Section Problem 2 2.2 Locks 4 2.3 Petersons Solution 5 2.4 Semaphores 5 2.5 Major Problems of Synchronization 6 3 Windows vs Linux Synchronization 8 4 Activity Chart 9 5 Conclusion 9 6 References 9
  • 4. FIGURES TABLE Fig# Contents Page# 1 Synchronization 1 2 Synchronization 2 3 Critical Section Problem 3 4 Locks 4 5 Petersons Solution 5 6 Major Problems of Synchronization 7 7 Major Problems of Synchronization 7 8 Major Problems of Synchronization 8 9 Activity Chart 9
  • 5. 1. Introduction Synchronization is the mutual understanding between two processes or more. In simple words synchronization means sharing system resources. i.e. Track of a train, they are mutually synchronized with each other. 2. Synchronization Access to two or more processes to share data can result in data inconsistency. for this a mechanism is used called “Synchronization”. Synchronization is the mutual understanding between two processes or more. In simple words synchronization means sharing system resources. i.e. Track of a train, they are mutually synchronized with each other.
  • 6. (Figure 1) Example: Synchronizing Traffic In a one way tunnel the tunnel can only be used when no oncoming traffic is present and when the traffic is already flowing in the right way.
  • 7. (Figure 2) Problems:  Deadlock: Two or more than two process waiting for an event  Starvation: Indefinite blocking. Process that required resource which is never allocated. 2.1. Critical SectionProblem Only one process executed at a time in critical section. Only one process is allowed to start or execute in its critical section. So every process 1st request permission to entering in critical section. Three section involved in critical section: i. Entering Section ii. Exit Section iii. Remainder Section If one process started working, other processes will have to wait until first will finished. (Figure 3) We discuss the critical section problem now we will discuss the solution of critical section problem. Solutions of Critical Section Problem:
  • 8. Three kinds of solutions involved in critical section problem i. Mutual Exclusion ii. Progress iii. Bounded Waiting i. Mutual Exclusion One processes execute no other process will interfere in it. For example, if a process named A1 and other Process named A2. If A1 executes in its critical section, then A2 not allowed to interfere in it. ii. Progress If no process executed in its critical section, then those process only requested to execute in its critical section which are in remainder section and the rest are placed in queue. iii. Bounded Waiting When a process makes request or a process request granted to enter in a critical section then a limit or bound exists on the number of times that the other processes are allowed to enter its critical section. For example, a process AB requested to enter in its critical section bounded waiting restricted that this process enter only two times in its critical section after request made and before request granted to its critical section Another example of bounded waiting is the limits of downloading on websites 2.2. Locks Lock means to prevent someone to do something. Any solution to critical section problem requires some form of lock. Acquire: Before entering its critical section Release: After exits the critical section A software tool is built for this known as “Mutex Lock”. Also known as spin lock.
  • 9. (Figure 4) Synchronization Hardware: Many systems provide the support of hardware for critical section.  Uniprocessors can disable interrupts: System clock kept updated by interrupts  Modern machines are non-interrupt able: Allow us to test and modify content of a word or to swap contents of two words. 2.3. Peterson’s Solution It is a software based solution to critical section problem.  Provides good algorithm description of solving.  Describe the complexities in designing software (three critical section solutions).  Could not be work on modern non-interrupt able machines. The solution is for two processes. Load and store instructions are non-interrupt able.
  • 10. (Figure 5) 2.4. Semaphores Semaphores is a variable that is used to manage or control access to a common resource by multiple processes in a similar or concurrent system. It is basically a synchronization tool. Two operations are involved in it. Wait and Signal represented as P() and V(). Wait: increasing the value of its arguments as soon as it will become non minus Signal: decreasing the value of its arguments as an individual operation Properties:  It is very simple  Works with many processes  Each critical section has different semaphores  Can have same critical section with same semaphores Types of semaphores: i. Counting Semaphores ii. Binary Semaphores i. Binary Semaphores It is a type of semaphores used to implement bounded concurrency The value of binary semaphores can only range from 0 to 1. ii. Counting Semaphores A type of semaphores which is also known as mutex. It is used to implement mutual exclusion value of counting semaphores over an unrestricted range. For example Bank account 2.5. MajorProblems of Synchronization There are three major problems of synchronization
  • 11. i. Bound Buffer Problems ii. Reader-Writer Problem iii. Dinning Philosophers Problem i. Bound Buffer Problem In bound buffer there are two concepts involved. Producer and consumer This problem explains these two processes which share common buffer used as a queue. Producer produce the data take it into the buffer and again started Whereas Consumer delete or remove data one by one If buffer is full then more data can’t be stored and consumer not able to remove data from an empty buffer. The solution for producer is to discard data or go to sleep if the buffer is full. If consumer removes something into the buffer, then notifies the producer will start again to fill the buffer. Now for consumer, if consumer finds buffer empty then it can go to sleep. When producer puts any data in buffer the consumer awakes. The solution of this problem is semaphores and improper solution will result as a deadlock. ii. Readers-Writers Problem Readers: Don’t perform any updates only read the data Writers: Performing both reading and writing Problem is that multiple readers to read the data but only one writer can access data at that time. iii. Dining Philosophers Problems Invented by E.W. Dijkstra. Problem: Imagine there are five philosophers who only eat and think. They are sitting on a circular table to eat spaghetti and have only five chopsticks to eat. Each philosopher thins and when he felt hungry he picks up chopsticks and eat spaghetti, after finish eating he puts down the chopsticks and starts to think again.
  • 12. (Figure 6) Analysis of problem: (Figure 7) Solution:
  • 13. (Figure 8) 3. Windows vs Linux Synchronization Windows Linux Uses interrupts to protect access to global resources on unipolar systems Disables interrupts to implement short critical sections Provides dispatcher objects which may act as semaphores Provides semaphores Uses spin locks on multiprocessor systems Provides spin locks 4. Activity Chart
  • 14. (Figure 9) 5. Conclusion Synchronization is a mechanism for the mutual understanding between two or more processes. It Includes critical section problems, locks, Peterson’s solution, semaphores and major problems of synchronization. As very thing has positive and negative sights, synchronization has more positive ones. It is a major technique / mechanism used in the operating systems. It gives access to prevent from deadlocks and starvation, due to this mechanism the data integrity and consistency increases, it collaborates data and improve the efficiency of the work. 6. References Critical Section: http://web.stanford.edu/class/cs140/cgi-bin/lecture.php?topic=locks https://cseweb.ucsd.edu/classes/fa05/cse120/lectures/120-l5.pdf Semaphores: https://en.wikipedia.org/wiki/Semaphore_(programming) http://www.personal.kent.edu/~rmuhamma/OpSystems/Myos/semaphore.htm https://en.wikibooks.org/wiki/Operating_System_Design/Processes/Semaphores Dining Philosophers Problems: https://www.cs.mtu.edu/~shene/NSF-3/e-Book/MUTEX/TM-example-philos-1.html Locks: http://cse.stfx.ca/~mlin/cs375/lectures/syn3.ppt Imp of Sync: http://users.csc.calpoly.edu/~fkurfess/Courses/COMP-346/W00/Slides/05-ProcSync.ppt