0% found this document useful (0 votes)
2 views

lecture 8

The document discusses CPU scheduling concepts including CPU-I/O burst cycles, scheduling criteria, and various scheduling algorithms such as First Come, First Served (FCFS), Shortest Job First (SJF), Priority Scheduling, and Round Robin (RR). It highlights the importance of optimizing CPU utilization, throughput, turnaround time, waiting time, and response time. Additionally, it addresses issues like starvation in priority scheduling and provides examples of average waiting and turnaround times for different scheduling methods.

Uploaded by

yushahabib25
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)
2 views

lecture 8

The document discusses CPU scheduling concepts including CPU-I/O burst cycles, scheduling criteria, and various scheduling algorithms such as First Come, First Served (FCFS), Shortest Job First (SJF), Priority Scheduling, and Round Robin (RR). It highlights the importance of optimizing CPU utilization, throughput, turnaround time, waiting time, and response time. Additionally, it addresses issues like starvation in priority scheduling and provides examples of average waiting and turnaround times for different scheduling methods.

Uploaded by

yushahabib25
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/ 26

CPU SCHEDULING

Basic Concepts
• Maximum CPU utilization obtained with multiprogramming
• CPU–I/O Burst Cycle –Process execution consists of a
cycle of CPU execution and I/O wait
• „CPU burst distribution
Alternating Sequence of CPU And I/O Bursts
CPU Scheduler
• Selects from among the processes in memory that are
ready to execute, and allocates the CPU to one of them „
• CPU scheduling decisions may take place when a
process:
1.Switches from running to waiting state
2.Switches from running to ready state
3.Switches from waiting to ready
4.Terminates
„Scheduling under 1 and 4 is non-preemptive
„All other scheduling is preemptive
Dispatcher
• Dispatcher module gives control of the CPU to the
process selected by the short-term scheduler; this
involves:
• switching context
• switching to user mode
• jumping to the proper location in the user program to
restart that program „
• Dispatch latency– time it takes for the dispatcher to stop
one process and start another running
Scheduling Criteria
• CPU utilization –keep the CPU as busy as possible „
• Throughput – of processes that complete their execution
per time unit „
• Turnaround time –amount of time to execute a particular
process
• „Waiting time –amount of time a process has been
waiting in the ready queue
• „Response time –amount of time it takes from when a
request was submitted until the first response is produced,
not output (for time-sharing environment)
Optimization Criteria
• Max CPU utilization „
• Max throughput
• „Min turnaround time „
• Min waiting time „
• Min response time
First Come, First-Served (FCFS) Scheduling
FCFS Scheduling (Cont.)
• Suppose that the processes arrive in the order
P2, P3, P1 „
The Gantt chart for the schedule is:

Waiting time for P1 =6;P 2= 0; P3 = 3


„Average waiting time: (6 + 0 + 3)/3 = 3 „
Much better than previous case „
Convoy effect short process behind long process
Shortest-Job-First (SJF) Scheduling
• Associate with each process the length of its next CPU
burst. Use these lengths to schedule the process with the
shortest time „Two schemes:
• Non-preemptive –once CPU given to the process it cannot
be preempted until completes its CPU burst
• preemptive –if a new process arrives with CPU burst
length less than remaining time of current executing
process, preempt. This scheme is know as the Shortest-
Remaining-Time-First (SRTF) „
• SJF is optimal –gives minimum average waiting time for a
given set of processes
Example of Non-Preemptive SJF
Example of Preemptive SJF
Priority Scheduling
• A priority number (integer) is associated with each
process „
• The CPU is allocated to the process with the highest
priority
Non-preemptive
• Average Turn Around time = (4 + 14 + 10 + 6 + 7) / 5 = 41
/ 5 = 8.2 unit
• Average waiting time = (0 + 11 + 9 + 1 + 5) / 5 = 26 / 5 =
5.2 unit
Preemptive
• Average Turn Around time = (15 + 11 + 1 + 5 + 6) / 5 =
38 / 5 = 7.6 unit
• Average waiting time = (11 + 8 + 0 + 0 + 4) / 5 = 23 / 5 =
4.6 unit

Continue…

• „Problem ≡Starvation –low priority processes may never


execute
• „Solution ≡Aging –as time progresses increase the
priority of the process
Round Robin (RR)
• Each process gets a small unit of CPU time (time
quantum), usually 10-100 milliseconds. After this time has
elapsed, the process is preempted and added to the end
of the ready queue.
• „If there are n processes in the ready queue and the time
quantum is q, then each process gets 1/n of the CPU time
in chunks of at most q time units at once. No process
waits more than (n-1)q time units. „
• Performance
• Q large ⇒FIFO
Example of RR with Time Quantum = 20
• Average Turn Around time = (8 + 17 + 4 + 6 + 17 + 13) / 6
= 65 / 6 = 10.84 unit
• Average waiting time = (4 + 12 + 2 + 5 + 11 + 10) / 6 =
44 / 6 = 7.33 unit
Class activity

• If the CPU scheduling policy is Round Robin with time


quantum = 3, calculate the average waiting time and
average turn around time.
Solution

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