4. INTRODUCTION
▪ Welcome to this presentation on the shortest remaining time first (SRTF) scheduling algorithm. In today's
fast-paced world, computer systems are required to handle an ever-increasing number of processes, often
with limited resources. This is where CPU scheduling comes in - it is a method used by operating systems to
manage the allocation of the CPU among processes.
▪ SRTF is one of several CPU scheduling algorithms that are used to manage processes in a computer system.
It is designed to prioritize shorter processes, which can lead to higher throughput and shorter turnaround
times.
▪ In this presentation, we will explore how the SRTF algorithm works, its advantages and limitations, and how
it can be implemented in practice. We will also compare SRTF with other scheduling algorithms and provide
examples of SRTF scheduling in action.
▪ Let's dive into the world of CPU scheduling with SRTF!
5. WORKING(SRTF ALGORITHM)
The shortest remaining time first (SRTF) scheduling algorithm is a preemptive CPU scheduling algorithm that selects
the process with the smallest amount of remaining CPU burst time to execute next. The basic idea is to prioritize
shorter processes, which can help to reduce the average waiting time of processes in the ready queue.
The SRTF algorithm works by keeping track of the remaining CPU burst time for each process in the ready queue.
When a new process arrives or a running process is preempted, the algorithm selects the process with the smallest
remaining CPU burst time to execute next.
If a process with a shorter remaining CPU burst time arrives while a process is already executing, the currently
executing process is preempted, and the shorter process is executed instead. This ensures that the shortest process
always has priority.
Once a process completes its CPU burst, it is removed from the system, and the next shortest process in the ready
queue is selected. This process continues until all processes have completed.
It's important to note that SRTF scheduling is a preemptive algorithm, which means that a currently running process
can be interrupted if a shorter process arrives. This allows for better prioritization of shorter processes but can also
lead to more frequent context switches, which can impact system performance.
6. ADVANTAGES
1. Prioritizes shorter processes: SRTF scheduling prioritizes processes with shorter CPU burst times, which can help to
reduce the average waiting time of processes in the ready queue. This can lead to higher throughput and shorter
turnaround times.
2. Efficient use of CPU time: SRTF scheduling ensures that the shortest process always has priority, which can lead to
more efficient use of CPU time. This is because shorter processes can complete more quickly, freeing up the CPU for
other processes.
3. Fairness: SRTF scheduling ensures that shorter processes are given priority, which can help to ensure fairness in the
allocation of CPU time. This can be especially important in systems where processes have different levels of priority.
4. Low response time: SRTF scheduling can help to reduce the response time of processes. This is because shorter
processes are executed first, and therefore, they can complete more quickly and return a response to the user more
rapidly.
7. LIMITATIONS
1. Possibility of starvation: SRTF scheduling prioritizes shorter processes, which means that longer
processes may be left waiting indefinitely. This can lead to a situation known as starvation, where
a process is never allowed to execute, even though it is important.
2. High context switch overhead: SRTF scheduling is a preemptive algorithm, which means that a
currently running process can be interrupted if a shorter process arrives. This can lead to more
frequent context switches, which can impact system performance.
3. Difficulty in predicting CPU burst time: SRTF scheduling relies on accurate predictions of the
remaining CPU burst time for each process. However, it can be difficult to accurately predict CPU
burst times, which can lead to inefficiencies in the scheduling algorithm.
4. Complexity: SRTF scheduling is more complex than some other scheduling algorithms, which can
make it more difficult to implement and maintain.
8. EXAMPLES(REAL WORLD)
1. Operating systems: Many operating systems use SRTF scheduling or variants of it, such as the
shortest job next (SJN) algorithm, to manage the allocation of CPU time among processes.
2. Web servers: SRTF scheduling has been used in web servers to prioritize requests with shorter
response times, such as simple HTML requests, over requests with longer response times, such
as database queries.
3. Traffic management: SRTF scheduling has been used in traffic management systems to prioritize
shorter routes over longer ones, which can help to reduce congestion and improve traffic flow.
4. Manufacturing: SRTF scheduling has been used in manufacturing systems to prioritize shorter
production runs, which can help to improve efficiency and reduce downtime.
9. COMPARISON
1. First-come, first-served (FCFS): FCFS scheduling is a non-preemptive algorithm that executes
processes in the order they arrive in the ready queue. Unlike SRTF scheduling, FCFS does not
prioritize shorter processes and may result in longer waiting times for longer processes.
2. Round-robin (RR): RR scheduling is a preemptive algorithm that allocates a fixed time slice to
each process in the ready queue before switching to the next process. Unlike SRTF scheduling,
RR does not prioritize shorter processes and may result in longer waiting times for shorter
processes.
3. Priority scheduling: Priority scheduling is a preemptive or non-preemptive algorithm that assigns a
priority level to each process and executes higher-priority processes first. Unlike SRTF
scheduling, priority scheduling does not always prioritize shorter processes and may result in
longer waiting times for longer processes with higher priority levels.
4. Shortest job next (SJN): SJN scheduling is a non-preemptive algorithm that executes the shortest
process first. Like SRTF scheduling, SJN prioritizes shorter processes but does not take into
account the remaining CPU burst time of processes.
10. IMPLEMENTATION
▪ The implementation of the shortest remaining time first (SRTF) scheduling algorithm involves the
following steps:
1. Maintain a ready queue: Processes that are ready to run are placed in a queue, called the ready
queue.
2. Calculate remaining CPU burst time: The remaining CPU burst time for each process is calculated
based on its previous CPU burst time and the total time it has spent waiting in the ready queue.
3. Select the shortest process: The process with the shortest remaining CPU burst time is selected for
execution. If multiple processes have the same shortest remaining CPU burst time, the process that
arrived first is selected.
4. Preempt the current process: If a process with a shorter remaining CPU burst time arrives while a
process is executing, the current process is preempted and placed back into the ready queue.
5. Execute the selected process: The selected process is executed until its CPU burst time is complete
or it is preempted by a shorter process.
6. Repeat the process: Steps 2-5 are repeated until all processes have completed their execution.
11. CONCLUSION
The shortest remaining time first (SRTF) scheduling algorithm is a powerful tool for
optimizing the allocation of CPU time in computer systems. By prioritizing shorter processes
based on their remaining CPU burst time, SRTF scheduling can help to reduce waiting
times, improve efficiency, and ensure fairness in the allocation of CPU time. Compared to
other scheduling algorithms, SRTF scheduling stands out by its ability to prioritize shorter
processes, which is particularly useful in systems with a mix of short and long processes.
Although SRTF scheduling may not be suitable for all systems and situations, it remains a
popular and effective scheduling algorithm in many real-world applications. Whether you're
developing an operating system, managing a web server, or optimizing a manufacturing
process, SRTF scheduling can help to improve performance and efficiency. With its clear
benefits and proven track record, SRTF scheduling is an important tool for anyone involved
in computer systems and processes.