Os Presentation
Os Presentation
Os Presentation
Classical Problems of
Synchronization
Our Team
Qurat-ul-Ain
Muzamil Khan Touseef AQ
Fa-17/BSCS/019 Fa-17/BSCS/297
Fa-17/BSCS/127
Leader
Agenda
01 Process Synchronization
Process 1 Process 3
Process 2
Classical problems of
Synchronization
Classical Problems
8
Bounded-Buffer Problem
Also Known as producer/consumer problem
Participants
Produces
Producer Buffer
Bounded-Buffer Problem
Without Synchronization
Also Known as producer/consumer problem
Buffer
Producer Consumer
Bounded-Buffer Problem
Without Synchronization 2 2 10
(Preemptive)
Also Known as producer/consumer problem
Counter
Produces Consumes
Mutex = 1
Wait(empty) Signal(full)
Wait(Mutex) Signal(Mutex)
Infinite loop
Mutex = 1
Classical Problem 2:
?
M3
Now everyone is waiting for right fork.
y ?
Wh
M1
?
Deadlock
M0 M3
Dining Table
Solution?
M0 M1 M2 M3 M4
How? 1 1 1 1 1
Mutex --
Signal(Mi)
Wait(fork(Mi)
Wait(fork(Mi+1%N) Signal(Mi+1%5)
Remainder Section
Mi<=0 Critical Section
Infinite loop
Int M[5];
Problem 03:
Reader Writer's Problem
A file is to be shared among several concurrent
processes. Some of these processes, called readers,
may want only to read whereas others, called writers, No reader will be kept waiting unless a writer has
may want to update the shared file. already obtained permission to use the shared
object
Wait(mutex) Wait(mutex)
Readcount++ Readcount--
Reading/W
Wait(wrt) Signal (wrt)
riting
If (Readcount ==1) If (Readcount ==0)
Critical Section
Wait(wrt) Signal (wrt)
Signal(mutex) Signal (mutex)
THANK YOU