Q:

C++ Program For First Come First Served (FCFS) Scheduling Algorithm

0
Explanation:-
 First Come First Served (FCFS) is a Non-Preemptive scheduling algorithm. FCFS follow the FIFO (First In First Out) rules that means when a process comes to CPU for executing, CPU executes the process without checking anything like in primitive scheduling algorithm. In other words, we can say that the First process will be executed either the execution time of the first process is higher than other or until the first process executing another process should wait for their turn. Below is the Brief description or Q&A of FCFS Non-Preemptive scheduling algorithm.
 
1. What is First Come First Served (FCFS) Scheduling Algorithm?.
2. How to Calculate Turn Around Time?.
3. How to Calculate Waiting Time?.
4. Example.
 
What is First Come First Served (FCFS) Scheduling Algorithm?.
 
First Come First Served (FCFS) is a Non-Preemptive scheduling algorithm for process execution in an operating system and easy to understand and poor performance (waiting time is higher), If the first process is taking time for execution than until finish first process rest of the process has to wait.
 
How to Calculate Turn Around Time?.
 
Turn Around Time = Completion Time – Arrival Time
 
With the help of this formula, we can calculate a Turn Around Time of all process in Queue.
 
How to Calculate Waiting Time?.
 
Waiting Time = Turn Around Time – Burst Time
 
This formula is used for calculating the waiting time for rest of process.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<stdio.h>
#include<string.h>

int strToint (char[]);

int main()
{

    while(1)
    {
    char str[10];
    int intNum;

    printf("\n\nEnter Integer Number: ");
    scanf("%s",str);

    intNum = strToint(str);

 if(intNum==0)
 {
 printf("\nEnter The Number Not String\n\n");
 }
 else
    {
     printf("\n\nEquivalent Integer Value: %d",intNum);
 }
 }
 
return 0;
}

int strToint (char str[])
{

    int i=0,sum=0;

    while(str[i] != '\0')
  {

        if(str[i] < 48 || str[i] > 57)
   {
            printf("\n\nCan't Convert Into Integer");
            return 0;
        }
        else
   {
            sum = sum*10 + (str[i] - 48);
            i++;
        }
    }

return sum;

}

return sum;

}

 

Output:

Enter The Total Number of Process: 5
 
Enter CBT of Process:
4
9
8
3

 

7
======================================================================
                        Gantt. Chart
======================================================================
[P1]    [P2]    [P3]    [P4]    [P5]
----------------------------------------------------------------------
 
0       4       13      21      24
 
======================================================================
Process     CBT   Waiting Time    Turn Around Time
======================================================================
 
[p1]          4           0               4
[p2]          9           4              13
[p3]          8          13              21
[p4]          3          21              24
[p5]          7          24              31
 
 
Average Awating Time: 12.4
Average Turn Around Time: 18.6

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now