Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
85 views11 pages

Project CPU Scheduling

The document discusses CPU scheduling concepts and algorithms. It covers scheduling criteria like CPU utilization, throughput, turnaround time and waiting time. Common scheduling algorithms like First Come First Served (FCFS) are explained through examples showing the calculation of performance metrics for different process arrival scenarios. FCFS aims to maximize CPU utilization but can result in longer waiting times for shorter processes.

Uploaded by

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

Project CPU Scheduling

The document discusses CPU scheduling concepts and algorithms. It covers scheduling criteria like CPU utilization, throughput, turnaround time and waiting time. Common scheduling algorithms like First Come First Served (FCFS) are explained through examples showing the calculation of performance metrics for different process arrival scenarios. FCFS aims to maximize CPU utilization but can result in longer waiting times for shorter processes.

Uploaded by

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

CPU Scheduling

◼ Basic Concepts
◼ Scheduling Criteria
◼ Scheduling Algorithms
◼ Thread Scheduling
◼ Multiple-Processor Scheduling
◼ Real-Time CPU Scheduling
◼ Operating Systems Examples
◼ Algorithm Evaluation
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 followed by I/O burst
◼ CPU burst distribution is of main
concern
Histogram of CPU-burst Times
CPU Scheduler
◼ Short-term scheduler selects from among the processes in
ready queue, and allocates the CPU to one of them
⚫ Queue may be ordered in various ways
◼ 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 nonpreemptive
◼ All other scheduling is preemptive
⚫ Consider access to shared data
⚫ Consider preemption while in kernel mode
⚫ Consider interrupts occurring during crucial OS activities
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 –number 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)
Scheduling Algorithm Optimization Criteria

◼ Max CPU utilization


◼ Max throughput
◼ Min turnaround time
◼ Min waiting time
◼ Min response time
First- Come, First-Served (FCFS) Scheduling
Process Burst Time(ms)
P1 15
P2 8
P3 6
Order of Processes arrival : P1 , P2 , P3
Case 1: All the Processes are arrived at same time ( 0 ms)
Gantt Chart:
P1 P2 P3

0 15 23 29
Calculations :
Process Burst Time (BT) ms Arrival Time Completion Time Turn Around Time Waiting Time
Number (AT) ms (CT) ms (TAT=CT-AT) ms (WT=TAT-BT) ms

P1 15 0 15 15 0
P2 8 0 23 23 15
P3 6 0 29 29 23
Average =(15+23+29)/3 =(0+15+23)/3
=67/3=22.33 ms =38/3=12.67 ms
FCFS Scheduling Continued
• Case 2: Processes arrive at time 0 ms in order of P2, P3 and P1
• Gantt Chart
P2 P3 P1

0 8 14 29

Calculations
Process Burst Time (BT) Arrival Time Completion Time Turn Around Time Waiting Time
Number ms (AT) ms (CT) ms (TAT=CT-AT) ms (WT=TAT-BT) ms

P2 8 0 8 8 0

P3 6 0 14 14 8

P1 15 0 29 29 14

Average =(8+14+29)/3 =(0+8+14)/3


=51/3=17 ms =22/3=7.3 ms
FCFS Scheduling Continued
Case 3: Processes are arrived in order P1, P2, P3 at times 0 ms, 1 ms, 2 ms.

Gantt Chart:
P1 P2 P3
0 1 2 15 23 29
P1 Arrives
P2 Arrives
P3 Arrives

Calculations:
Process Burst Time (BT) ms Arrival Time Completion Time Turn Around Time Waiting Time
Number (AT) ms (CT) ms (TAT=CT-AT) ms (WT=TAT-BT) ms

P1 15 0 15 15 0

P2 8 1 23 22 14

P3 6 2 29 27 21

Average =(15+22+27)/3 =(0+14+21)/3


=64/3=21.33 ms =35/3=11.67 ms
FCFS Scheduling Continued
• Case 4: Processes are arrived in order P2, P3, P1 at times 0
ms, 1 ms, 2 ms.

• Gantt Chart:
P2 P3 P1

0 1 2 8 14 29
P2 Arrives
P3 Arrives
P1 Arrives
Calculations:
Process Burst Time (BT) ms Arrival Time Completion Time Turn Around Time Waiting Time
Number (AT) ms (CT) ms (TAT=CT-AT) ms (WT=TAT-BT) ms

P2 8 0 8 8 0

P3 6 1 14 13 7

P1 15 2 29 27 12

Average =(8+13+27)/3 =(0+7+12)/3


=48/3=16 ms =19/3=6.3 ms

You might also like