First Come First Serve Algorithm C Program

 

Let us learn how to implement first come first serve algorithm in C programming with its explanation, output, advantages, disadvantages and much more.

What is First Come First Serve Disk Scheduling Algorithm?

The first come first serve algorithm is commonly abbreviated as FCFS algorithm. It primarily works on the First In First Out (FIFO) principle.

The incoming requests or jobs in the system queue are executed based on first come first served basis. This is a non-preemptive scheduling algorithm.

Therefore, once the CPU is allocated to a particular job, the job keeps on executing till it gets completed. The CPU cannot leave the current job before it gets completed. So, the CPU cannot move to another job in the queue.

The FCFS algorithm is usually represented using Gantt’s Chart on paper. However, the FCFS scheduling algorithm is not so efficient when it comes to performance optimization.

It is not optimized for time-sharing systems. The average waiting time for the first come first serve scheduling algorithm is highly dependent on the burst time of the jobs.

Advantages

  • Simple and easy to implement
  • Every process/job gets executed completely
  • Lower possibilities of starvation

Disadvantages

  • Poor performance due to high average waiting time
  • There is no option for pre-emption of a job.
  • Higher average turnaround time
  • In-efficient for time-sharing systems

Note: This FCFS Algorithm C program is compiled with GNU GCC compiler using Linux terminal on Linux Ubuntu operating system.

First Come First Serve CPU Scheduling Algorithm C Program

   

Output

C Program For First Come First Serve Algorithm

If you have any doubts about the implementation of FCFS program in C language, let us know about it in the comment section. Find more about it here.

CPU Scheduling Algorithms
Preemptive Shortest Job First Scheduling Algorithm
SCAN Disk Scheduling Algorithm
C SCAN Disk Scheduling Algorithm
Round Robin Scheduling Algorithm
Shortest Job First Scheduling Algorithm
Multi-Level Feedback Queue Scheduling Algorithm
Preemptive Priority Scheduling Algorithm
Non-Preemptive Priority Scheduling Scheduling Algorithm
Shortest Seek Time First Scheduling Algorithm

9 thoughts on “First Come First Serve Algorithm C Program

  1. Vikas Gandhi

    I think SJF algorithm is more efficient than the FCFS algorithm due to its turnaround time.

    Reply
  2. Vineet Daniel

    FCFS algorithm does not seem to process efficiently. Its turnaround time is too much compared to other scheduling algorithms. Which is the best scheduling algorithm for CPU Scheduling in C Programming?

    Reply
    1. Tushar Soni Post author

      There is no such thing as which is the best. It all depends upon what work you intend the CPU to process. However, here are some of the most efficient CPU Scheduling Algorithms which you can implement in C Programming as well.

      • Round Robin Scheduling
      • Priority Scheduling
      • Multi Level Queue Scheduling
      • Shortest Job First
      Reply
  3. Rahul Sharma

    Great Program. Works perfectly fine. But it is quite difficult to grasp. However, it helped in my submissions! ūüôā

    Reply
    1. Tushar Soni Post author

      Yes. It is a little difficult but not impossible. I would suggest you to solve few FCFS problems first. You will get the logic and converting it in a programming language would not be much harder then.

      Reply
  4. Rajiv Makhija

    Can I implement a preemptive FCFS algorithm in C programming? Please help.

    Reply
  5. Milind Kothari

    This is one of most basic disk schedulong algorithms and I do not recommend it to be used. They are way better cpu scheduling algorithms than this. See sjf, rr and many more.

    Reply
  6. Vineeth Daniel

    The FCFS CPU Scheduling Algorithm is rarely used nowadays. However, it is used with some other algorithms as a part and combined to form a new algorithm. For example, a situation can be handled better by both SJF and FCFS algorithms when used together.

    Reply

Let's Discuss