From 9321a80f862f01f90d7fa3d1fb399d369d5ed2c9 Mon Sep 17 00:00:00 2001 From: aayushdadhich0409 <83806731+aayushdadhich0409@users.noreply.github.com> Date: Mon, 10 Oct 2022 21:48:01 +0530 Subject: [PATCH] added operating system algorithm's in c --- algorithms/C/os_algos/fcfs.c | 27 +++++++++++++++++++++++++++ algorithms/C/os_algos/os_fcfs.md | 27 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 algorithms/C/os_algos/fcfs.c create mode 100644 algorithms/C/os_algos/os_fcfs.md diff --git a/algorithms/C/os_algos/fcfs.c b/algorithms/C/os_algos/fcfs.c new file mode 100644 index 00000000..43877dac --- /dev/null +++ b/algorithms/C/os_algos/fcfs.c @@ -0,0 +1,27 @@ +#include +int main(){ + int a,b,wt[10],bt[10],tat[10],n=4,i,j; + + for(i=0;i<=n;i++){ + printf("enter bt :%d\n",i); + scanf("%d",&bt[i]); + } + wt[0]=0; + tat[0] = wt[0]+bt[0]; + for(i=1;i<=n;i++){ + wt[i]=tat[i-1]; + tat[i]=bt[i]+wt[i]; + + } + printf("\nprocess\t\t burst time\t\t waiting time\t\t turn around time\n"); + for(j=0;j<=n;j++){ + printf("%d\t\t %d\t\t %d\t\t %d\t\t \n",j+1,bt[j],wt[j],tat[j]); + // printf("%d\t\t %d\t\t %d\t\t %d\t\t \n",j+1,bt[1],wt[1],tat[1]); + // printf("%d\t\t %d\t\t %d\t\t %d\t\t \n",j+1,bt[2],wt[2],tat[2]); + // printf("%d\t\t %d\t\t %d\t\t %d\t\t \n",j+1,bt[3],wt[3],tat[3]); + } + + +return 0; + +} \ No newline at end of file diff --git a/algorithms/C/os_algos/os_fcfs.md b/algorithms/C/os_algos/os_fcfs.md new file mode 100644 index 00000000..a3d5b84b --- /dev/null +++ b/algorithms/C/os_algos/os_fcfs.md @@ -0,0 +1,27 @@ + +# operating system algo's + +In this operating system folder, we can see the different tupes of scheduling algorithms used by CPU. + +1. FCFS (first come first serve alogrithm) + - + First come first serve (FCFS) scheduling algorithm simply schedules the jobs according to their arrival time. The job which comes first in the ready queue will get the CPU first. The lesser the arrival time of the job, the sooner will the job get the CPU. FCFS scheduling may cause the problem of starvation if the burst time of the first process is the longest among all the jobs. + + + + + +## Demo- output of FCFS_scheduling : + +![App Screenshot](https://media.geeksforgeeks.org/wp-content/uploads/20200910234944/FCFS.jpg) + + +## Documentation + +To know more about FCFS,[click here](https://www.geeksforgeeks.org/program-for-fcfs-cpu-scheduling-set-1/) + + +## Support + +For support, email aayushdadhich0409@gmail.com. +