Monday, 10 October 2016

First Come First Serve (FCFS) scheduling Algo. With C++ Program - (By-ANSHUL)

                  With this schema the process that request CPU First  is allocated the CPU first.
                The implementation of the First Come First Serve (FCFS) policy is easily managed with 
                FIFO queue.When a process enters into ready queue , its  PCB is linked onto the tail of                   the queue.When the CPU is free it is allocated to the process at the head of the queue,
                  the running process is then removed from the queue. 




The code of FCFS is simple to write and understand.FCFS is non-preemptive.


C++ Program  :-
        #include <iostream.h>
             #include <conio.h>
             void main()
     {
              int n,p[10],wt[10],t[10],i;
              clrscr();
              cout<<"Enter No. of process :"<<endl;
              cin>>n;
              cout<<"Enter Burst Time :"<<endl;
              for(i=0;i<n;i++)
              cin>>p[i];
              cout<<"Calclualting TAT & WT:"<<endl;
              t[0]=p[0];
              for(i=1;i<=n;i++)
     {    
              t[i]=t[i-1]+p[i];
              wt[i-1]=t[i-1]-p[i-1];
      }
              cout<<"Printing TAT & WT"<<endl;
              for(i=0;i<n;i++)
              cout<<"T["<<i+1<<"] ="<<t[i]<<" \t  w["<<i+1<<"] ="<<wt[i]<<endl;
               getch();
       }

No comments:

Post a Comment