SlideShare a Scribd company logo
1 of 32
Processes Types
The two types of processes are
 Cooperating Processes
 Can affect or be affected by the execution of another
process
 A process that shares data with other processes or share a
logical address space.
 Independent Processes
 Cannot affect or be affected by the execution of another
process
 A process that does not share data.
 The best example to see the cooperation
between two processes is Producer Consumer
problem.
 It is also known as the bounded-buffer
problem.
 The problem contains two processes:
 the producer and the consumer.
 Both processes share a common, fixed-size
buffer used as a queue.
 Producer produces and consumer consumes.
 Types
Unbounded-buffer:
◦ No practical limit on the size of the buffer
◦ Consumer may wait, producer never waits
Bounded-buffer:
◦ Assumes that there is a fixed buffer size
◦ Consumer waits for new item, producer waits if buffer
is full.
Race Conditions:
The situation where several processes access and
manipulate shared data concurrently and the out
come of execution depends on the particular order
in which the access takes place are called race
conditions
Critical Section (CS)
 Each process has a code segment, called critical
section, in which the shared data is accessed.
 When one process is executing in the critical
section, no other process is to be allowed in its
critical section. This is the problem of Critical
Section Problem.
Types of Section:
 Each process must request permission to enter its critical
section.
1. Entry Section(ES)
 Section of code implementing the request permission to
enter the critical section.
2. Exit Section (LS)
 Section of code to leave the critical section which follows
Entry Section.
3. Remainder Section(RS)
 Remaining code of the process after the critical section.
Structure of process Pi
do {
entrysection
Criticalsection
exit section
Remaindersection
} while(1);
1.Mutual Exclusion
 If process Pi is executing in its critical section,
then no other processes can be executing in their
critical sections
2. Progress
 If no process is executing in its critical section
and there exist some processes that wish to
enter their critical section, then the selection of
the processes that will enter the critical section
next cannot be postponed indefinitely
◦ If only one process wants to enter, it should be able to
◦ If two or more want to enter, one of them should
succeed
3. Bounded Waiting :
 A bound must exist on the number of times that
other processes are allowed to enter their
critical sections after a process has made a
request to enter its critical section and before
that request is granted.
 Mutex is short for Mutual exclusion
 Mutex lock is used to solve the critical-section
problem
 Used to ensure exclusive access to data shared
between threads
 Used to protect critical regions and thus prevent
race conditions
 Illustration
 A process must acquire the lock before entering a
critical section using acquire () function releases
the lock when it exits the critical section using
release() function
SEMOPHORES:
 Semaphore is a synchronization tool
(provided by the OS) that does not require
busy waiting .
 Semaphore is a variable that has an integer
value
 May be initialized to a non negative number
 Wait operation decrements the semaphore value
 Signal operation increments semaphore value
 A semaphore S is an integer variable that
,apart from initialization ,can only be accessed
through 2 atomic and mutually exclusive
operations:
 wait(S)-Originally called P(), from Dutch proberen―to test.
 signal(S) -Originally called V(), from Dutch verhogen ―to
increment.
 Wait and Signal Operations
 Busy-waiting implementation of these in divisible (atomic)
operations:
wait(S)
{
while(S <=0 )
;
S--;
}
signal(S)
{
S++;
}
Usage of Semaphore:
 Two or more processes can cooperate by means of simple
signals such that a process can be forced to stop at a
specified place until it has received a specified signal.
Usage1:Critical Section of n Processes Problem
Shared data
Semaphore mutex;
Structure of Process Pi
do {
wait(mutex);
critical section
signal(mutex);
Remainder section
}while(1);
 Usage2: synchronization of 2 processes
inserting the following statements inP1
s1;signal(mutex);
and the following statements in P2
wait(mutex)s2;
 Deadlock is a situation that occurs when two
processes are waiting for the other to complete
before proceeding
 Types of Deadlock
 Process Deadlock
 A process is deadlocked when it is waiting on an event which will
never happen
 System Deadlock
 A system is deadlocked when one or more processes are
deadlocked
 System consists of resources
 Resource types :
1.Reusable - Processor, memory space, I/O devices
2.Consumable – interrupts,messages
 Each resource type Ri has Wi instances.
 Each process utilizes a resource in sequence:
◦ request
◦ use
◦ release
 Mutual exclusion: only one process at a time can
use a resource
 Hold and wait: a process holding at least one
resource is waiting to acquire additional resources
held by other processes
 No preemption: a resource can be released only
voluntarily by the process holding it, after that
process has completed its task
Deadlock can arise if four conditions hold simultaneously.
 Circular wait: there exists a set {P0, P1,
…, Pn} of waiting processes such that P0
is waiting for a resource that is held by
P1, P1 is waiting for a resource that is
held by P2, …, Pn–1 is waiting for a
resource that is held by Pn, and Pn is
waiting for a resource that is held by P0.
 V is partitioned into two types:
◦ P = {P1, P2, …, Pn}, the set consisting of all the
processes in the system
◦ R = {R1, R2, …, Rm}, the set consisting of all
resource types in the system
 request edge – directed edge Pi  Rj
 assignment edge – directed edge Rj  Pi
A set of vertices V and a set of edges E.
 Process
 Resource Type with 4 instances
 Request edge : Pi requests instance of Rj
 Claim edge : Pi is holding an instance of Rj
Pi
Pi
Rj
Rj
◦ Deadlock prevention-remove possibility of
deadlock occurring
◦ Deadlock avoidance – Identifying safe and
unsafe states
◦ Deadlock detection
◦ Deadlock recovery
 Mutual Exclusion – not required for sharable
resources (e.g., read-only files); must hold for
non-sharable resources
 Hold and Wait – must guarantee that whenever
a process requests a resource, it does not hold
any other resources
Restrain the ways request can be made
 No Preemption –
◦ If a process that is holding some resources
requests another resource that cannot be
immediately allocated to it, then all resources
currently being held are released
 Circular Wait – impose a total ordering of all
resource types, and require that each process
requests resources in an increasing order of
enumeration
 Resource-allocation state is defined by
the number of available and allocated
resources, and the maximum demands
of the processes
 When a process requests an available resource, system
must decide if immediate allocation leaves the system
in a safe state
 System is in safe state if there exists a sequence <P1,
P2, …, Pn> of ALL the processes in the systems such
that for each Pi, the resources that Pi can still request
can be satisfied by currently available resources +
resources held by all the Pj, with j < I
 If a system is in safe state  no
deadlocks
 If a system is in unsafe state 
possibility of deadlock
 Avoidance  ensure that a system
will never enter an unsafe state.
OS UNIT3.pptx

More Related Content

Similar to OS UNIT3.pptx

Mch7 deadlock
Mch7 deadlockMch7 deadlock
Mch7 deadlock
wahab13
 
Lecture 5- Process Synchonization_revised.pdf
Lecture 5- Process Synchonization_revised.pdfLecture 5- Process Synchonization_revised.pdf
Lecture 5- Process Synchonization_revised.pdf
Amanuelmergia
 

Similar to OS UNIT3.pptx (20)

Operating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresOperating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphores
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
 
Os unit 4
Os unit 4Os unit 4
Os unit 4
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Deadlock and Banking Algorithm
Deadlock and Banking AlgorithmDeadlock and Banking Algorithm
Deadlock and Banking Algorithm
 
deadlocks.pptx
deadlocks.pptxdeadlocks.pptx
deadlocks.pptx
 
Mch7 deadlock
Mch7 deadlockMch7 deadlock
Mch7 deadlock
 
process syn.ppt
process syn.pptprocess syn.ppt
process syn.ppt
 
OSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptxOSLec14&15(Deadlocksinopratingsystem).pptx
OSLec14&15(Deadlocksinopratingsystem).pptx
 
Lecture 9 - Process Synchronization.pptx
Lecture 9 - Process Synchronization.pptxLecture 9 - Process Synchronization.pptx
Lecture 9 - Process Synchronization.pptx
 
Lecture 5- Process Synchonization_revised.pdf
Lecture 5- Process Synchonization_revised.pdfLecture 5- Process Synchonization_revised.pdf
Lecture 5- Process Synchonization_revised.pdf
 
Ch 4 deadlock
Ch 4 deadlockCh 4 deadlock
Ch 4 deadlock
 
Deadlock
DeadlockDeadlock
Deadlock
 
Gp1242 007 oer ppt
Gp1242 007 oer pptGp1242 007 oer ppt
Gp1242 007 oer ppt
 
7308346-Deadlock.pptx
7308346-Deadlock.pptx7308346-Deadlock.pptx
7308346-Deadlock.pptx
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
OS 7.pptx
OS 7.pptxOS 7.pptx
OS 7.pptx
 
Bankers
BankersBankers
Bankers
 
deadlock in OS.pptx
deadlock in OS.pptxdeadlock in OS.pptx
deadlock in OS.pptx
 

More from DHANABALSUBRAMANIAN (15)

unit 2.ppt
unit 2.pptunit 2.ppt
unit 2.ppt
 
Unit --3.ppt
Unit --3.pptUnit --3.ppt
Unit --3.ppt
 
Unit 4.ppt
Unit 4.pptUnit 4.ppt
Unit 4.ppt
 
Unit 1.ppt
Unit 1.pptUnit 1.ppt
Unit 1.ppt
 
Unit -- 5.ppt
Unit -- 5.pptUnit -- 5.ppt
Unit -- 5.ppt
 
Unit 3.ppt
Unit 3.pptUnit 3.ppt
Unit 3.ppt
 
Unit 5.ppt
Unit 5.pptUnit 5.ppt
Unit 5.ppt
 
Unit - 5.ppt
Unit - 5.pptUnit - 5.ppt
Unit - 5.ppt
 
Unit - 3.ppt
Unit - 3.pptUnit - 3.ppt
Unit - 3.ppt
 
unit -1.ppt
unit -1.pptunit -1.ppt
unit -1.ppt
 
Unit -2.ppt
Unit -2.pptUnit -2.ppt
Unit -2.ppt
 
OS UNIT1.pptx
OS UNIT1.pptxOS UNIT1.pptx
OS UNIT1.pptx
 
OS UNIT2.ppt
OS UNIT2.pptOS UNIT2.ppt
OS UNIT2.ppt
 
OS Unit5.pptx
OS Unit5.pptxOS Unit5.pptx
OS Unit5.pptx
 
OS UNIT4.pptx
OS UNIT4.pptxOS UNIT4.pptx
OS UNIT4.pptx
 

Recently uploaded

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
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).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
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 

OS UNIT3.pptx

  • 1.
  • 2. Processes Types The two types of processes are  Cooperating Processes  Can affect or be affected by the execution of another process  A process that shares data with other processes or share a logical address space.  Independent Processes  Cannot affect or be affected by the execution of another process  A process that does not share data.
  • 3.  The best example to see the cooperation between two processes is Producer Consumer problem.  It is also known as the bounded-buffer problem.  The problem contains two processes:  the producer and the consumer.  Both processes share a common, fixed-size buffer used as a queue.  Producer produces and consumer consumes.
  • 4.  Types Unbounded-buffer: ◦ No practical limit on the size of the buffer ◦ Consumer may wait, producer never waits Bounded-buffer: ◦ Assumes that there is a fixed buffer size ◦ Consumer waits for new item, producer waits if buffer is full. Race Conditions: The situation where several processes access and manipulate shared data concurrently and the out come of execution depends on the particular order in which the access takes place are called race conditions
  • 5. Critical Section (CS)  Each process has a code segment, called critical section, in which the shared data is accessed.  When one process is executing in the critical section, no other process is to be allowed in its critical section. This is the problem of Critical Section Problem.
  • 6. Types of Section:  Each process must request permission to enter its critical section. 1. Entry Section(ES)  Section of code implementing the request permission to enter the critical section. 2. Exit Section (LS)  Section of code to leave the critical section which follows Entry Section. 3. Remainder Section(RS)  Remaining code of the process after the critical section.
  • 7. Structure of process Pi do { entrysection Criticalsection exit section Remaindersection } while(1);
  • 8. 1.Mutual Exclusion  If process Pi is executing in its critical section, then no other processes can be executing in their critical sections 2. Progress  If no process is executing in its critical section and there exist some processes that wish to enter their critical section, then the selection of the processes that will enter the critical section next cannot be postponed indefinitely ◦ If only one process wants to enter, it should be able to ◦ If two or more want to enter, one of them should succeed
  • 9. 3. Bounded Waiting :  A bound must exist on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted.
  • 10.  Mutex is short for Mutual exclusion  Mutex lock is used to solve the critical-section problem  Used to ensure exclusive access to data shared between threads  Used to protect critical regions and thus prevent race conditions
  • 11.  Illustration  A process must acquire the lock before entering a critical section using acquire () function releases the lock when it exits the critical section using release() function
  • 12. SEMOPHORES:  Semaphore is a synchronization tool (provided by the OS) that does not require busy waiting .  Semaphore is a variable that has an integer value  May be initialized to a non negative number  Wait operation decrements the semaphore value  Signal operation increments semaphore value
  • 13.  A semaphore S is an integer variable that ,apart from initialization ,can only be accessed through 2 atomic and mutually exclusive operations:  wait(S)-Originally called P(), from Dutch proberen―to test.  signal(S) -Originally called V(), from Dutch verhogen ―to increment.  Wait and Signal Operations  Busy-waiting implementation of these in divisible (atomic) operations: wait(S) { while(S <=0 ) ; S--; }
  • 15. Usage of Semaphore:  Two or more processes can cooperate by means of simple signals such that a process can be forced to stop at a specified place until it has received a specified signal. Usage1:Critical Section of n Processes Problem Shared data Semaphore mutex; Structure of Process Pi do { wait(mutex); critical section signal(mutex); Remainder section }while(1);
  • 16.  Usage2: synchronization of 2 processes inserting the following statements inP1 s1;signal(mutex); and the following statements in P2 wait(mutex)s2;
  • 17.  Deadlock is a situation that occurs when two processes are waiting for the other to complete before proceeding  Types of Deadlock  Process Deadlock  A process is deadlocked when it is waiting on an event which will never happen  System Deadlock  A system is deadlocked when one or more processes are deadlocked
  • 18.  System consists of resources  Resource types : 1.Reusable - Processor, memory space, I/O devices 2.Consumable – interrupts,messages  Each resource type Ri has Wi instances.  Each process utilizes a resource in sequence: ◦ request ◦ use ◦ release
  • 19.  Mutual exclusion: only one process at a time can use a resource  Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by other processes  No preemption: a resource can be released only voluntarily by the process holding it, after that process has completed its task Deadlock can arise if four conditions hold simultaneously.
  • 20.  Circular wait: there exists a set {P0, P1, …, Pn} of waiting processes such that P0 is waiting for a resource that is held by P1, P1 is waiting for a resource that is held by P2, …, Pn–1 is waiting for a resource that is held by Pn, and Pn is waiting for a resource that is held by P0.
  • 21.  V is partitioned into two types: ◦ P = {P1, P2, …, Pn}, the set consisting of all the processes in the system ◦ R = {R1, R2, …, Rm}, the set consisting of all resource types in the system  request edge – directed edge Pi  Rj  assignment edge – directed edge Rj  Pi A set of vertices V and a set of edges E.
  • 22.  Process  Resource Type with 4 instances  Request edge : Pi requests instance of Rj  Claim edge : Pi is holding an instance of Rj Pi Pi Rj Rj
  • 23.
  • 24.
  • 25.
  • 26. ◦ Deadlock prevention-remove possibility of deadlock occurring ◦ Deadlock avoidance – Identifying safe and unsafe states ◦ Deadlock detection ◦ Deadlock recovery
  • 27.  Mutual Exclusion – not required for sharable resources (e.g., read-only files); must hold for non-sharable resources  Hold and Wait – must guarantee that whenever a process requests a resource, it does not hold any other resources Restrain the ways request can be made
  • 28.  No Preemption – ◦ If a process that is holding some resources requests another resource that cannot be immediately allocated to it, then all resources currently being held are released  Circular Wait – impose a total ordering of all resource types, and require that each process requests resources in an increasing order of enumeration
  • 29.  Resource-allocation state is defined by the number of available and allocated resources, and the maximum demands of the processes
  • 30.  When a process requests an available resource, system must decide if immediate allocation leaves the system in a safe state  System is in safe state if there exists a sequence <P1, P2, …, Pn> of ALL the processes in the systems such that for each Pi, the resources that Pi can still request can be satisfied by currently available resources + resources held by all the Pj, with j < I
  • 31.  If a system is in safe state  no deadlocks  If a system is in unsafe state  possibility of deadlock  Avoidance  ensure that a system will never enter an unsafe state.