0% found this document useful (0 votes)
4 views23 pages

Week-3 - CPU SCHEDULING

Uploaded by

harshverma8433
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)
4 views23 pages

Week-3 - CPU SCHEDULING

Uploaded by

harshverma8433
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/ 23

12-1

CPU Scheduling
Process Scheduling 12-2
Scheduling Queues 12-3
Scheduling Queues 12-4
Context Switch 12-5
Process Scheduling 12-6

 The process scheduling is the activity of the process manager that


handles the removal of the running process from the CPU and the
selection of another process on the basis of a particular strategy.
 Process scheduling is an essential part of
Multiprogramming operating systems.
 In a single Processor system, only one process can run at a time; any
other must wait until the CPU is free and can be rescheduled.
 The Objective of Multiprogramming is to have some process running at
all times to maximize the CPU utilization.
Process Scheduling 12-7
Conti…..
Dispatcher 12-8

 Another component involved in the CPU scheduling function is


the Dispatcher.
 The dispatcher is the module that gives control of the CPU to the
process selected by the short-term scheduler.
This function involves:
 Switching context
 Switching to user mode
 Jumping to the proper location in the user program to restart
that program from where it left last time.
Type of CPU Scheduling 12-9

CPU scheduling decisions may take place under the following four
circumstances:
1. When a process switches from the running state to the waiting state
(for I/O request or invocation of wait for the termination of one of the
child processes).
2. When a process switches from the running state to the ready state (for
example, when an interrupt occurs).
3. When a process switches from the waiting state to the ready state (for
example, completion of I/O).
4. When a process terminates.
Type of CPU Scheduling 12-10

 In circumstances 1 and 4, there is no choice in terms of scheduling. A new


process (if one exists in the ready queue) must be selected for execution. There
is a choice, however in circumstances 2 and 3.
 When Scheduling takes place only under circumstances 1 and 4, we say the
scheduling scheme is Non-preemptive; otherwise the scheduling scheme
is Preemptive.

1. Running to Waiting
2. Running to Ready
3. Waiting to Ready
4. Process Terminate
Type of CPU Scheduling 12-11

Non-Preemptive Scheduling
Under non-preemptive scheduling, once the CPU has been allocated to a
process, the process keeps the CPU until
1. Process is terminated
2. Switches to the waiting state.

Preemptive Scheduling
In this type of Scheduling, the process switches the control to another
process in following conditions
3. High Priority Process Arrives
4. Times Slice Expires
5. Process completes it I/O Operation
6. Generate a child process
CPU Scheduling Criteria 12-12

 Throughput: It is the total number of processes completed per unit time or


rather say total amount of work done in a unit of time. This may range from
10/second to 1/hour depending on the specific processes.
 Turnaround Time: It is the amount of time taken to execute a particular
process, i.e. the interval from time of submission of the process to the time of
completion of the process (Wall clock time).
 Waiting Time: The sum of the periods spent waiting in the ready queue
amount of time a process has been waiting in the ready queue to acquire get
control on the CPU.
CPU Scheduling Criteria
cont… 12-13

 Load Average: It is the average number of processes residing in the


ready queue waiting for their turn to get into the CPU.
 Response Time: Amount of time it takes from when a request was
submitted until the first response is produced. Remember, it is the time
till the first response and not the completion of process execution (final
response).
In general CPU utilization and Throughput are maximized and other

factors are reduced for proper optimization.

 CPU Utilization: To make out the best use of CPU and not to waste
any CPU cycle, CPU would be working most of the time (Ideally 100%
of the time).
Considering a real system, CPU usage should range from 40% (lightly
loaded) to 90% (heavily loaded).
FCFS Example-Q1 12-14

Average WT=17
Q2 12-15

Process Burst time Arrival time


P1 6 2
P2 3 5
P3 8 1
P4 3 0
P5 4 4

Average WT=8
Q3 12-16

Average WT=5.75
Q4. 12-17
SJF 12-18
SJF with non-preemptive 12-19
Example 2(Non-preemptive) 12-20

Process Queue Burst time Arrival time


P1 6 2
P2 2 5
P3 8 1
P4 3 0
P5 4 4
12-21

 Wait time
P4= 0-0=0
P1= 3-2=1
 P2= 9-5=4
P5= 11-4=7
P3= 15-1=14
 Average Waiting Time= (0+1+4+7+14)/5 = 26/5 = 5.2
12-22
12-23

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy