Skip to main content

Program of FCFS - First come First Server (First come first Out) in c++

Program of FCFS - First come First out in c++

About FCFS

Operating System Design. The first come, first served (commonly called FIFO ‒ first in, first out) process scheduling algorithm is the simplest process scheduling algorithm. It is rarely used in modern operating systems, but is sometimes used inside of other scheduling systems.

Perhaps, 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 nonpreemptive discipline, once a process has a CPU, it runs to completion


Download C++ software Link || Dev C++ click On the Link Below.
Link: http://linkshrink.net/7Cd8Z1



Dev c++ : for coding in C/C++


Source Code of FCFS


  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n,bt[20],wt[20],tat[20],avwt=0,avtat=0,i,j;
  8.     cout<<"Enter total number of processes(maximum 20):";
  9.     cin>>n;
  10.  
  11.     cout<<"\nEnter Process Burst Time\n";
  12.     for(i=0;i<n;i++)
  13.     {
  14.         cout<<"P["<<i+1<<"]:";
  15.         cin>>bt[i];
  16.     }
  17.  
  18.     wt[0]=0;    //waiting time for first process is 0
  19.  
  20.     //calculating waiting time
  21.     for(i=1;i<n;i++)
  22.     {
  23.         wt[i]=0;
  24.         for(j=0;j<i;j++)
  25.             wt[i]+=bt[j];
  26.     }
  27.  
  28.     cout<<"\nProcess\t\tBurst Time\tWaiting Time\tTurnaround Time";
  29.  
  30.     //calculating turnaround time
  31.     for(i=0;i<n;i++)
  32.     {
  33.         tat[i]=bt[i]+wt[i];
  34.         avwt+=wt[i];
  35.         avtat+=tat[i];
  36.         cout<<"\nP["<<i+1<<"]"<<"\t\t"<<bt[i]<<"\t\t"<<wt[i]<<"\t\t"<<tat[i];
  37.     }
  38.  
  39.     avwt/=i;
  40.     avtat/=i;
  41.     cout<<"\n\nAverage Waiting Time:"<<avwt;
  42.     cout<<"\nAverage Turnaround Time:"<<avtat;
  43.  
  44.     return 0;
  45. }


ALSO Watch Video for Demo





I Hope you like Our Video..
dotclu
dot clu

=====Also Watch Our  Video========
SJF-Shortest Job First or SJN (shortest job Next) || C++ program of SJF with input | dot clu
https://youtu.be/zXA3oS5p1UM

Get started With C || First Program in C || C tutorial || Hello world program in C || dot clu
link: https://youtu.be/Oqyoe1nJNjE

Install Virtual BOX in your PC | create Virtual Machine | downloading link in description || dot clu
link:https://youtu.be/x9ijUzOUyiY

How to Install Hyper V in windows 7?
link: https://youtu.be/Y64Dr3YNCSw

What is Bitcoin? || Earn Bitcoin money with your Android phone || 100% working || dot clu || Hindi
link: https://youtu.be/HYQgDQrSC1I

Comments

Popular posts from this blog

Shortest Remaining Time First (SRTF) Program in C++ || dot clu

Shortest Remaining Time First (SRTF) Program in C++ || dot clu Shortest Remaining Time First (SRTF) Shortest Remaining Time First (SRTF) Algorithm is preemptive version of Shortest Job First Algorithm. In this current process is executed until it is completed or a new process is added having lower burst time compare to the the remaining time for current process. SRTF algorithm may lead to starvation, if processes with lower burst time continues to add to cpu scheduler then the current process will never get a chance to get executed. For example consider the following table Process Arrival Time Burst Time P1 0 10 P2 1 6 P3 2 9 P4 3 4 At time t=0, Process P1 will start get executing as it is only the process present at that time. Then at t=1, Process P2 added to the CPU scheduler, at this time remaining time(Burst time) for Process P1 gets 9, as Burst time of P2 is less than the remaining time of other processes (for now there is only process P1) therefore pro...

First Fit Program and Algorithm in C++ || dot clu

First Fit Program and Algorithm in C++ || dot clu First Fit Algorithm in C and C++ Here you will learn about first fit algorithm in C and C++ with program examples. There are various memory management schemes in operating system like first fit, best fit and worst fit. In this section we will talk about first fit scheme. Suggestion: 1. First Fit 2.  Best Fit 3.  Worst Fit What is First Fit Memory Management Scheme? In this scheme we check the blocks in a sequential manner which means we pick the first process then compare it’s size with first block size if it is less than size of block it is allocated otherwise we move to second block and so on. First Fit Algorithm Get no. of Processes and no. of blocks. After that get the size of each block and process requests. Now allocate processes if(block size >= process size) //allocate the process else //move on to next block Display the processes with the blocks that are allocated to a respective...

C++ Program For PRIORITY WITH NON - PREEMPTIVE Scheduling Algorithm || dot clu

C++ Program For PRIORITY WITH  NON - PREEMPTIVE Scheduling Algorithm It is important to distinguish  preemptive  from  non - preemptive scheduling algorithms.  Preemption  means the operating system moves a process from running to ready without the process requesting it. Without  preemption , the system implements ``run to completion (or yield or block)''. Non-Preemptive Scheduling Non-Preemptive Scheduling means once a process starts its execution or the CPU is processing a specific process it cannot be halted or in other words we cannot preempt (take control) the CPU to some other process. A computer system implementing this cannot support the execution of process in a multi task fashion. It executes all the processes in a sequential manner. It is not practical as all processes are not of same priority and are not always known to the system in advance. Source Code: #include <iostream> using namespace std; int main(...