# FCFS Disk Scheduling Algorithms

## Introduction

In computer operating systems, disk scheduling algorithms are used to manage the order in which input/output (I/O) requests are processed by the disk controller. One such algorithm is FCFS (First-Come, First-Served), which is a simple and straightforward scheduling algorithm that processes I/O requests in the order in which they arrive in the queue. In FCFS, when a process generates an I/O request, it is added to the end of the queue of pending requests. The disk controller then services the requests in the order they were added to the queue, with the oldest request being processed first. Once the request is processed, the disk controller removes it from the queue and sends a completion signal to the process that generated the request.

## What is FCFS Disk Scheduling Algorithms?

FCFS (First-Come, First-Served) Disk Scheduling Algorithm is a simple and easy-to-implement algorithm used in operating systems to manage input/output (I/O) requests from processes to access disk blocks. In this algorithm, the operating system processes the I/O requests in the order in which they arrive in the queue, without any reordering or prioritization.

When a process generates an I/O request, it is added to the end of the queue, and the operating system services the requests in the same order. The requests are serviced one by one until the entire queue is empty. This algorithm has the advantage of being fair, predictable, and requiring low overhead. However, it also has limitations, such as long waiting times for requests that arrive later and potential starvation of requests that are stuck behind long-running requests. FCFS may not be suitable for systems with a high volume of I/O requests or where requests have different priorities.

## Advantages of FCFS disk scheduling algorithm

Here are some advantages of the FCFS (First-Come, First-Served) disk scheduling algorithm, explained in points −

• Simplicity − FCFS is a simple algorithm that is easy to implement and understand. It does not require any complex calculations or heuristics.

• Fairness − FCFS provides fairness in processing I/O requests, as it processes them in the order in which they arrive in the queue. This ensures that all requests are processed eventually, and no request is unfairly prioritized over another.

• Low overhead − FCFS has low overhead, as it does not require any additional information or processing. It only requires a simple queue to store and process I/O requests.

• Predictability − FCFS provides predictable behavior, as the order of requests is predetermined based on the order in which they arrive in the queue. This makes it easier to predict the system's behavior and plan accordingly.

• No starvation − FCFS ensures that no request is starved, as it processes requests in the order in which they arrive in the queue. This ensures that even low-priority requests are processed eventually.

• No complex data structures − FCFS does not require any complex data structures, such as a priority queue or tree, to manage the queue. This makes it easier to implement and reduces the risk of errors.

• No unnecessary head movement − FCFS processes requests sequentially, which minimizes unnecessary head movement and can lead to better disk efficiency.

• No reordering of requests − FCFS does not reorder requests, which can be beneficial in certain scenarios, such as when processing requests for a real-time system where the order of requests is critical.

Overall, while FCFS has some limitations, it can be a suitable choice for systems with a low volume of I/O requests and a limited number of users. It is simple, fair, and predictable, and it ensures that all requests are eventually processed, making it a good choice for certain types of systems. However, for high-volume systems with a mix of long and short requests, other scheduling algorithms may provide better performance and efficiency.

## Disadvantages of FCFS disk scheduling algorithm

Here are some of the major disadvantages of the FCFS (First-Come, First-Served) disk scheduling algorithm, explained in points −

• Poor performance for long requests − Since FCFS processes requests in the order they arrive, long requests may have to wait for a long time before being processed, leading to higher response times. This can significantly impact the overall performance of the system, especially if there are many long requests in the queue.

• Inefficient disk usage − FCFS does not consider the location of the data on the disk, which can lead to inefficient disk usage as requests may not be processed in a way that optimizes disk access. This can result in longer waiting times for requests and increased disk access times.

• Limited scalability − The algorithm may not scale well in systems with a large number of I/O requests, as the queue can become overwhelmed, and the waiting time for requests can become excessively long. This can lead to decreased system performance and reduced efficiency.

• Convoy effect − When a single long request is being processed, all other requests have to wait, leading to a build-up of requests in the queue. This can lead to decreased system performance and reduced efficiency.

• No priority − FCFS does not provide any priority to any particular request or process, which can negatively impact the performance of the system. In some cases, certain requests may be more important than others, and FCFS does not provide any way to distinguish between them.

• No optimization for seek time − FCFS does not optimize the order of requests based on their location on the disk, which can lead to increased seek time and reduced efficiency.

• High average waiting time − FCFS can lead to a high average waiting time for requests, especially if the number of requests in the queue is high.

• Lack of adaptivity − FCFS is not adaptable to changes in the workload or the system's resources. This can lead to decreased performance and efficiency when the workload changes or the system resources become limited.

• No consideration for deadlines − FCFS does not take into account any deadlines for requests. This can lead to missed deadlines, which can be critical in real-time systems.

• No preemption − FCFS does not support preemption, which means that a request cannot be interrupted or stopped once it has started. This can lead to longer response times for critical requests.

Overall, while FCFS is a simple and easy-to-implement scheduling algorithm, it has several significant limitations that can negatively impact the performance and efficiency of the system. Therefore, it may not be the best choice for high-volume systems or systems with a mix of long and short requests. Other disk scheduling algorithms, such as Shortest Seek Time First (SSTF) and SCAN, can provide better performance and efficiency in such cases.

## Example and solution

Here's an example of how the FCFS disk scheduling algorithm works: Suppose there are four I/O requests, R1, R2, R3, and R4, arriving in the following order −

R1: track 10 R2: track 22 R3: track 15 R4: track 28

Assuming the disk head is initially at track 20, the queue for servicing these requests will look like this −

Queue: R1, R2, R3, R4

The disk arm will first move to track 10 to service request R1, then move to track 22 to service request R2, then move to track 15 to service request R3, and finally move to track 28 to service request R4.

The total head movement for this sequence will be: |20-10| + |22-10| + |15-22| + |28-15| = 35 + 12 + 7 + 13 = 67

Now let's consider a scenario where request R5 arrives with track 5 after R1 and before R2. The queue for servicing these requests will now look like this −

Queue: R1, R5, R2, R3, R4

Using the FCFS algorithm, the disk arm will first move to track 10 to service request R1, then move to track 5 to service request R5, then move to track 22 to service request R2, and so on.

The total head movement for this sequence will be: |20-10| + |5-10| + |22-5| + |15-22| + |28-15| = 10 + 5 + 17 + 7 + 13 = 52

In this example, we can see that the total head movement is reduced by 15 tracks when R5 is serviced before R2, compared to the original sequence. However, this is not always the case, and FCFS can result in long waiting times for some requests and potential starvation for others. In scenarios where requests have different priorities or a high volume of I/O requests, more sophisticated scheduling algorithms may be needed.

## Conclusion

In conclusion, FCFS disk scheduling algorithm is a simple and fair method for managing input/output requests to disk in operating systems. However, it has several disadvantages, including long waiting times for requests that arrive later and potential starvation of requests that are stuck behind long-running requests. It may not be suitable for systems with a high volume of I/O requests or where requests have different priorities. Despite its limitations, FCFS remains a fundamental algorithm and is often used as a basis for more sophisticated scheduling algorithms.

Updated on: 05-Apr-2023

3K+ Views

##### Kickstart Your Career

Get certified by completing the course