OS
OS
University: ASOIU
Specialty: Information Security
Course: Operating Systems
Instructor: Vagif Salimov
Group: 692.23E
Topic : CPU scheduling algorithms
in UNIX
Presentation Plan
1.Introduction
2.CPU Scheduling Theory
3.CPU Scheduling Algorithms
4.CPU Scheduling in UNIX
5.Comparison and Evaluation
6.Conclusion
CPU Scheduling Algorithms
CPU scheduling ensures the optimal use of the computer system's central
processing unit (CPU). The main objectives of scheduling include
improving system performance, ensuring fair distribution of resources
among users, and minimizing process delays.
CPU Scheduling Theory
Process:
A process is the running or executing instance of a computer
program. Processes go through three primary states:
Waiting Time: The total time a process spends waiting in the queue
to be executed by the CPU. This represents how long a process
delays before receiving CPU time.
1
Turnaround Time:
The total time taken for a process to be created, executed,
and completed.
Formula:
Turnaround Time = Completion Time − Arrival Time
Response Time:
The time taken for a process to receive its first response or
for its execution to begin.
CPU Utilization:
The percentage of time the CPU is actively executing
processes. The goal is to maximize CPU utilization to
ensure efficient resource use.
Queue:
The scheduling queue where processes wait to be selected
for execution. Queues can follow different strategies, such
as FIFO (First In, First Out) or other scheduling principles
01/24/2025
Algorithms
CPU Scheduling
• First Come, First Serve (FCFS):
• Processes are scheduled in the order they arrive
in the ready queue.
• It is simple and straightforward but can lead to
the "convoy effect," where shorter processes wait
for longer ones to complete.
• Shortest Job First (SJF):
• The process with the shortest execution time is
scheduled first.
• It minimizes the average waiting time but
requires prior knowledge of process execution
times, which may not always be feasible.
01/24/2025
Priority Scheduling:
2
Each process is assigned a priority, and the CPU is allocated
to the process with the highest priority.
It can be preemptive or non-preemptive, but low-priority
processes may suffer from starvation unless aging is
implemented.
Round Robin (RR):
Processes are assigned CPU time slices (quantum) in a
circular order.
It is fair and suitable for time-sharing systems but requires
an optimal time quantum for efficiency.
Multilevel Queue Scheduling:
Processes are divided into multiple queues based on their
type or priority. Each queue may use a different scheduling
algorithm.
It is efficient for systems with varying process types but can
be complex to manage.
01/24/2025
Explanation of Algorithms Used in UNIX:
01/24/2025
Fair Distribution Mechanism and
Priorities:
UNIX implements a fair distribution
mechanism to balance CPU usage among
processes.
• Advantages:
• Minimizes average
waiting time.
• Efficient for batch
systems with
predictable job
durations.
• Disadvantages:
• Requires knowledge of
process execution times
in advance.
• Risk of starvation for
longer processes.
Priority Scheduling:
• Advantages:
• Flexibility to handle critical tasks with higher
priorities.
• Suitable for real-time systems.
• Disadvantages:
• Starvation of low-priority processes unless aging is
implemented.
• Complexity in managing dynamic priorities.
Round Robin (RR):
• Advantages:
• Fair and ensures no process is indefinitely
delayed.
• Suitable for interactive and time-sharing
systems.
• Disadvantages:
• Choosing an inappropriate time quantum can
either cause frequent context switches (if too
short) or delay processes (if too long).
Multilevel Queue
Scheduling:
• Advantages:
• Efficient for systems with
diverse process types (e.g.,
batch, interactive).
• Customizable scheduling
policies for each queue.
• Disadvantages:
• Complex to manage and
configure.
• Processes in lower-priority
queues may experience
delays.
Which Algorithm is Best for Different Scenarios?
FCFS:
Best for simple systems or batch processing with
similar-sized jobs.
SJF:
Ideal for batch systems where job durations are
predictable and short.
Priority Scheduling:
Suitable for systems with critical tasks that must be
completed quickly, such as real-time applications.
Round Robin:
Perfect for time-sharing and interactive systems where
fairness and responsiveness are key.
In summary, CPU scheduling plays a vital role in optimizing system
performance by managing how processes are allocated CPU time. Different
scheduling algorithms such as FCFS, SJF, Round Robin, and Multilevel Queue
each have their unique strengths and weaknesses, making them suitable for
different scenarios. UNIX systems, with their dynamic scheduling mechanisms,
provide flexibility and fairness in multi-user and multitasking environments.
Understanding the theory behind CPU scheduling, its key concepts, and the
various algorithms helps us appreciate how operating systems efficiently handle
system resources.
Conclusion