CPU Scheduling in OS: Concepts, Performance Criteria & Types of Schedulers

Operating System · Chapter 14

CPU Scheduling in OS: Concepts, Performance Criteria & Types of Schedulers

A computer may have many processes ready to run, but the CPU cannot execute every ready process at exactly the same moment. The operating system therefore needs a way to decide which process should get the CPU next. This decision-making process is called CPU Scheduling in OS.

CPU scheduling looks difficult because students meet many terms together: ready queue, CPU burst, I/O burst, preemptive scheduling, non-preemptive scheduling, dispatcher, turnaround time, waiting time, response time, long-term scheduler, short-term scheduler and medium-term scheduler. In this chapter, we will connect all of them step by step instead of memorising separate definitions.

Quick Answer: CPU Scheduling in Operating System is the method used by the OS to select a process from the ready queue and give it the CPU. A good scheduling system tries to use the CPU efficiently, complete more work, reduce waiting and turnaround time, provide fast response, and keep process execution reasonably fair. The three commonly taught types of schedulers are long-term, short-term and medium-term schedulers.
Ready Queue
P1
P2
P3
P4

Many processes are ready, but the scheduler must decide who runs next.

⇢
CPU Scheduler
Processor
CPU Selected Process Runs

What Is CPU Scheduling in Operating System?

CPU Scheduling in OS: Concepts, Performance Criteria & Types of Schedulers

CPU Scheduling in Operating System is the process of selecting one process from the ready queue and allocating the CPU to that process.

The need for CPU scheduling appears because several processes may be ready for execution at the same time. The operating system needs a policy that tells it which process should run first, which process should wait and when the CPU should move to another process.

Simple Definition:
CPU scheduling is the method used by the operating system to decide which ready process gets the CPU next.

Why Is CPU Scheduling Needed?

1 Many processes may be waiting for CPU time.
2 Only a limited number of processor cores are available.
3 The OS must use CPU time efficiently and fairly.

If CPU scheduling did not exist, the operating system would not have a proper method for choosing between ready processes.

CPU Scheduling and Multiprogramming

CPU scheduling is closely connected with multiprogramming.

A process does not use the CPU continuously from start to finish. It may use the CPU, then request input or output, then wait, and later use the CPU again.

When one process waits for I/O, the operating system can give the CPU to another ready process instead of keeping the CPU idle.

Main idea: Multiprogramming tries to keep useful work available. CPU scheduling decides which ready process should use the CPU.

CPU Burst and I/O Burst Cycle

To understand CPU Scheduling in OS properly, you first need to understand the CPU-I/O burst cycle.

During its life, a process often moves between periods of CPU work and periods of I/O activity.

CPU Burst Process executes instructions
→
I/O Burst Waiting / performing I/O
→
CPU Burst CPU work again
→
I/O Burst Another I/O activity
→
CPU Burst Final CPU work

What Is CPU Burst?

A CPU burst is a period during which a process is actively executing instructions on the CPU.

What Is I/O Burst?

An I/O burst is a period during which the process is performing or waiting for input/output work instead of using the CPU.

Easy memory trick:
CPU Burst = process is calculating or executing.
I/O Burst = process is dealing with input/output.

CPU-Bound vs I/O-Bound Processes

Processes do not all behave in the same way. This matters when designing a CPU scheduling policy.

I/O-Bound Process

An I/O-bound process usually performs many I/O operations and often has relatively short CPU bursts.

Examples may include programs that frequently wait for user input, disk operations or network data.

Many short CPU periods mixed with I/O activity

CPU-Bound Process

A CPU-bound process spends more time performing calculations and usually has longer CPU bursts.

Examples may include heavy calculations, data processing or encoding tasks.

Longer CPU work with less frequent I/O

What Is Ready Queue in CPU Scheduling?

The ready queue contains processes that are ready to execute and are waiting for CPU time.

Ready Queue P1 · P2 · P3 · P4
→
CPU Scheduler Selects a ready process
→
CPU Selected process executes

The order of the ready queue depends on the CPU scheduling algorithm being used.

When Does CPU Scheduling Take Place?

CPU scheduling decisions are connected with changes in process state. The scheduler may need to act when a process changes from one state to another.

1
Running → Waiting
Example: process requests I/O.
2
Running → Ready
Example: process is preempted.
3
Waiting → Ready
Example: I/O finishes.
4
Running → Terminated
Process completes execution.

These transitions help explain the difference between preemptive and non-preemptive CPU scheduling.

Types of CPU Scheduling: Preemptive and Non-Preemptive

CPU scheduling is commonly divided into two broad approaches: preemptive scheduling and non-preemptive scheduling.

Preemptive Scheduling

In preemptive CPU scheduling, the operating system can take the CPU away from a currently running process and give it to another process.

This can happen because of a time-sharing rule, priority decision or another scheduling condition.

P1 P2 P1 P3

Notice how execution can move between processes before one process completely finishes.

Non-Preemptive Scheduling

In non-preemptive CPU scheduling, once a process gets the CPU, it normally keeps it until the process finishes its CPU burst by terminating or moving to a waiting state.

P1 P1 P1 P2

The running process is not normally forced out simply because another ready process arrives.

Point Preemptive Scheduling Non-Preemptive Scheduling
CPU can be taken away? Yes, according to scheduling rules. Normally no during the current CPU burst.
Response Can provide quicker response for interactive work. A long-running job can make others wait.
Context-switch overhead Can be higher because switches may happen more often. Usually fewer forced switches.
Examples Round Robin, SRTF, preemptive Priority FCFS, SJF, non-preemptive Priority

Types of Schedulers in Operating System

Students often confuse CPU scheduling algorithms with types of schedulers in OS.

They are not the same thing.

A scheduler is an operating-system component that makes scheduling decisions at a particular level.

OPERATING SYSTEM SCHEDULER CONTROL TOWER
Long-Term Scheduler Decides which jobs should be admitted into the system for execution. Runs less frequently
Short-Term Scheduler Chooses one process from the ready queue and selects it for CPU execution. Runs very frequently
Medium-Term Scheduler Temporarily removes or later reintroduces processes to control memory and multiprogramming. Runs when needed

1. Long-Term Scheduler in Operating System

1 LONG TERM

The long-term scheduler is also called the job scheduler.

Its main job is to decide which jobs or processes should be admitted into the system for execution.

By controlling how many processes enter the active system, the long-term scheduler can influence the degree of multiprogramming.

What Is Degree of Multiprogramming?

Degree of multiprogramming means the number of processes that are present in memory and competing for system resources.

Easy idea: Long-term scheduler decides “Which jobs should be allowed into the active processing system?”

Why Is Long-Term Scheduling Important?

If too many processes are admitted, the system may become heavily loaded. If too few are admitted, resources may not be used efficiently.

In traditional descriptions, the long-term scheduler may also try to maintain a useful mix of CPU-bound and I/O-bound processes.

2. Short-Term Scheduler in Operating System

2 SHORT TERM

The short-term scheduler is also commonly called the CPU scheduler.

It selects one process from the ready queue and decides which process should execute on the CPU next.

Because CPU scheduling decisions happen very frequently, the short-term scheduler must make decisions quickly.

One-line answer:
Short-term scheduler selects a process from the ready queue and chooses it for CPU execution.

3. Medium-Term Scheduler in Operating System

3 MEDIUM TERM

The medium-term scheduler helps manage processes that may be temporarily removed from active memory and later brought back.

This idea is commonly connected with suspension and swapping.

It can help reduce the number of active processes when the system needs to control memory pressure or the degree of multiprogramming.

Active Process In memory
→
Suspended / Swapped Temporarily removed
→
Reintroduced Can continue later

Long-Term vs Short-Term vs Medium-Term Scheduler

Point Long-Term Short-Term Medium-Term
Another name Job Scheduler CPU Scheduler Swapper / medium-term scheduling function
Main decision Which jobs enter active processing Which ready process gets CPU next Which processes should be suspended or resumed
Frequency Relatively low Very high As required
Speed requirement Less critical than short-term scheduler Must be very fast Moderate / situation dependent
Controls Admission and degree of multiprogramming CPU allocation Suspension and memory pressure

What Is Dispatcher in CPU Scheduling?

The CPU scheduler decides which process should run next, but another component is needed to actually give control of the CPU to that process.

That component is called the dispatcher.

🧠
CPU Scheduler

Makes the decision: “Run Process P2 next.”

→
⚡
Dispatcher

Carries out the decision and transfers CPU control to P2.

Main Work of a Dispatcher

A dispatcher may perform tasks such as:

  • performing the required context switch,
  • switching execution to the proper processor mode where required,
  • and transferring control to the correct instruction of the selected process.

What Is Dispatch Latency?

Dispatch latency is the time required to stop one process and start another selected process running.

Memory trick:
Scheduler = chooses.
Dispatcher = gives control.

CPU Scheduling and Context Switching

When CPU execution moves from one process to another, the operating system may need to save the state of the old process and restore the state of the new process.

This is called a context switch.

Process A Currently running
→
Context Switch Save A · Restore B
→
Process B Starts / continues

Context switching is necessary for multitasking, but it also has overhead because the CPU spends some time changing execution context instead of doing application work.

CPU Scheduling Criteria in Operating System

Different CPU scheduling algorithms can produce different results. We therefore need performance measurements to compare them.

These measurements are called CPU scheduling criteria or CPU scheduling performance criteria.

1

CPU Utilization

CPU utilization tells us how much of the available processor time is being used for useful CPU work.

In general, we want to keep CPU utilization high without making the system unhealthy or unresponsive.

CPU Utilization = Busy CPU Time / Total Time × 100
2

Throughput

Throughput means the number of processes or jobs completed during a given period of time.

Throughput = Completed Processes / Unit Time
3

Turnaround Time

Turnaround time is the total elapsed time from a process arriving until it finishes.

TAT = Completion Time − Arrival Time
4

Waiting Time

Waiting time is the total time a process spends waiting in the ready queue for CPU service.

WT = Turnaround Time − Total CPU Burst Time
5

Response Time

Response time measures how long a process waits before receiving its first CPU service or first response opportunity.

RT = First CPU Start Time − Arrival Time
6

Fairness

A scheduler should avoid allowing some processes to wait forever while other processes repeatedly receive CPU time.

Fairness has no single simple formula that fits every scheduler, but it is an important design goal.

Important CPU Scheduling Terms: AT, BT, CT, TAT, WT & RT

These short forms appear again and again in CPU scheduling numericals. Understand them before solving any Gantt chart question.

AT – Arrival Time
Time at which a process becomes ready and enters scheduling consideration.
BT – Burst Time
Total CPU execution time required in the simplified scheduling problem.
CT – Completion Time
Time at which the process finishes.
TAT – Turnaround Time
Total elapsed time from arrival to completion.
WT – Waiting Time
Total time spent waiting in the ready queue.
RT – Response Time
Time from arrival until the process gets CPU for the first time.

Simple CPU Scheduling Performance Example

Let us understand the formulas before moving to individual scheduling algorithms.

PERFORMANCE CRITERIA WORKBENCH
Process P1
Arrival = 2
Burst = 5
Starts
Time = 4
Completes
Time = 9

Step 1: Turnaround Time

TAT = Completion Time − Arrival Time
TAT = 9 − 2 = 7 units

Step 2: Waiting Time

WT = Turnaround Time − Burst Time
WT = 7 − 5 = 2 units

Step 3: Response Time

RT = First Start Time − Arrival Time
RT = 4 − 2 = 2 units
Important: Waiting time is not always just the time before a process first runs. In a preemptive algorithm, a process may return to the ready queue many times. Its waiting time includes all of those ready-queue waiting periods.

Average Waiting Time and Average Turnaround Time

When comparing CPU scheduling algorithms, questions often ask for average waiting time or average turnaround time.

Average Waiting Time:
Add the waiting times of all processes and divide by the number of processes.

Average Turnaround Time:
Add the turnaround times of all processes and divide by the number of processes.

Average Response Time:
Add the response times of all processes and divide by the number of processes.

What Should a Good CPU Scheduling Algorithm Try to Achieve?

↑ High CPU Utilization
↑ High Throughput
↓ Low Turnaround Time
↓ Low Waiting Time
↓ Low Response Time
✓ Reasonable Fairness

However, improving one measure can sometimes make another measure worse.

That is why there is no single CPU scheduling policy that is automatically the best for every type of computer system.

CPU Scheduling Goals for Different Types of Systems

Batch Systems

Throughput and turnaround time may be major concerns because many jobs need to be completed efficiently.

Interactive Systems

Response time becomes very important because users expect applications to react quickly.

Real-Time Systems

Meeting required timing constraints or deadlines can be more important than simply minimizing an average waiting time.

Main CPU Scheduling Algorithms in Operating System

CPU scheduling algorithms define the rule used to select the next ready process. Each algorithm handles the ready queue differently.

FCFS – First Come First Served

The process that arrives first gets CPU service first. It is simple but can suffer from the convoy effect when a long job delays shorter jobs.

Usually Non-Preemptive
SJF – Shortest Job First

The ready process with the smallest predicted CPU burst is selected first. It can produce a low average waiting time when burst lengths are known or estimated well.

Non-Preemptive Version
SRTF – Shortest Remaining Time First

This is the preemptive form of shortest-job scheduling. The process with the smallest remaining CPU time is preferred.

Preemptive
Priority Scheduling

CPU selection is based on process priority. Priority scheduling can be implemented in either preemptive or non-preemptive form.

Priority Based
Round Robin Scheduling

Every ready process gets a limited amount of CPU time called a time quantum or time slice.

If the process does not finish during its quantum, it can return to the ready queue.

Preemptive · Time Sharing
Multilevel Queue Scheduling

Processes are divided into separate ready queues, often according to process type or class. Different queues can use different scheduling policies.

Multiple Fixed Queues
Multilevel Feedback Queue

Processes can move between queues according to their behaviour and the rules of the scheduler. This gives the system more flexibility than fixed multilevel queues.

Dynamic Queues
HRRN – Highest Response Ratio Next

HRRN uses a response ratio that considers both waiting time and service time, helping older waiting jobs gain preference.

Response Ratio Based
These algorithms deserve separate numerical lessons because FCFS, SJF, SRTF, Priority and Round Robin questions usually involve Gantt charts and calculations. Here the goal is to understand where each algorithm fits inside CPU scheduling.

What Is Time Quantum in CPU Scheduling?

A time quantum, also called a time slice, is the limited amount of CPU time given to a process in scheduling approaches such as Round Robin.

P1 Quantum
P2 Quantum
P3 Quantum
P1 Next turn

If the time quantum is very large, Round Robin can begin to behave more like FCFS.

If the quantum is extremely small, processes may appear more responsive, but context-switch overhead can increase.

What Is Convoy Effect in CPU Scheduling?

The convoy effect can occur when a long CPU-bound process gets ahead of several short processes and makes them wait.

Long Process P1 Large CPU burst
→
CPU Busy P1 keeps CPU
→
P2 · P3 · P4 Short jobs wait behind it

FCFS scheduling is commonly used to explain this problem.

Starvation and Aging in CPU Scheduling

Some scheduling policies may repeatedly favour certain processes. This can create another problem called starvation.

Starvation

A process keeps waiting for a very long time because other processes repeatedly receive preference.

→

Aging

Aging gradually improves the priority of a process that has been waiting for a long time, helping it eventually receive CPU service.

Memory trick:
Starvation = process keeps waiting.
Aging = waiting process slowly gets better priority.

Fairness in CPU Scheduling

Fairness does not necessarily mean that every process receives exactly the same amount of CPU time.

Different processes can have different priorities, deadlines or scheduling classes. The main idea is that the scheduling policy should behave according to its defined goals without unnecessarily allowing eligible processes to wait forever.

Priority in CPU Scheduling

Some CPU scheduling systems assign a priority to processes. A scheduler can use this priority when deciding which process should execute next.

P1 Priority 3
·
P2 Priority 1
·
P3 Priority 5
Do not automatically assume that a larger number always means higher priority. The numeric convention depends on the system or the question. Always check what the question defines.

CPU Scheduling on Multi-Core Systems

The basic examples in this chapter often assume one CPU execution resource so that scheduling is easy to understand.

Modern systems may have several processor cores. The operating system then has additional scheduling decisions, such as deciding which runnable task should use which core and how work should be balanced.

Real operating systems can therefore use much more advanced scheduling designs than the simple classroom algorithms.

For semester exams, first understand the single-CPU scheduling model clearly. The same foundation helps you understand advanced multi-core scheduling later.

CPU Scheduling Overhead

Scheduling itself is useful, but it is not completely free.

The operating system needs time to make scheduling decisions, perform context switches and update process-management information.

Therefore, a scheduling policy should not create unnecessary switching just to improve one small performance measure.

Common Mistakes Students Make in CPU Scheduling

×
Thinking the CPU scheduler and dispatcher are the same.
Scheduler selects the process. Dispatcher gives CPU control to it.
×
Thinking waiting time means only initial waiting.
A preempted process can wait in the ready queue several times.
×
Confusing turnaround time with response time.
Turnaround ends when the process finishes. Response time only measures how long it waited for its first service.
×
Thinking every scheduler means a scheduling algorithm.
Long-term, short-term and medium-term schedulers describe scheduling roles, while FCFS, SJF and Round Robin are scheduling policies or algorithms.
×
Thinking preemptive always means better.
It can improve responsiveness, but it can also increase switching overhead.
×
Thinking one scheduling algorithm is best everywhere.
The best policy depends on workload and system goals.

Complete CPU Scheduling Flow in Simple Words

1 READY
Processes that can run wait in the ready queue.
2 SELECT
The short-term / CPU scheduler selects one process according to the scheduling algorithm.
3 DISPATCH
The dispatcher transfers CPU control to the selected process.
4 RUN
The process executes its CPU burst.
5 CHANGE
The process may finish, wait for I/O, be preempted or later return to the ready queue.

CPU Scheduling in OS Exam Preparation

OPERATING SYSTEM · CPU SCHEDULING EXAM MODE

For a 2-Mark Question

Answer: CPU Scheduling in OS is the process of selecting one process from the ready queue and allocating the CPU to it. Its main aim is to use CPU time efficiently and improve system performance.

For a 5-Mark Question

Write:

  1. definition of CPU scheduling,
  2. need for CPU scheduling,
  3. ready queue,
  4. preemptive and non-preemptive scheduling,
  5. main CPU scheduling criteria.

For an 8–10 Mark Question

Explain in this order:

  1. meaning of CPU Scheduling in Operating System,
  2. need and multiprogramming connection,
  3. CPU-I/O burst cycle,
  4. CPU-bound and I/O-bound processes,
  5. ready queue,
  6. scheduling decision points,
  7. preemptive vs non-preemptive scheduling,
  8. long-term scheduler,
  9. short-term scheduler,
  10. medium-term scheduler,
  11. dispatcher and dispatch latency,
  12. CPU scheduling criteria,
  13. CPU utilization, throughput, turnaround, waiting and response time,
  14. brief overview of scheduling algorithms.

CPU Scheduling Practice Questions

Q1. What is CPU Scheduling in Operating System?
Q2. Why is CPU scheduling required?
Q3. What is a CPU burst?
Q4. What is the difference between CPU-bound and I/O-bound processes?
Q5. What is the ready queue?
Q6. Explain preemptive and non-preemptive CPU scheduling.
Q7. What are the three types of schedulers in OS?
Q8. What is the difference between long-term and short-term scheduler?
Q9. What is medium-term scheduling?
Q10. What is a dispatcher?
Q11. What is dispatch latency?
Q12. Define CPU utilization and throughput.
Q13. Write the formula for turnaround time.
Q14. Write the formula for waiting time.
Q15. What is response time?
Q16. What is time quantum?
Q17. What is starvation in CPU scheduling?
Q18. How does aging reduce starvation?
Q19. What is convoy effect?
Q20. Why is there no single best CPU scheduling algorithm for every system?

CPU Scheduling Quick Revision

CPU Scheduling: decides which ready process gets CPU next.
Ready Queue: contains processes waiting for CPU.
CPU Burst: period of CPU execution.
I/O Burst: period of I/O activity or waiting.
Preemptive: CPU can be taken from a running process.
Non-Preemptive: running process normally keeps CPU until burst ends.
Long-Term Scheduler: controls admission of jobs.
Short-Term Scheduler: chooses next ready process.
Medium-Term Scheduler: helps suspend and resume processes.
Dispatcher: gives CPU control to selected process.
CPU Utilization: percentage of time CPU is busy.
Throughput: completed jobs per unit time.
TAT: CT − AT.
WT: TAT − BT in the standard single-burst calculation.
RT: First CPU Start − AT.
Time Quantum: CPU time slice used in Round Robin.
Starvation: process waits excessively long.
Aging: gradually improves priority of waiting processes.
Convoy Effect: short jobs wait behind a long job.
Context Switch: CPU changes from one execution context to another.

Frequently Asked Questions About CPU Scheduling in OS

What is CPU Scheduling in OS?

CPU Scheduling in OS is the method used by the operating system to select a ready process and allocate the CPU to it.

Why is CPU scheduling required?

CPU scheduling is required because multiple processes may be ready at the same time, while available CPU execution resources are limited. The operating system therefore needs a rule for deciding which process runs next.

What are the main types of CPU scheduling?

CPU scheduling is commonly classified as preemptive scheduling and non-preemptive scheduling.

What are the three types of schedulers in Operating System?

The three commonly taught types are long-term scheduler, short-term scheduler and medium-term scheduler.

What is a short-term scheduler?

The short-term scheduler, also called the CPU scheduler, selects a process from the ready queue for CPU execution.

What is a long-term scheduler?

The long-term scheduler or job scheduler decides which jobs should be admitted into the active system and influences the degree of multiprogramming.

What is a medium-term scheduler?

The medium-term scheduler helps temporarily suspend or later reintroduce processes, often to manage memory pressure and the degree of multiprogramming.

What is dispatcher in CPU scheduling?

The dispatcher is the operating-system component that transfers CPU control to the process selected by the CPU scheduler.

What are the main CPU scheduling criteria?

Important CPU scheduling criteria include CPU utilization, throughput, turnaround time, waiting time, response time and fairness.

What is turnaround time in CPU scheduling?

Turnaround time is the total elapsed time from process arrival to process completion. It is commonly calculated as Completion Time minus Arrival Time.

What is waiting time in CPU scheduling?

Waiting time is the total time a process spends waiting in the ready queue. In standard scheduling numericals, it can be calculated as Turnaround Time minus total CPU Burst Time.

What is response time in CPU scheduling?

Response time is the time from process arrival until the process receives CPU service for the first time.

What is CPU utilization?

CPU utilization represents the proportion of total time during which the CPU is busy performing useful execution work.

What is throughput in CPU scheduling?

Throughput is the number of processes or jobs completed during a unit of time.

What is time quantum?

Time quantum is the limited CPU time slice assigned to a process in scheduling methods such as Round Robin.

What is starvation in CPU scheduling?

Starvation occurs when a process waits for an excessively long time because other processes continue to receive scheduling preference.

What is aging in CPU scheduling?

Aging is a technique that gradually increases the priority of a process that has been waiting for a long time, helping reduce starvation.

Which CPU scheduling algorithm is best?

There is no single CPU scheduling algorithm that is best for every workload. Different systems may prioritize throughput, response time, deadlines, fairness or other goals.

Conclusion

CPU Scheduling in OS becomes much easier when you see the complete flow instead of memorising separate definitions. Several processes may wait in the ready queue. The CPU scheduler selects one of them, and the dispatcher gives CPU control to that process.

A process normally moves through CPU bursts and I/O bursts, so the operating system repeatedly gets chances to schedule other work. Depending on the scheduling policy, CPU allocation can be preemptive or non-preemptive.

The main types of schedulers in Operating System are the long-term scheduler, short-term scheduler and medium-term scheduler. They work at different levels: admitting jobs, selecting the next ready process, and controlling suspension or reintroduction of processes.

Finally, CPU scheduling performance is measured using criteria such as CPU utilization, throughput, turnaround time, waiting time and response time. Once these concepts are clear, algorithms such as FCFS, SJF, SRTF, Priority, Round Robin, Multilevel Queue and Multilevel Feedback Queue become much easier to learn.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Join Telegram Exam updates and free resources