You are on page 1of 14

1

Lahore Garrison University


CSC351-Operating System
Lecture-10
Fall 2023
2
Text Book

 Operating system concepts by Abraham


Silberschatz, Galvin, Gagne, 9th edition

Lahore Garrison University


3

►Multilevel Queue
►Multilevel Feedback Queue
►Thread Scheduling
►Multiprocessor Scheduling
Preamble (Past ►Multi Core

lesson brief) ►OS Examples

Lahore Garrison University


4
Chapter 5

 Process Synchronization

Lahore Garrison University


5
Process Synchronization

 On the basis of synchronization, processes are categorized as one of the


following two types:
 Independent Process : Execution of one process does not affects the
execution of other processes.
 Cooperative Process : Execution of one process affects the execution of
other processes.
 They may share
 Variable
 Memory (buffer)
 Code
 Resources (CPU, Printer, Scanners)

Process synchronization problem arises in the case of Cooperative process also


Lahorebecause resources are shared in Cooperative processes.
Garrison University
6
Process Synchronization

 Example: for sharing a variable


Int shared = 5;

P1 P2
Int x= shared; Int y= shared;

x++; y--;
sleep(1); sleep(1);

shared = x; shared = y;
7
Race Condition

 When more than one processes are executing the same code or
accessing the same memory or any shared variable in that
condition there is a possibility that the output or the value of the
shared variable is wrong so for that all the processes doing race to
say that my output is correct this condition known as
race condition.
 Several processes access and process the manipulations over the
same data concurrently, then the outcome depends on the
particular order in which the access takes place.

Lahore Garrison University


8
Critical Section

 It is part of program where shared resources are accessed by various


processes

Lahore Garrison University


9
Mutual Exclusion

 P2 also wants to enter the same time then


P2 will not be allowed to enter while P1
is in CS. Its like a lock.

Shared Data

Critical Section
P1

Lahore Garrison University


10
Progress

 P1 is not interested to enter in the critical section but its also


stopping P2 to enter in critical section
 It can be done by mistake or intentionally
 P1 is not progressing nor letting P2 to progress
 So no process is in critical section no progress
 P1 must progress and also let P2

Critical Section

Lahore Garrison University


11
Bounded Waiting

P1
Critical Section

 P1 P2
 1 0
 2 0
 3 0
 . 0
 .
 .
 .
 Infinite
 Then it’s a kind of starvation. there must not be unbounded waiting.
Lahore Garrison University
12
No assumption related to H/W
speed

 Solution should not be hardware dependent


 It must be portable

Lahore Garrison University


13
Synchronization Mechanism

Lahore Garrison University


14
Reference

 To cover this topics , different reference material has been used


for consultation.
 Operating systems concept by Abraham silberchatz edition 9
 Tutorialspoint.com
 Google.com

Lahore Garrison University

You might also like