SlideShare a Scribd company logo
Unit 2: CPU/ Process Scheduling
Relate!!
Basic Concept
 Imagine you're at a busy cafe,
 Orders must be managed efficiently, ensuring prompt
customer service.
 Similarly, Modern operating systems rely on CPU
scheduling,
 optimizing task execution and resource utilization
efficiently.
 This effectively determines CPU task order, balancing
performance, fairness, and responsiveness.
Basic Concept
 CPU Scheduling is:
 Basis of Multi-programmed OS
 Objective of Multi-programming:
 To have some processes running all the time to
maximize CPU Utilization.
CPU and I/O Bursts
Sequence of CPU and I/O Bursts
CPU Scheduling Decisions
1. When process switches from
Running State to Waiting State
(i/o request or wait)
2. When process switches from
Running to Ready State
(interrupt)
3. When process switches from
Waiting State to Ready State
(at completion of i/o)
4. When a process terminates
1. Non-preemptive
2. Pre-emptive
3. Pre-emptive
4. Non-Preemptive
(allow)
Process States
Scheduling
 Non-Preemptive
 Preemptive
Non-Preemptive
 Once CPU is allocated to process,
 process retains CPU until completion.
 It may switch to a waiting state.
 Example: Windows 3.x, Apple Macintosh systems.
 Process executes till it finishes.
 Example: First In, First Out scheduling.
Preemptive Scheduling
 The running process is interrupted briefly.
 It resumes once priority task finishes.
 CPU or resources are taken away.
 A high-priority process needs immediate
execution.
 Lower-priority processes must wait for turn.
 This ensures critical tasks are completed
efficiently.
Dispatcher
 Dispatcher manages CPU control, enabling process
execution.
 Functions include context switching, user mode
switching.
 Restarts program at proper memory location.
 Dispatcher must operate efficiently, minimizing delays.
 Invoked during every process switch promptly.
 Dispatch latency measures process-switch time
duration.
Scheduling Criteria
 Which algorithm to use in a particular situation
1. CPU Utilization: CPU should be busy to the fullest
2. Throughput: No. of processes completed per unit of
time.
3. Turnaround Time: The time interval from submitting a
process to the time of completion.
Turnaround Time= Time spent to get into memory + waiting
in ready queue + doing I/O + executing on CPU
(It is the amount of time taken to execute a particular process)
Scheduling Criteria
4. Waiting Time: Time a process spends in a ready queue.
Amount of time a process has been waiting in the ready
queue to acquire control on the CPU.
5. Response Time: Time from the submission of a request
to the first response, Not Output
6. Load Average: It is the average number of processes
residing in the ready queue waiting for their turn to get
into the CPU.
Scheduling Algorithm Optimization Criteria
 Max CPU utilization
 Max throughput
 Min turnaround time
 Min waiting time
 Min response time
Formula
Turn around time= Completion Time- Arrival Time
Waiting Time= Turn around Time-Burst Time
OR
Turnaround time = Burst time + Waiting time
First-Come, First-Served (FCFS)
 Processes that request CPU first, are allocated the CPU
first
 It is non-preemptive scheduling algorithm
 FCFS is implemented with FIFO queue.
 A process is allocated the CPU according to their arrival
times.
First-Come, First-Served (FCFS)
 When process enters the ready queue,
 its PCB is attached to the Tail of queue.
 When CPU is free,
 it is allocated to the process selected from Head/Front
of queue.
 FCFS leads to Convoy Effect
First-Come, First-Served (Example)
 Example: Consider three processes arrive in order
P1, P2, and P3.
 P1 burst time: 24
 P2 burst time: 3
 P3 burst time: 3
 Draw the Gantt Chart and compute Average Waiting
Time and Average Turn Around Time.
Sol:
19
First-Come, First-Served (Example)
First-Come, First-Served (Example)
Process A T BT CT TAT WT
P1 0 2
P2 3 1
P3 5 6
Calculate avg.
CT, TAT, WT
First-Come, First-Served (Example)
Process A T BT CT TAT WT
P1 0 4
P2 1 3
P3 2 1
P4 3 2
P5 4 5
H.W
Calculate avg.
CT, TAT,WT
(2) Shortest Job First
 Processes with least burst time (BT) are selected.
 CPU assigned to process with less BT.
 SJF has two types:
1. Non-Preemptive.
 CPU stays until process completion only.
(2) Shortest Job First
2. Preemption:
New process enters the scheduling queue.
Scheduler compares execution time with current.
 A shorter process preempts an already running process.
Efficient scheduling ensures minimized waiting time.
Shortest Job First(Preemptive)
Q1. Consider foll. Processes with A.T and B.T
Process A.T B.T
P1 0 4
P2 0 6
P3 0 4
Cal. Completion time, turn around time and avg. waiting time.
SJF(Pre-emptive)-> SRTF
Q1. Consider foll. Processes with A.T and B.T
Process A.T B.T
P1 0 9
P2 1 4
P3 2 9
Cal. Completion time, turn around time and avg. waiting time.
SJF(Pre-emptive)-> SRTF
Shortest Job First(Preemptive)
Q1. Consider foll. Processes with A.T and B.T
Process A.T B.T
P1 0 5
P2 1 7
P3 3 4
Cal. Completion time, turn around time and avg. waiting time.
SJF(Pre-emptive)-> SRTF
Shortest Job First(Preemptive)
Q1. Consider foll. Processes with A.T and B.T
Process A.T B.T
P1 0 5
P2 1 3
P3 2 3
P4 3 1
Cal. Completion time, turn around time and avg. waiting time.
Shortest Job First(Preemptive)
Shortest Job First (Non-Preemption)
 P1 burst time: 15
 P2 burst time: 8
 P3 burst time: 10
 P4 burst time: 3
Processes arrived at the same time.
29
Q1. Consider foll. Processes with A.T and B.T
Process A.T B.T
P1 1 7
P2 2 5
P3 3 1
P4 4 2
P5 5 8
Cal. Completion time, turn around time and avg. waiting time.
Practice: Shortest Job First (Non Preemption)
SRTF Example
CPU idle time: (idle time/ total time spent) * 100
SRTF Example
Consider three processes, all arriving at time zero, with total
execution time of 10, 20 and 30 units, respectively. Each
process spends the first 20% of execution time doing I/O, the
next 70% of time doing computation, and the last 10% of time
doing I/O again. The operating system uses a shortest
remaining compute time first scheduling algorithm and
schedules a new process either when the running process gets
blocked on I/O or when the running process finishes its
compute burst. Assume that all I/O operations can be
overlapped as much as possible. For what percentage of time
does the CPU remain idle?
(A) 0% (B) 10.6% (C) 30.0% (D) 89.4%
SRTF Example
Explanation: Let three processes be p0, p1 and p2. Their execution time is 10, 20
and 30 respectively. p0 spends first 2 time units in I/O, 7 units of CPU time and
finally 1 unit in I/O. p1 spends first 4 units in I/O, 14 units of CPU time and finally 2
units in I/O. p2 spends first 6 units in I/O, 21 units of CPU time and finally 3 units in
I/O.
idle p0 p1 p2 idle
0 2 9 23 44 47
Total time spent = 47
Idle time = 2 + 3 = 5
Percentage of idle time = (5/47)*100 = 10.6 %
Priority Scheduling
 Priority is associated with each process.
 CPU is allocated to the process with highest priority.
 If 2 processes have same priority  FCFS
Disadvantage: Starvation (Low priority Processes wait for
long)
Solution of Starvation:
Aging: The priority of a process is gradually increased over
time to prevent it from starving (waiting indefinitely).
Priority Scheduling (Preemptive)
Process Arrival
Time
Priority Burst
Time
Completion
Time
P1 1 5 4
P2 2 7 2
P3 3 4 3
Consider 4 as
Highest and 7 as
Lowest Priority
Priority Scheduling (Preemptive)
Process Arrival
Time
Priority Burst
Time
Completion
Time
P1 0 2 10
P2 2 1 5
P3 3 0 2
P4 5 3 20
Consider 0 as
Lowest and 3
as Highest
Priority
Priority Scheduling (Preemptive)
Process Arrival
Time
Priority Burst
Time
Completion
Time
P1 0 2 10
P2 2 1 5
P3 3 0 2
P4 5 3 20
Consider 3 as
Lowest and 0
as Highest
Priority
Round Robin Scheduling
 A Time Quantum is associated to all processes
 Time Quantum: Maximum amount of time for which
process can run once it is scheduled.
 RR scheduling is always Pre-emptive.
Round Robin
Process Arrival
Time
Burst
Time
Completion
Time
P1 0 5
P2 1 7
P3 2 1
TQ: 2
Process Arrival
Time
Burst
Time
Completion
Time
P1 0 3
P2 3 4
P3 4 6
Round Robin
Process Arrival
Time
Burst
Time
Completion
Time
P1 0 4
P2 1 5
P3 2 2
P4 3 1
P5 4 6
P6 6 3
TQ: 2
Round Robin
Process Arrival
Time
Burst
Time
Completion
Time
P1 0 4
P2 1 5
P3 2 2
P4 3 1
P5 4 6
P6 6 3
TQ: 2
Multilevel Queue Scheduling
Partition the ready queue into several separate queues.
For Example: a multilevel queue scheduling algorithm with
five queue:
1. System processes
2. Interactive processes
3. Interactive editing processes
4. Batch processes
5. Student/ user processes
Multilevel Queue
 A process moves between various queues.
 Multilevel Queue Scheduler defined by parameters.
 Number of queues is defined here.
 Scheduling algorithms for each queue specified.
 Method determines when to upgrade process.
 Method decides which queue gets service.
Multilevel Queue
Multilevel Queue
Multilevel Queue
1. System Processes: These are programs that belong to OS
(System Files)
2. Interactive Processes: Real-Time Processes e.g. playing
games online, listening to music online, etc.
3. Batch Processes: Lots of processes are pooled and one
process at a time is selected for execution. I/O by Punch Cards
4. Student/User Processes
Multilevel Queue
 No process in the batch queue could run unless the other
queues for the system were empty.
 If an interactive editing process entered the ready queue
while a batch process was running, the batch process would
be preempted.
Multilevel Queue
 Processes can be :
 Foreground Process: processes that are running
currently
 Background Process: Processes that are running in the
background but their effects are not visible to the user.
 Processes are permanently assigned to one queue on some
properties:
 memory size, process priority, process type.
 Each queue has its own scheduling algorithm
Multilevel Queue
 Different types of processes exist, So
 Cannot apply same scheduling algorithm.
Disadvantages:
1. Until high priority queue is not empty,
2. No process from lower priority queues will be selected.
3. Starvation for lower priority processes.
Advantage:
Can apply separate scheduling algorithm for each queue.
Multilevel Feedback Queue
 Solution is: Multilevel Feedback Queue
 If a process is taking too long to execute..
 Pre-empt it send it to low priority queue.
 Don’t allow a low priority process to wait for long.
 After some time move the least priority process to
high priority queue  Aging
Multilevel Feedback Queue
Multilevel Feedback Queue
Multi-processor Scheduling
Concerns:
• Multiple CPUs enable load sharing.
• Focus is on homogeneous processors' systems.
• Use any processor for any process.
• Various types of limitations exist.
• Systems with I/O devices have restrictions.
• Devices must run on specific processors.
Unit2 CPU Scheduling 24252 (sssssss1).ppt
Approaches to Multiple-Processor Scheduling
1. Asymmetric multiprocessing
•Scheduling decisions, I/O processing handled by server.
•Other processors execute only user code.
•One processor accesses system data structures.
•Reduces the need for data sharing.
•Single processor controls system activities efficiently.
•Improves data management, reducing conflicts.
Approaches to Multiple-Processor Scheduling
 2. Symmetric multiprocessing (SMP)
 Each processor is self-scheduling and efficient.
 All processes may share a common queue.
 Each processor may have a private queue.
 Schedulers examine queues and select processes.
 Modern operating systems widely support SMP.
 Like, Windows, Linux, Mac OS X included.
Issues concerning SMP systems
 1. Processor Affinity
(a process has an affinity for the processor on which it is currently
running.)
 Consider what happens to cache memory when a process
has been running on a specific processor.
The data most recently accessed by the process populate
the cache for the processor.
As a result, successive memory accesses by the process are
often in cache memory.
Issues concerning SMP systems
1. Processor Affinity
 If the process migrates to another processor.
 The contents of cache memory must be invalidated for the
first processor,
and the cache for the second processor must be repopulated.
Issues concerning SMP systems
1. Processor Affinity
High cost of invalidating and repopulating caches.
Most SMP systems avoid process migration entirely.
They attempt to keep processes running consistently.
This concept is called processor affinity generally.
A process has affinity for its processor.
It runs on the same processor continuously.
Issues concerning SMP systems
Forms of Processor Affinity
1. Soft affinity
• An OS tries keeping processes on the same processor.
• This is called soft affinity policy.
2. Hard affinity
• The OS tries to keep processes stable.
• Processes may migrate between different processors.
Issues concerning SMP systems
2. Load Balancing
•On SMP systems, workload balance is important.
•All processors should be fully utilized efficiently.
•Load balancing prevents some processors from idling.
•High workloads may burden specific processors excessively.
•Idle processors waste system resources and efficiency.
•Balanced workloads maximize the system's overall
performance.
Issues concerning SMP systems
2. Load Balancing
Two approaches to load balancing: push migration and pull
migration.
1. Push migration: a specific task periodically checks the
load on each processor and—if it finds an imbalance—evenly
distributes the load by moving (or pushing) processes from
overloaded to idle or less-busy processors.
2. Pull migration: occurs when an idle processor pulls a
waiting task from a busy processor.
Issues concerning SMP systems
3. Multicore Processors
•A multi-core processor has independent cores.
•It reads and executes program instructions.
•A CPU may contain multiple cores.
•A core includes registers and cache.
•Core handles processor tasks, not entire.
•It's essential for efficient task performance.
Issues concerning SMP systems
3. Multicore Processors
Multicore processors may complicate scheduling issues:
When a processor accesses memory, it spends a significant
amount of time waiting for the data to become available. This
situation, known as a memory stall.
Memory Stall may occur due to a cache miss (accessing
data that are not in cache memory).
Issues concerning SMP systems
Memory Stall
the processor can spend up to 50 percent of its time waiting for
data to become available from memory.
Real Time Scheduling
Analysis and testing of the scheduler system and the
algorithms used in real-time applications
a) soft real-time systems b) hard real-time systems
a)Soft real-time systems provide no guarantee as to when
a critical real-time process will be scheduled.
b)Hard real-time systems have stricter requirements. A
task must be serviced by its deadline;
Rate-Monotonic Scheduling
• Rate-monotonic scheduling assigns tasks' priorities statically.
• It uses a preemption-based scheduling policy efficiently.
• RMS operates in real-time operating systems seamlessly.
• Static priorities depend on task cycle duration.
• Shorter cycles lead to higher job priority.
• This ensures periodic tasks are scheduled optimally.
Rate-Monotonic Scheduling
rate-monotonic scheduling assumes that the processing time of
a periodic process is the same for each CPU burst.
For example
Consider P1, P2 with time period 50,100 resp. and B.T 20,35
resp.
Cal. CPU utilization of each process and total CPU
utilization.
Sol:
CPU utilization=(Burst time/Time period)= (Ti/Pi)
For P1: (20/50)=0.40 i.e 40%
For P2: (35/100)=0.35 i.e 35%
Total CPU utilization is 75%
Earliest Deadline First Scheduling
Earliest-deadline-first (EDF) scheduling dynamically assigns
priorities according to deadline.
The earlier the deadline, the higher the priority the later the
deadline, the lower the priority.
Under the EDF policy, when a process becomes runnable, it
must announce its deadline requirements to the system.
Practice MCQ:
Ad

More Related Content

Similar to Unit2 CPU Scheduling 24252 (sssssss1).ppt (20)

Process Scheduling in Ope Spptystems rating
Process Scheduling in Ope Spptystems ratingProcess Scheduling in Ope Spptystems rating
Process Scheduling in Ope Spptystems rating
Aryan904173
 
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
ssuserc35fa4
 
CPU scheduling
CPU schedulingCPU scheduling
CPU scheduling
Amir Khan
 
Cp usched 2
Cp usched  2Cp usched  2
Cp usched 2
nidsrajdev
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
donny101
 
operating system scheduling concept lec2
operating system scheduling concept lec2operating system scheduling concept lec2
operating system scheduling concept lec2
thakurnishant1903200
 
Cpu Scheduling Galvin
Cpu Scheduling GalvinCpu Scheduling Galvin
Cpu Scheduling Galvin
Sonali Chauhan
 
CPU Scheduling
CPU SchedulingCPU Scheduling
CPU Scheduling
sammerkhan1
 
OS Process Chapter 3.pdf
OS Process Chapter 3.pdfOS Process Chapter 3.pdf
OS Process Chapter 3.pdf
Kp Sharma
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
KeyreSebre
 
Operating Systems Third Unit - Fourth Semester - Engineering
Operating Systems Third Unit  - Fourth Semester - EngineeringOperating Systems Third Unit  - Fourth Semester - Engineering
Operating Systems Third Unit - Fourth Semester - Engineering
Yogesh Santhan
 
CPU SCHEDULING ALGORITHMS-FCFS,SJF,RR.pptx
CPU SCHEDULING ALGORITHMS-FCFS,SJF,RR.pptxCPU SCHEDULING ALGORITHMS-FCFS,SJF,RR.pptx
CPU SCHEDULING ALGORITHMS-FCFS,SJF,RR.pptx
Rajapriya82
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
tech2click
 
Os module 2 ba
Os module 2 baOs module 2 ba
Os module 2 ba
Gichelle Amon
 
Process Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdfProcess Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdf
Rakibul Rakib
 
Lecture 3 CPU scheduling_2.pdflllllllllll
Lecture 3 CPU scheduling_2.pdflllllllllllLecture 3 CPU scheduling_2.pdflllllllllll
Lecture 3 CPU scheduling_2.pdflllllllllll
MohamedPalastine
 
Lecture 3 CPU scheduling.pdfvgukgiolphpiphjp
Lecture 3 CPU scheduling.pdfvgukgiolphpiphjpLecture 3 CPU scheduling.pdfvgukgiolphpiphjp
Lecture 3 CPU scheduling.pdfvgukgiolphpiphjp
MohamedPalastine
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
Prakash Sir
 
• A process is a program under execution. • Its current activity is indicated...
•	A process is a program under execution. •	Its current activity is indicated...•	A process is a program under execution. •	Its current activity is indicated...
• A process is a program under execution. • Its current activity is indicated...
manjuvanikm
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
mohsinalilarik1
 
Process Scheduling in Ope Spptystems rating
Process Scheduling in Ope Spptystems ratingProcess Scheduling in Ope Spptystems rating
Process Scheduling in Ope Spptystems rating
Aryan904173
 
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
ch6- CPU scheduling https://www.slideshare.net/slideshow/operating-system-18-...
ssuserc35fa4
 
CPU scheduling
CPU schedulingCPU scheduling
CPU scheduling
Amir Khan
 
Unit iios process scheduling and synchronization
Unit iios process scheduling and synchronizationUnit iios process scheduling and synchronization
Unit iios process scheduling and synchronization
donny101
 
operating system scheduling concept lec2
operating system scheduling concept lec2operating system scheduling concept lec2
operating system scheduling concept lec2
thakurnishant1903200
 
OS Process Chapter 3.pdf
OS Process Chapter 3.pdfOS Process Chapter 3.pdf
OS Process Chapter 3.pdf
Kp Sharma
 
chapter 5 CPU scheduling.ppt
chapter  5 CPU scheduling.pptchapter  5 CPU scheduling.ppt
chapter 5 CPU scheduling.ppt
KeyreSebre
 
Operating Systems Third Unit - Fourth Semester - Engineering
Operating Systems Third Unit  - Fourth Semester - EngineeringOperating Systems Third Unit  - Fourth Semester - Engineering
Operating Systems Third Unit - Fourth Semester - Engineering
Yogesh Santhan
 
CPU SCHEDULING ALGORITHMS-FCFS,SJF,RR.pptx
CPU SCHEDULING ALGORITHMS-FCFS,SJF,RR.pptxCPU SCHEDULING ALGORITHMS-FCFS,SJF,RR.pptx
CPU SCHEDULING ALGORITHMS-FCFS,SJF,RR.pptx
Rajapriya82
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
tech2click
 
Process Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdfProcess Scheduling Algorithms.pdf
Process Scheduling Algorithms.pdf
Rakibul Rakib
 
Lecture 3 CPU scheduling_2.pdflllllllllll
Lecture 3 CPU scheduling_2.pdflllllllllllLecture 3 CPU scheduling_2.pdflllllllllll
Lecture 3 CPU scheduling_2.pdflllllllllll
MohamedPalastine
 
Lecture 3 CPU scheduling.pdfvgukgiolphpiphjp
Lecture 3 CPU scheduling.pdfvgukgiolphpiphjpLecture 3 CPU scheduling.pdfvgukgiolphpiphjp
Lecture 3 CPU scheduling.pdfvgukgiolphpiphjp
MohamedPalastine
 
• A process is a program under execution. • Its current activity is indicated...
•	A process is a program under execution. •	Its current activity is indicated...•	A process is a program under execution. •	Its current activity is indicated...
• A process is a program under execution. • Its current activity is indicated...
manjuvanikm
 

More from AkashPundir2 (7)

This is an updated slide on User Centered Design .
This is an updated slide on User Centered Design .This is an updated slide on User Centered Design .
This is an updated slide on User Centered Design .
AkashPundir2
 
A ppt on deadlock in operating systems for the better explanation
A ppt on deadlock in operating systems for the better explanationA ppt on deadlock in operating systems for the better explanation
A ppt on deadlock in operating systems for the better explanation
AkashPundir2
 
HCIUnit1.pptxssssssssssssssssssssssssssss
HCIUnit1.pptxssssssssssssssssssssssssssssHCIUnit1.pptxssssssssssssssssssssssssssss
HCIUnit1.pptxssssssssssssssssssssssssssss
AkashPundir2
 
Unit2 CPU Scheduling 24252.ppBBBBBBBBBBt
Unit2 CPU Scheduling 24252.ppBBBBBBBBBBtUnit2 CPU Scheduling 24252.ppBBBBBBBBBBt
Unit2 CPU Scheduling 24252.ppBBBBBBBBBBt
AkashPundir2
 
Unit1 CSE316_System_Calls 2BBBBB4252.pptx
Unit1 CSE316_System_Calls 2BBBBB4252.pptxUnit1 CSE316_System_Calls 2BBBBB4252.pptx
Unit1 CSE316_System_Calls 2BBBBB4252.pptx
AkashPundir2
 
OPERATING SYSTEM PPT ON SCHEDULING AND ALGORITHMS
OPERATING SYSTEM PPT ON SCHEDULING AND ALGORITHMSOPERATING SYSTEM PPT ON SCHEDULING AND ALGORITHMS
OPERATING SYSTEM PPT ON SCHEDULING AND ALGORITHMS
AkashPundir2
 
OPERATING SYSTEM PPT ON INTRODUCTION AND BASICS
OPERATING SYSTEM PPT ON INTRODUCTION AND BASICSOPERATING SYSTEM PPT ON INTRODUCTION AND BASICS
OPERATING SYSTEM PPT ON INTRODUCTION AND BASICS
AkashPundir2
 
This is an updated slide on User Centered Design .
This is an updated slide on User Centered Design .This is an updated slide on User Centered Design .
This is an updated slide on User Centered Design .
AkashPundir2
 
A ppt on deadlock in operating systems for the better explanation
A ppt on deadlock in operating systems for the better explanationA ppt on deadlock in operating systems for the better explanation
A ppt on deadlock in operating systems for the better explanation
AkashPundir2
 
HCIUnit1.pptxssssssssssssssssssssssssssss
HCIUnit1.pptxssssssssssssssssssssssssssssHCIUnit1.pptxssssssssssssssssssssssssssss
HCIUnit1.pptxssssssssssssssssssssssssssss
AkashPundir2
 
Unit2 CPU Scheduling 24252.ppBBBBBBBBBBt
Unit2 CPU Scheduling 24252.ppBBBBBBBBBBtUnit2 CPU Scheduling 24252.ppBBBBBBBBBBt
Unit2 CPU Scheduling 24252.ppBBBBBBBBBBt
AkashPundir2
 
Unit1 CSE316_System_Calls 2BBBBB4252.pptx
Unit1 CSE316_System_Calls 2BBBBB4252.pptxUnit1 CSE316_System_Calls 2BBBBB4252.pptx
Unit1 CSE316_System_Calls 2BBBBB4252.pptx
AkashPundir2
 
OPERATING SYSTEM PPT ON SCHEDULING AND ALGORITHMS
OPERATING SYSTEM PPT ON SCHEDULING AND ALGORITHMSOPERATING SYSTEM PPT ON SCHEDULING AND ALGORITHMS
OPERATING SYSTEM PPT ON SCHEDULING AND ALGORITHMS
AkashPundir2
 
OPERATING SYSTEM PPT ON INTRODUCTION AND BASICS
OPERATING SYSTEM PPT ON INTRODUCTION AND BASICSOPERATING SYSTEM PPT ON INTRODUCTION AND BASICS
OPERATING SYSTEM PPT ON INTRODUCTION AND BASICS
AkashPundir2
 
Ad

Recently uploaded (20)

AlaskaSilver Corporate Presentation Apr 28 2025.pdf
AlaskaSilver Corporate Presentation Apr 28 2025.pdfAlaskaSilver Corporate Presentation Apr 28 2025.pdf
AlaskaSilver Corporate Presentation Apr 28 2025.pdf
Western Alaska Minerals Corp.
 
Influence of Career Development on Retention of Employees in Private Univers...
Influence of Career Development on Retention of  Employees in Private Univers...Influence of Career Development on Retention of  Employees in Private Univers...
Influence of Career Development on Retention of Employees in Private Univers...
publication11
 
Brandon Flatley - A Skilled Musician
Brandon Flatley - A Skilled MusicianBrandon Flatley - A Skilled Musician
Brandon Flatley - A Skilled Musician
Brandon Flatley
 
Top 5 Mistakes to Avoid When Writing a Job Application
Top 5 Mistakes to Avoid When Writing a Job ApplicationTop 5 Mistakes to Avoid When Writing a Job Application
Top 5 Mistakes to Avoid When Writing a Job Application
Red Tape Busters
 
LDMMIA Bday celebration 2025 Gifts information
LDMMIA Bday celebration 2025 Gifts informationLDMMIA Bday celebration 2025 Gifts information
LDMMIA Bday celebration 2025 Gifts information
LDM Mia eStudios
 
Alan Stalcup - The Enterprising CEO
Alan  Stalcup  -  The  Enterprising  CEOAlan  Stalcup  -  The  Enterprising  CEO
Alan Stalcup - The Enterprising CEO
Alan Stalcup
 
The Peter Cowley Entrepreneurship Event Master 30th.pdf
The Peter Cowley Entrepreneurship Event Master 30th.pdfThe Peter Cowley Entrepreneurship Event Master 30th.pdf
The Peter Cowley Entrepreneurship Event Master 30th.pdf
Richard Lucas
 
Strategic Enterprise Management - Unit I.pptx
Strategic Enterprise Management - Unit I.pptxStrategic Enterprise Management - Unit I.pptx
Strategic Enterprise Management - Unit I.pptx
PrekshyaRana
 
From Sunlight to Savings The Rise of Homegrown Solar Power.pdf
From Sunlight to Savings The Rise of Homegrown Solar Power.pdfFrom Sunlight to Savings The Rise of Homegrown Solar Power.pdf
From Sunlight to Savings The Rise of Homegrown Solar Power.pdf
Insolation Energy
 
Salesforce_Architecture_Diagramming_Workshop (1).pptx
Salesforce_Architecture_Diagramming_Workshop (1).pptxSalesforce_Architecture_Diagramming_Workshop (1).pptx
Salesforce_Architecture_Diagramming_Workshop (1).pptx
reinbauwens1
 
2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf
2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf
2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf
ThiNgc22
 
www.visualmedia.com digital markiting (1).pptx
www.visualmedia.com digital markiting (1).pptxwww.visualmedia.com digital markiting (1).pptx
www.visualmedia.com digital markiting (1).pptx
Davinder Singh
 
Harnessing Hyper-Localisation: A New Era in Retail Strategy
Harnessing Hyper-Localisation: A New Era in Retail StrategyHarnessing Hyper-Localisation: A New Era in Retail Strategy
Harnessing Hyper-Localisation: A New Era in Retail Strategy
RUPAL AGARWAL
 
CGG Deck English - Apr 2025-edit (1).pptx
CGG Deck English - Apr 2025-edit (1).pptxCGG Deck English - Apr 2025-edit (1).pptx
CGG Deck English - Apr 2025-edit (1).pptx
China_Gold_International_Resources
 
20250428 CDB Investor Deck_Apr25_vFF.pdf
20250428 CDB Investor Deck_Apr25_vFF.pdf20250428 CDB Investor Deck_Apr25_vFF.pdf
20250428 CDB Investor Deck_Apr25_vFF.pdf
yihong30
 
Level Up Your Launch: Utilizing AI for Start-up Success
Level Up Your Launch: Utilizing AI for Start-up SuccessLevel Up Your Launch: Utilizing AI for Start-up Success
Level Up Your Launch: Utilizing AI for Start-up Success
Best Virtual Specialist
 
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdfAccounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
CA Suvidha Chaplot
 
waterBeta white paper - 250202- two-column.docx
waterBeta white paper - 250202- two-column.docxwaterBeta white paper - 250202- two-column.docx
waterBeta white paper - 250202- two-column.docx
Peter Adriaens
 
Affinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing PresentationAffinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing Presentation
omiller199514
 
Solaris Resources Presentation - Corporate April 2025.pdf
Solaris Resources Presentation - Corporate April 2025.pdfSolaris Resources Presentation - Corporate April 2025.pdf
Solaris Resources Presentation - Corporate April 2025.pdf
pchambers2
 
Influence of Career Development on Retention of Employees in Private Univers...
Influence of Career Development on Retention of  Employees in Private Univers...Influence of Career Development on Retention of  Employees in Private Univers...
Influence of Career Development on Retention of Employees in Private Univers...
publication11
 
Brandon Flatley - A Skilled Musician
Brandon Flatley - A Skilled MusicianBrandon Flatley - A Skilled Musician
Brandon Flatley - A Skilled Musician
Brandon Flatley
 
Top 5 Mistakes to Avoid When Writing a Job Application
Top 5 Mistakes to Avoid When Writing a Job ApplicationTop 5 Mistakes to Avoid When Writing a Job Application
Top 5 Mistakes to Avoid When Writing a Job Application
Red Tape Busters
 
LDMMIA Bday celebration 2025 Gifts information
LDMMIA Bday celebration 2025 Gifts informationLDMMIA Bday celebration 2025 Gifts information
LDMMIA Bday celebration 2025 Gifts information
LDM Mia eStudios
 
Alan Stalcup - The Enterprising CEO
Alan  Stalcup  -  The  Enterprising  CEOAlan  Stalcup  -  The  Enterprising  CEO
Alan Stalcup - The Enterprising CEO
Alan Stalcup
 
The Peter Cowley Entrepreneurship Event Master 30th.pdf
The Peter Cowley Entrepreneurship Event Master 30th.pdfThe Peter Cowley Entrepreneurship Event Master 30th.pdf
The Peter Cowley Entrepreneurship Event Master 30th.pdf
Richard Lucas
 
Strategic Enterprise Management - Unit I.pptx
Strategic Enterprise Management - Unit I.pptxStrategic Enterprise Management - Unit I.pptx
Strategic Enterprise Management - Unit I.pptx
PrekshyaRana
 
From Sunlight to Savings The Rise of Homegrown Solar Power.pdf
From Sunlight to Savings The Rise of Homegrown Solar Power.pdfFrom Sunlight to Savings The Rise of Homegrown Solar Power.pdf
From Sunlight to Savings The Rise of Homegrown Solar Power.pdf
Insolation Energy
 
Salesforce_Architecture_Diagramming_Workshop (1).pptx
Salesforce_Architecture_Diagramming_Workshop (1).pptxSalesforce_Architecture_Diagramming_Workshop (1).pptx
Salesforce_Architecture_Diagramming_Workshop (1).pptx
reinbauwens1
 
2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf
2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf
2_English_Vocabulary_In_Use_Pre-Intermediate_Cambridge_-_Fourth_Edition (1).pdf
ThiNgc22
 
www.visualmedia.com digital markiting (1).pptx
www.visualmedia.com digital markiting (1).pptxwww.visualmedia.com digital markiting (1).pptx
www.visualmedia.com digital markiting (1).pptx
Davinder Singh
 
Harnessing Hyper-Localisation: A New Era in Retail Strategy
Harnessing Hyper-Localisation: A New Era in Retail StrategyHarnessing Hyper-Localisation: A New Era in Retail Strategy
Harnessing Hyper-Localisation: A New Era in Retail Strategy
RUPAL AGARWAL
 
20250428 CDB Investor Deck_Apr25_vFF.pdf
20250428 CDB Investor Deck_Apr25_vFF.pdf20250428 CDB Investor Deck_Apr25_vFF.pdf
20250428 CDB Investor Deck_Apr25_vFF.pdf
yihong30
 
Level Up Your Launch: Utilizing AI for Start-up Success
Level Up Your Launch: Utilizing AI for Start-up SuccessLevel Up Your Launch: Utilizing AI for Start-up Success
Level Up Your Launch: Utilizing AI for Start-up Success
Best Virtual Specialist
 
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdfAccounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
Accounting_Basics_Complete_Guide_By_CA_Suvidha_Chaplot (1).pdf
CA Suvidha Chaplot
 
waterBeta white paper - 250202- two-column.docx
waterBeta white paper - 250202- two-column.docxwaterBeta white paper - 250202- two-column.docx
waterBeta white paper - 250202- two-column.docx
Peter Adriaens
 
Affinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing PresentationAffinity.co Lifecycle Marketing Presentation
Affinity.co Lifecycle Marketing Presentation
omiller199514
 
Solaris Resources Presentation - Corporate April 2025.pdf
Solaris Resources Presentation - Corporate April 2025.pdfSolaris Resources Presentation - Corporate April 2025.pdf
Solaris Resources Presentation - Corporate April 2025.pdf
pchambers2
 
Ad

Unit2 CPU Scheduling 24252 (sssssss1).ppt

  • 1. Unit 2: CPU/ Process Scheduling
  • 3. Basic Concept  Imagine you're at a busy cafe,  Orders must be managed efficiently, ensuring prompt customer service.  Similarly, Modern operating systems rely on CPU scheduling,  optimizing task execution and resource utilization efficiently.  This effectively determines CPU task order, balancing performance, fairness, and responsiveness.
  • 4. Basic Concept  CPU Scheduling is:  Basis of Multi-programmed OS  Objective of Multi-programming:  To have some processes running all the time to maximize CPU Utilization.
  • 5. CPU and I/O Bursts
  • 6. Sequence of CPU and I/O Bursts
  • 7. CPU Scheduling Decisions 1. When process switches from Running State to Waiting State (i/o request or wait) 2. When process switches from Running to Ready State (interrupt) 3. When process switches from Waiting State to Ready State (at completion of i/o) 4. When a process terminates 1. Non-preemptive 2. Pre-emptive 3. Pre-emptive 4. Non-Preemptive (allow)
  • 10. Non-Preemptive  Once CPU is allocated to process,  process retains CPU until completion.  It may switch to a waiting state.  Example: Windows 3.x, Apple Macintosh systems.  Process executes till it finishes.  Example: First In, First Out scheduling.
  • 11. Preemptive Scheduling  The running process is interrupted briefly.  It resumes once priority task finishes.  CPU or resources are taken away.  A high-priority process needs immediate execution.  Lower-priority processes must wait for turn.  This ensures critical tasks are completed efficiently.
  • 12. Dispatcher  Dispatcher manages CPU control, enabling process execution.  Functions include context switching, user mode switching.  Restarts program at proper memory location.  Dispatcher must operate efficiently, minimizing delays.  Invoked during every process switch promptly.  Dispatch latency measures process-switch time duration.
  • 13. Scheduling Criteria  Which algorithm to use in a particular situation 1. CPU Utilization: CPU should be busy to the fullest 2. Throughput: No. of processes completed per unit of time. 3. Turnaround Time: The time interval from submitting a process to the time of completion. Turnaround Time= Time spent to get into memory + waiting in ready queue + doing I/O + executing on CPU (It is the amount of time taken to execute a particular process)
  • 14. Scheduling Criteria 4. Waiting Time: Time a process spends in a ready queue. Amount of time a process has been waiting in the ready queue to acquire control on the CPU. 5. Response Time: Time from the submission of a request to the first response, Not Output 6. Load Average: It is the average number of processes residing in the ready queue waiting for their turn to get into the CPU.
  • 15. Scheduling Algorithm Optimization Criteria  Max CPU utilization  Max throughput  Min turnaround time  Min waiting time  Min response time
  • 16. Formula Turn around time= Completion Time- Arrival Time Waiting Time= Turn around Time-Burst Time OR Turnaround time = Burst time + Waiting time
  • 17. First-Come, First-Served (FCFS)  Processes that request CPU first, are allocated the CPU first  It is non-preemptive scheduling algorithm  FCFS is implemented with FIFO queue.  A process is allocated the CPU according to their arrival times.
  • 18. First-Come, First-Served (FCFS)  When process enters the ready queue,  its PCB is attached to the Tail of queue.  When CPU is free,  it is allocated to the process selected from Head/Front of queue.  FCFS leads to Convoy Effect
  • 19. First-Come, First-Served (Example)  Example: Consider three processes arrive in order P1, P2, and P3.  P1 burst time: 24  P2 burst time: 3  P3 burst time: 3  Draw the Gantt Chart and compute Average Waiting Time and Average Turn Around Time. Sol: 19
  • 21. First-Come, First-Served (Example) Process A T BT CT TAT WT P1 0 2 P2 3 1 P3 5 6 Calculate avg. CT, TAT, WT
  • 22. First-Come, First-Served (Example) Process A T BT CT TAT WT P1 0 4 P2 1 3 P3 2 1 P4 3 2 P5 4 5 H.W Calculate avg. CT, TAT,WT
  • 23. (2) Shortest Job First  Processes with least burst time (BT) are selected.  CPU assigned to process with less BT.  SJF has two types: 1. Non-Preemptive.  CPU stays until process completion only.
  • 24. (2) Shortest Job First 2. Preemption: New process enters the scheduling queue. Scheduler compares execution time with current.  A shorter process preempts an already running process. Efficient scheduling ensures minimized waiting time.
  • 25. Shortest Job First(Preemptive) Q1. Consider foll. Processes with A.T and B.T Process A.T B.T P1 0 4 P2 0 6 P3 0 4 Cal. Completion time, turn around time and avg. waiting time. SJF(Pre-emptive)-> SRTF
  • 26. Q1. Consider foll. Processes with A.T and B.T Process A.T B.T P1 0 9 P2 1 4 P3 2 9 Cal. Completion time, turn around time and avg. waiting time. SJF(Pre-emptive)-> SRTF Shortest Job First(Preemptive)
  • 27. Q1. Consider foll. Processes with A.T and B.T Process A.T B.T P1 0 5 P2 1 7 P3 3 4 Cal. Completion time, turn around time and avg. waiting time. SJF(Pre-emptive)-> SRTF Shortest Job First(Preemptive)
  • 28. Q1. Consider foll. Processes with A.T and B.T Process A.T B.T P1 0 5 P2 1 3 P3 2 3 P4 3 1 Cal. Completion time, turn around time and avg. waiting time. Shortest Job First(Preemptive)
  • 29. Shortest Job First (Non-Preemption)  P1 burst time: 15  P2 burst time: 8  P3 burst time: 10  P4 burst time: 3 Processes arrived at the same time. 29
  • 30. Q1. Consider foll. Processes with A.T and B.T Process A.T B.T P1 1 7 P2 2 5 P3 3 1 P4 4 2 P5 5 8 Cal. Completion time, turn around time and avg. waiting time. Practice: Shortest Job First (Non Preemption)
  • 31. SRTF Example CPU idle time: (idle time/ total time spent) * 100
  • 32. SRTF Example Consider three processes, all arriving at time zero, with total execution time of 10, 20 and 30 units, respectively. Each process spends the first 20% of execution time doing I/O, the next 70% of time doing computation, and the last 10% of time doing I/O again. The operating system uses a shortest remaining compute time first scheduling algorithm and schedules a new process either when the running process gets blocked on I/O or when the running process finishes its compute burst. Assume that all I/O operations can be overlapped as much as possible. For what percentage of time does the CPU remain idle? (A) 0% (B) 10.6% (C) 30.0% (D) 89.4%
  • 33. SRTF Example Explanation: Let three processes be p0, p1 and p2. Their execution time is 10, 20 and 30 respectively. p0 spends first 2 time units in I/O, 7 units of CPU time and finally 1 unit in I/O. p1 spends first 4 units in I/O, 14 units of CPU time and finally 2 units in I/O. p2 spends first 6 units in I/O, 21 units of CPU time and finally 3 units in I/O. idle p0 p1 p2 idle 0 2 9 23 44 47 Total time spent = 47 Idle time = 2 + 3 = 5 Percentage of idle time = (5/47)*100 = 10.6 %
  • 34. Priority Scheduling  Priority is associated with each process.  CPU is allocated to the process with highest priority.  If 2 processes have same priority  FCFS Disadvantage: Starvation (Low priority Processes wait for long) Solution of Starvation: Aging: The priority of a process is gradually increased over time to prevent it from starving (waiting indefinitely).
  • 35. Priority Scheduling (Preemptive) Process Arrival Time Priority Burst Time Completion Time P1 1 5 4 P2 2 7 2 P3 3 4 3 Consider 4 as Highest and 7 as Lowest Priority
  • 36. Priority Scheduling (Preemptive) Process Arrival Time Priority Burst Time Completion Time P1 0 2 10 P2 2 1 5 P3 3 0 2 P4 5 3 20 Consider 0 as Lowest and 3 as Highest Priority
  • 37. Priority Scheduling (Preemptive) Process Arrival Time Priority Burst Time Completion Time P1 0 2 10 P2 2 1 5 P3 3 0 2 P4 5 3 20 Consider 3 as Lowest and 0 as Highest Priority
  • 38. Round Robin Scheduling  A Time Quantum is associated to all processes  Time Quantum: Maximum amount of time for which process can run once it is scheduled.  RR scheduling is always Pre-emptive.
  • 39. Round Robin Process Arrival Time Burst Time Completion Time P1 0 5 P2 1 7 P3 2 1 TQ: 2 Process Arrival Time Burst Time Completion Time P1 0 3 P2 3 4 P3 4 6
  • 40. Round Robin Process Arrival Time Burst Time Completion Time P1 0 4 P2 1 5 P3 2 2 P4 3 1 P5 4 6 P6 6 3 TQ: 2
  • 41. Round Robin Process Arrival Time Burst Time Completion Time P1 0 4 P2 1 5 P3 2 2 P4 3 1 P5 4 6 P6 6 3 TQ: 2
  • 42. Multilevel Queue Scheduling Partition the ready queue into several separate queues. For Example: a multilevel queue scheduling algorithm with five queue: 1. System processes 2. Interactive processes 3. Interactive editing processes 4. Batch processes 5. Student/ user processes
  • 43. Multilevel Queue  A process moves between various queues.  Multilevel Queue Scheduler defined by parameters.  Number of queues is defined here.  Scheduling algorithms for each queue specified.  Method determines when to upgrade process.  Method decides which queue gets service.
  • 46. Multilevel Queue 1. System Processes: These are programs that belong to OS (System Files) 2. Interactive Processes: Real-Time Processes e.g. playing games online, listening to music online, etc. 3. Batch Processes: Lots of processes are pooled and one process at a time is selected for execution. I/O by Punch Cards 4. Student/User Processes
  • 47. Multilevel Queue  No process in the batch queue could run unless the other queues for the system were empty.  If an interactive editing process entered the ready queue while a batch process was running, the batch process would be preempted.
  • 48. Multilevel Queue  Processes can be :  Foreground Process: processes that are running currently  Background Process: Processes that are running in the background but their effects are not visible to the user.  Processes are permanently assigned to one queue on some properties:  memory size, process priority, process type.  Each queue has its own scheduling algorithm
  • 49. Multilevel Queue  Different types of processes exist, So  Cannot apply same scheduling algorithm. Disadvantages: 1. Until high priority queue is not empty, 2. No process from lower priority queues will be selected. 3. Starvation for lower priority processes. Advantage: Can apply separate scheduling algorithm for each queue.
  • 50. Multilevel Feedback Queue  Solution is: Multilevel Feedback Queue  If a process is taking too long to execute..  Pre-empt it send it to low priority queue.  Don’t allow a low priority process to wait for long.  After some time move the least priority process to high priority queue  Aging
  • 53. Multi-processor Scheduling Concerns: • Multiple CPUs enable load sharing. • Focus is on homogeneous processors' systems. • Use any processor for any process. • Various types of limitations exist. • Systems with I/O devices have restrictions. • Devices must run on specific processors.
  • 55. Approaches to Multiple-Processor Scheduling 1. Asymmetric multiprocessing •Scheduling decisions, I/O processing handled by server. •Other processors execute only user code. •One processor accesses system data structures. •Reduces the need for data sharing. •Single processor controls system activities efficiently. •Improves data management, reducing conflicts.
  • 56. Approaches to Multiple-Processor Scheduling  2. Symmetric multiprocessing (SMP)  Each processor is self-scheduling and efficient.  All processes may share a common queue.  Each processor may have a private queue.  Schedulers examine queues and select processes.  Modern operating systems widely support SMP.  Like, Windows, Linux, Mac OS X included.
  • 57. Issues concerning SMP systems  1. Processor Affinity (a process has an affinity for the processor on which it is currently running.)  Consider what happens to cache memory when a process has been running on a specific processor. The data most recently accessed by the process populate the cache for the processor. As a result, successive memory accesses by the process are often in cache memory.
  • 58. Issues concerning SMP systems 1. Processor Affinity  If the process migrates to another processor.  The contents of cache memory must be invalidated for the first processor, and the cache for the second processor must be repopulated.
  • 59. Issues concerning SMP systems 1. Processor Affinity High cost of invalidating and repopulating caches. Most SMP systems avoid process migration entirely. They attempt to keep processes running consistently. This concept is called processor affinity generally. A process has affinity for its processor. It runs on the same processor continuously.
  • 60. Issues concerning SMP systems Forms of Processor Affinity 1. Soft affinity • An OS tries keeping processes on the same processor. • This is called soft affinity policy. 2. Hard affinity • The OS tries to keep processes stable. • Processes may migrate between different processors.
  • 61. Issues concerning SMP systems 2. Load Balancing •On SMP systems, workload balance is important. •All processors should be fully utilized efficiently. •Load balancing prevents some processors from idling. •High workloads may burden specific processors excessively. •Idle processors waste system resources and efficiency. •Balanced workloads maximize the system's overall performance.
  • 62. Issues concerning SMP systems 2. Load Balancing Two approaches to load balancing: push migration and pull migration. 1. Push migration: a specific task periodically checks the load on each processor and—if it finds an imbalance—evenly distributes the load by moving (or pushing) processes from overloaded to idle or less-busy processors. 2. Pull migration: occurs when an idle processor pulls a waiting task from a busy processor.
  • 63. Issues concerning SMP systems 3. Multicore Processors •A multi-core processor has independent cores. •It reads and executes program instructions. •A CPU may contain multiple cores. •A core includes registers and cache. •Core handles processor tasks, not entire. •It's essential for efficient task performance.
  • 64. Issues concerning SMP systems 3. Multicore Processors Multicore processors may complicate scheduling issues: When a processor accesses memory, it spends a significant amount of time waiting for the data to become available. This situation, known as a memory stall. Memory Stall may occur due to a cache miss (accessing data that are not in cache memory).
  • 65. Issues concerning SMP systems Memory Stall the processor can spend up to 50 percent of its time waiting for data to become available from memory.
  • 66. Real Time Scheduling Analysis and testing of the scheduler system and the algorithms used in real-time applications a) soft real-time systems b) hard real-time systems a)Soft real-time systems provide no guarantee as to when a critical real-time process will be scheduled. b)Hard real-time systems have stricter requirements. A task must be serviced by its deadline;
  • 67. Rate-Monotonic Scheduling • Rate-monotonic scheduling assigns tasks' priorities statically. • It uses a preemption-based scheduling policy efficiently. • RMS operates in real-time operating systems seamlessly. • Static priorities depend on task cycle duration. • Shorter cycles lead to higher job priority. • This ensures periodic tasks are scheduled optimally.
  • 68. Rate-Monotonic Scheduling rate-monotonic scheduling assumes that the processing time of a periodic process is the same for each CPU burst. For example Consider P1, P2 with time period 50,100 resp. and B.T 20,35 resp. Cal. CPU utilization of each process and total CPU utilization. Sol: CPU utilization=(Burst time/Time period)= (Ti/Pi) For P1: (20/50)=0.40 i.e 40% For P2: (35/100)=0.35 i.e 35% Total CPU utilization is 75%
  • 69. Earliest Deadline First Scheduling Earliest-deadline-first (EDF) scheduling dynamically assigns priorities according to deadline. The earlier the deadline, the higher the priority the later the deadline, the lower the priority. Under the EDF policy, when a process becomes runnable, it must announce its deadline requirements to the system.