First-Come-First-Served [FCFS] Scheduling:
    First-Come-First-Served algorithm is the simplest scheduling algorithm is the simplest scheduling algorithm. Processes are dispatched according to their arrival time on the ready queue. Being a no preemptive discipline, once a process has a CPU, it runs to completion. The FCFS scheduling is fair in the formal sense or human sense of fairness but it is unfair in the sense that long jobs make short jobs wait and unimportant jobs make important jobs wait.
    FCFS is more predictable than most of other schemes since it offers time. FCFS scheme is not useful in scheduling interactive users because it cannot guarantee good response time. The code for FCFS scheduling  is simple to write and understand. One of the major draw back of this scheme is that the average time is often quite long.
    The First-Come-First-Served algorithm is rarely used as a master scheme in modern operating systems but it is often embedded within other schemes.

Program to implement First-Come-First-Serve [FCFS] Scheduling:

#include<iostream.h>
#include<dos.h>
#include<conio.h>
void main()
{
    clrscr();
    char p_name[10];    //variable declaration
    int a_time[10],e_time[10],n;    //variable declaration
    cout<<endl<<"Enter the number of processes:";
    cin>>n;
    cout<<endl<<"Enter the names of the processes:";
    for(int i=0;i<n;i++)    //This loop reads the process names
        cin>>p_name[i];
    cout<<endl<<"Enter the process execution times:";
    for(i=0;i<n;i++)    //This loop reads the execution times of the processes
        cin>>e_time[i];
    cout<<endl<<"The processes to be executed in this order in FCFS algorithm:";
    for(i=0;i<n;i++)    //This loop executes the process order
    {
        cout<<endl<<p_name[i];
        sleep(e_time[i]);
        cout<<"\nprocess"<<i+1<<"finished";
    }
    getch();
}

Output:

0 comments: