0% found this document useful (0 votes)
89 views107 pages

Unit3 Process Management

The document is a collection of pages prepared by Narayan Dhamala about operating system concepts such as process hierarchy, process scheduling, and different scheduling algorithms. It discusses process hierarchy in Unix systems and how processes interact. It also covers types of scheduling like preemptive, non-preemptive, batch, interactive and real-time. Specific scheduling algorithms described include lottery scheduling, shortest job next, and fair share scheduling.

Uploaded by

Desire Maharjan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views107 pages

Unit3 Process Management

The document is a collection of pages prepared by Narayan Dhamala about operating system concepts such as process hierarchy, process scheduling, and different scheduling algorithms. It discusses process hierarchy in Unix systems and how processes interact. It also covers types of scheduling like preemptive, non-preemptive, batch, interactive and real-time. Specific scheduling algorithms described include lottery scheduling, shortest job next, and fair share scheduling.

Uploaded by

Desire Maharjan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 107

BCA

Fourth Semester
“ Operating System“

Prepared by :Narayan Dhamala 1


Unit III

Prepared by: Narayan Dhamala 2


Unit III

Prepared by: Narayan Dhamala 3


Unit III

Prepared by: Narayan Dhamala 4


Prepared by : Narayan Dhamala 5
Prepared by: Narayan Dhamala 6
Prepared by: Narayan Dhamala 7
Prepared by : Narayan Dhamala 8
Prepared by: Narayan Dhamala 9
Prepared by: Narayan Dhamala 10
Prepared by: Narayan Dhamala 11
Process Hierarchy
 In some computer systems when a process creates another process, the
n the parent process and child process continue to be associated in cert
ain ways. The child process can itself creates more processes that forms
a process hierarchy.
 In Unix system, a process group formed by a process and all of its childr
en and further descendants.
 Whenever a computer user sends a signal from the keyboard, that signa
l is then delivered to all the members of the process group that are curr
ently associated with the keyboard.
 Individually, each process can catch the signal, ignore the signal, or tak
e the default action, windows systems doesn't have any concept of a pro
cess hierarchy.
 Since each process is an independent entity with its own program coun
ter and internal state, processes sometime need to interact with other p
rocesses.
 Sometime, a process may generate some output that is used by some ot
her process as their input.
Prepared by: Narayan Dhamala 12
Prepared by: Narayan Dhamala 13
Prepared by: Narayan Dhamala 14
Prepared by: Narayan Dhamala 15
Prepared by: Narayan Dhamala 16
Prepared by: Narayan Dhamala 17
Prepared by: Narayan Dhamala 18
Prepared by: Narayan Dhamala 19
Prepared by: Narayan Dhamala 20
Prepared by: Narayan Dhamala 21
Prepared by: Narayan Dhamala 22
Prepared by: Narayan Dhamala 23
Prepared by: Narayan Dhamala 24
Prepared by: Narayan Dhamala 25
Prepared by: Narayan Dhamala 26
Prepared by: Narayan Dhamala 27
Prepared by: Narayan Dhamala 28
Prepared by: Narayan Dhamala 29
Prepared by: Narayan Dhamala 30
Prepared by: Narayan Dhamala 31
Prepared by: Narayan Dhamala 32
Prepared by: Narayan Dhamala 33
Prepared by: Narayan Dhamala 34
Prepared by: Narayan Dhamala 35
Prepared by: Narayan Dhamala 36
Prepared by: Narayan Dhamala 37
Prepared by: Narayan Dhamala 38
Prepared by: Narayan Dhamala 39
Prepared by: Narayan Dhamala 40
Prepared by: Narayan Dhamala 41
Prepared by: Narayan Dhamala 42
Prepared by: Narayan Dhamala 43
Prepared by: Narayan Dhamala 44
Prepared by: Narayan Dhamala 45
Prepared by: Narayan Dhamala 46
Prepared by: Narayan Dhamala 47
Prepared by: Narayan Dhamala 48
Prepared by: Narayan Dhamala 49
Prepared by: Narayan Dhamala 50
Prepared by: Narayan Dhamala 51
Prepared by: Narayan Dhamala 52
Prepared by: Narayan Dhamala 53
Prepared by: Narayan Dhamala 54
Prepared by: Narayan Dhamala 55
Prepared by: Narayan Dhamala 56
Prepared by: Narayan Dhamala 57
Prepared by: Narayan Dhamala 58
Prepared by: Narayan Dhamala 59
Prepared by: Narayan Dhamala 60
Prepared by: Narayan Dhamala 61
Prepared by: Narayan Dhamala 62
Prepared by: Narayan Dhamala 63
Prepared by: Narayan Dhamala 64
Prepared by: Narayan Dhamala 65
Prepared by: Narayan Dhamala 66
Prepared by: Narayan Dhamala 67
Prepared by: Narayan Dhamala 68
Prepared by: Narayan Dhamala 69
Prepared by: Narayan Dhamala 70
Process Scheduling Introduction
Process scheduling is the activity of the process manag
er that handles the removal of the running process fro
m the CPU and the selection of another process on the
basis of a particular strategy.

Prepared by: Narayan Dhamala 71


Types of Scheduling
Preemptive
Non-preemptive
Batch
Interactive
Real time

Prepared by: Narayan Dhamala 72


Types of Scheduling Contd..
Non-preemptive
 Once a process has been given the CPU, it runs until bl
ocks for I/O or termination.
 Treatment of all processes is fair.
 Response times are more predictable.
 Useful in real-time system.
 Shorts jobs are made to wait by longer jobs - no priorit
y

Prepared by: Narayan Dhamala 73


Types of Scheduling Contd..
Preemptive
 Processes are allowed to run for a maximum of some
fixed time.
 Useful in systems in which high-priority processes re
quires rapid attention.
 In timesharing systems, preemptive scheduling is im
portant in guaranteeing acceptable response times.
 High overhead.

Prepared by: Narayan Dhamala 74


Types of Scheduling Contd..
Batch System

Prepared by: Narayan Dhamala 75


Types of Scheduling Contd..
Interactive

Prepared by: Narayan Dhamala 76


Types of Scheduling Contd..
Real Time

Prepared by: Narayan Dhamala 77


Some goals of Scheduling algorithm

Prepared by: Narayan Dhamala 78


Prepared by: Narayan Dhamala 79
Prepared by: Narayan Dhamala 80
Prepared by: Narayan Dhamala 81
Prepared by: Narayan Dhamala 82
Prepared by: Narayan Dhamala 83
Prepared by: Narayan Dhamala 84
Prepared by: Narayan Dhamala 85
Prepared by: Narayan Dhamala 86
Prepared by: Narayan Dhamala 87
Prepared by: Narayan Dhamala 88
Prepared by: Narayan Dhamala 89
Prepared by: Narayan Dhamala 90
Prepared by: Narayan Dhamala 91
Prepared by: Narayan Dhamala 92
Prepared by: Narayan Dhamala 93
Prepared by: Narayan Dhamala 94
Prepared by: Narayan Dhamala 95
Prepared by: Narayan Dhamala 96
Prepared by: Narayan Dhamala 97
Lottery Scheduling
Lottery scheduling is a probabilistic scheduling algorithm  for p
rocesses in an operating system.
Processes are each assigned some number of lottery tickets, and t
he scheduler draws a random ticket to select the next process.
 The distribution of tickets need not be uniform; granting a proce
ss more tickets provides it a relative higher chance of selection. T
his technique can be used to approximate other scheduling algori
thms, such as Shortest Job next and Fair Share Scheduling.
Lottery scheduling solves the problem of Starvation.
 Giving each process at least one lottery ticket guarantees that it h
as non-zero probability of being selected at each scheduling oper
ation.

Prepared by: Narayan Dhamala 98


Shortest Job Next Scheduling
Shortest job next (SJN), also known as shortest job first (SJF)
or shortest process next (SPN), is a scheduling policy that sele
cts for execution the waiting process with the smallest execution
time.
 SJN is a non-preemptive algorithm. Shortest Remaining Time is
a preemptive variant of SJN.
Shortest job next is advantageous because of its simplicity and b
ecause it minimizes the average amount of time each process has
to wait until its execution is complete.
 However, it has the potential for process starvation for processes
which will require a long time to complete if short processes are
continually added. Highest Response Ration Next is similar but p
rovides a solution to this problem using a technique called aging.
Prepared by: Narayan Dhamala 99
Shortest Job Next Scheduling Contd..
Another disadvantage of using shortest job next is that t
he total execution time of a job must be known before ex
ecution. While it is impossible to predict execution time
perfectly, several methods can be used to estimate it, suc
h as a weighted average of previous execution times.[3]
Shortest job next can be effectively used with interactive
processes which generally follow a pattern of alternating
between waiting for a command and executing it. If the
execution burst of a process is regarded as a separate "jo
b", past behavior can indicate which process to run next,
based on an estimate of its running time.

Prepared by: Narayan Dhamala 100


Fair Share Scheduling
Fair-share scheduling is a scheduling algorithm for c
omputer Operating systems in which the CPU usage is
equally distributed among system users or groups, as o
pposed to equal distribution among processes.
One common method of logically implementing the f
air-share scheduling strategy is to recursively apply the
 round robin scheduling strategy at each level of abstra
ction (processes, users, groups, etc.) The time quantu
m required by round-robin is arbitrary, as any equal di
vision of time will produce the same results.

Prepared by: Narayan Dhamala 101


Fair Share Scheduling
For example, if four users (A,B,C,D) are concurrently executing one process each, the
scheduler will logically divide the available CPU cycles such that each user gets 25%
of the whole (100% / 4 = 25%). If user B starts a second process, each user will still re
ceive 25% of the total cycles, but each of user B's processes will now be attributed 1
2.5% of the total CPU cycles each, totaling user B's fair share of 25%. On the other ha
nd, if a new user starts a process on the system, the scheduler will reapportion the a
vailable CPU cycles such that each user gets 20% of the whole (100% / 5 = 20%).
Another layer of abstraction allows us to partition users into groups, and apply the fa
ir share algorithm to the groups as well. In this case, the available CPU cycles are divi
ded first among the groups, then among the users within the groups, and then amon
g the processes for that user. For example, if there are three groups (1,2,3) containin
g three, two, and four users respectively, the available CPU cycles will be distributed
as follows:
100% / 3 groups = 33.3% per group Group 1: (33.3% / 3 users) = 11.1% per user Grou
p 2: (33.3% / 2 users) = 16.7% per user Group 3: (33.3% / 4 users) = 8.3% per user

Prepared by: Narayan Dhamala 102


Highest Response Ratio Next (HRRN) Scheduling
Highest Response Ratio Next (HRNN) is one of the mos
t optimal scheduling algorithms.
This is a non-preemptive algorithm in which, the sched
uling is done on the basis of an extra parameter called R
esponse Ratio.
 A Response Ratio is calculated for each of the available
jobs and the Job with the highest response ratio is given
priority over the others.
Response Ratio is calculated by the given formula.
Response Ratio = (W+S)/S   Where
W → Waiting Time   
S → Service Time or Burst Time  

Prepared by: Narayan Dhamala 103


Highest Response Ratio Next (HRRN) Scheduling Contd..
This algorithm not only favors shorter job but it also c
oncern the waiting time of the longer jobs.
Its mode is non preemptive hence context switching is
minimal in this algorithm.

Example: see the file provided in google classroom.

Prepared by: Narayan Dhamala 104


Prepared by: Narayan Dhamala 105
Prepared by: Narayan Dhamala 106
End

Prepared by : Narayan Dhamala 107

You might also like