0% found this document useful (0 votes)
13 views19 pages

OS

Uploaded by

burzuyevrcb5
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)
13 views19 pages

OS

Uploaded by

burzuyevrcb5
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/ 19

Student: Rajab Burzuyev

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 Algorithms: Why Are They Important?


The primary goal of modern operating systems is to efficiently manage
resources while meeting the needs of users and applications. CPU
scheduling algorithms play a crucial role in achieving this goal.

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:

Ready State: The process is waiting in the queue to be assigned to


the CPU for execution.
Running State: The process is currently being executed by the CPU.
Waiting State: The process is waiting for resources or I/O operations
to complete.

Preemption: Preemption occurs when a currently executing process


is interrupted due to the arrival of a higher-priority process or when
its allocated time slice expires. Preemption is commonly used in
priority and round-robin scheduling algorithms.

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:

CPU Scheduling in UNIX


UNIX systems utilize advanced scheduling algorithms to
efficiently manage CPU resources in a multi-user and
multitasking environment. Common algorithms include:

• Time-Sharing: A round-robin-like approach where each


process is allocated a fixed time slice.
• Priority Scheduling: Processes are assigned priorities,
and higher-priority processes are scheduled first.
• Multilevel Feedback Queue: Processes can move
between queues based on their execution characteristics,
ensuring flexibility and responsiveness.

01/24/2025
Fair Distribution Mechanism and
Priorities:
UNIX implements a fair distribution
mechanism to balance CPU usage among
processes.

• Dynamic Priorities: Priorities are


dynamically adjusted based on process
behavior (e.g., CPU-bound or I/O-bound)
to prevent starvation and promote fairness.
• Nice Values: Users can influence process
priorities using nice values, with lower
values indicating higher priorities.
• Aging Mechanism: Older processes in the
queue gradually gain priority to ensure
they are eventually executed.
Comparison and
Evaluation

Advantages and Disadvantages of


Algorithms:
First Come, First Serve (FCFS):
• Advantages:
• Simple to implement.
• Predictable behavior.
• Disadvantages:
• Can cause the "convoy effect," leading to
longer waiting times for shorter processes.
• Not suitable for time-sharing
environments.
Shortest Job First
(SJF):

• 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

CPU scheduling is essential for ensuring


system efficiency, fairness, and
responsiveness. The choice of a
scheduling algorithm depends on the
specific requirements of the system, such
as workload type, performance goals,
and user expectations. UNIX's adaptive
scheduling mechanisms demonstrate
how combining multiple algorithms can
address diverse system needs, making it
a robust choice for multitasking and
multi-user environments.
References
• https://ggn.dronacharya.info/ITDept/Downloads/
QuestionBank/Odd/V%20sem/Lecture-8_Section-
B_SPSA.pdf
• https://www.geeksforgeeks.org/cpu-scheduling-in-
operating-systems/
• https://www.uio.no/studier/emner/matnat/ifi/IN3000/v23/
timeplan/cpu-scheduling.pdf

You might also like