C program on FCFS(First come first serve) in operating system.
What is first come first serve Scheduling (FCFS):-
In this scheduling algorithm we allocate CPU to process that comes first in the ready queue. That is, the process that comes first in the ready queue will gets the CPU first. So it’s called first come first serve algorithm.
It is Non preemptive it means in FCFS Scheduling once the CPU has been allocated to a process , the process keeps the CPU until it releases the CPU either by terminating or by requesting I/O.
Advantage:-
- Easy to implement
- Easy to understand
- The simplest form of a CPU scheduling algorithm
Disadvantage:-
- Average waiting time is often quite longer
- Because of its simplicity, FCFS is not very efficient
- Not an ideal technique for time-sharing systems
C program:-
Here I am going to give to two solution .In the first Code we will just use Array and in the second Code we will use structure .
Code 1:-
In this code we simply declare Some array for the arrival time , Burst time ,Waiting time , and turn around time .
First we take a input from the user which is number of process in the Ready queue.then After we take Arrival time and Burst time of all the process one by one.Aftet that we will calculate the waiting time and Turn Around time of all the process and store it in the Array WT and TT respectively .
Output:-
Code 2:-
In This Code first we create the structure for the process .Then after we declare an array of structure type .
cmpl_T stands for completion time of the process which we are calculating in the program.
Output:-
See more:-
- Program to find cycle in the graph
- Implementation of singly link list
- Implementation of queue by using link list
- Algorithm of quick sort
- stack by using link list
- program to find preorder post order and inorder of the binary search tree
- How to set limit in the floating value in python
- What is boolean data type
- How to print any character without using format specifier
- Very Cool numbers | Hacker earth solution
- Birthday party | Hacker earth solution
- Most frequent | hacker earth problem solution
- program to find symetric difference of two sets
- cost of balloons | Hacker earth problem solution
- Chacha o chacha | hacker earth problem solution
- jadu and dna | hacker earth solution
- Bricks game | hacker earth problem
- Anti-Palindrome strings | hacker earth solution
- connected components in the graph | hacker earth data structure
- odd one out || hacker earth problem solution
Good keep it up dear
How to give input for AT and BT? Im getting wrong output….