What is First Come First Served (FCFS) and C Program for FCFS Scheduling Algorithm
First Come First Served (FCFS) is a scheduling algorithm used in operating systems to allocate resources to processes in the order in which they arrive. In this algorithm, the process that arrives first is served first, and the process that arrives next is served next, and so on.
FCFS is a non-preemptive scheduling algorithm, which means that once a process starts running, it continues until it completes its execution or gets blocked by an event such as an input/output (I/O) operation. While FCFS is simple and easy to implement, it can lead to a problem called “convoy effect,” where a large process can hold up smaller processes that arrive later in the queue.
FCFS is commonly used for batch processing systems or applications where there is no need for interactivity between the user and the system. However, for systems where response time is important, FCFS may not be the best choice, and other scheduling algorithms such as Shortest Job First (SJF) or Round Robin (RR) may be more appropriate.
Overview of First Come First Served(FCFS)
First Come First Serve (FCFS) is an operating system scheduling algorithm that automatically executes requests and queued processes in order of arrival. It is the easiest and simplest CPU programming algorithm. In this type of algorithm, the processes that request the CPU first get the CPU allocation first. This is handled with a FIFO queue. The full form of FCFS is First Come First Serve.
FCFS stands for First Come First Serve. In the FCFS scheduling algorithm, the job that made it to the ready queue first is assigned to the CPU, then the job that came in second, and so on. We can say that the ready queue acts as a FIFO (First in, first out) queue, so the arriving jobs / processes are placed at the end of the queue.FCFS is a non-preemptive scheduling algorithm, as a process holds the CPU until it terminates or performs I / O. Therefore, if a longer job has been assigned to the CPU, many shorter jobs will have to be expected afterward. This algorithm is used in most batch operating systems.
Characteristics of FCFS method
- It supports non-preemptive and pre-emptive scheduling algorithm.
- Jobs are always executed on a first-come, first-serve basis.
- It is simple to implement and work.
- This process is low in performance, and the normal waiting time is too high.
Example of FCFS scheduling
A real life example of the FCFS method is buying a movie ticket at the ticket counter. In this scheduling algorithm, a person is served according to the shape of the queue. The person who gets to the queue first buys the ticket and then the next. This will continue until the last person in the queue buys the ticket. With this algorithm, the CPU process works in a similar way.
What is FCFS Scheduling
The First Arrival Arrival Scheduling (FCFS) algorithm simply schedules jobs according to their arrival time. The job that appears first in the ready queue will get the CPU first. The shorter the job arrival time, the sooner it will receive the CPU. FCFS scheduling can cause the starvation problem if the burst time of the first process is the longest among all jobs.
- First Come First Serve, is like FIFO (First in, first out) The data structure of the queue, where the data element that is added first to the queue, is the one that leaves the queue first.
- This is used in batch systems.
- It is easy to understand and implement programmatically, using a queue data structure, where a new process enters through the queue and the programmer selects the process from the beginning of the queue.
Advantages of FCFS
Here, are pros/benefits of using FCFS scheduling algorithm:
- The simplest form of a CPU scheduling algorithm
- Easy to program
- First come first served
Disadvantages of FCFS
Here, are cons/ drawbacks of using FCFS scheduling algorithm:
- It is a Non-Preemptive CPU scheduling algorithm, so after the process has been allocated to the CPU, it will never release the CPU until it finishes executing.
- The Average Waiting Time is high.
- Short processes that are at the back of the queue have to wait for the long process at the front to finish.
- Not an ideal technique for time-sharing systems.
- Because of its simplicity, FCFS is not very efficient.
What is C Program for FCFS Scheduling
First Come First Served (FCFS), also known as First In First Out (FIFO) is the CPU scheduling algorithm in which the CPU is assigned to processes in the order they are placed in queue ready.FCFS follows non-preemptive scheduling, which means that once the CPU is allocated to a process, it does not leave the CPU until the process is terminated or may stop due to some I / O interruption.
Also Read: What is the Blue Ocean Strategy