From b8732506b1350bc3124def68e28b71369a11dc1b Mon Sep 17 00:00:00 2001 From: Nandhika Jhansi <91628798+Nandhika2003@users.noreply.github.com> Date: Sun, 1 Oct 2023 03:26:21 +0530 Subject: [PATCH] Create fcfs.cpp --- algorithms/scheduling-algorithms/fcfs.cpp | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 algorithms/scheduling-algorithms/fcfs.cpp diff --git a/algorithms/scheduling-algorithms/fcfs.cpp b/algorithms/scheduling-algorithms/fcfs.cpp new file mode 100644 index 00000000..70622f8b --- /dev/null +++ b/algorithms/scheduling-algorithms/fcfs.cpp @@ -0,0 +1,44 @@ +#include +using namespace std; + +void findWaitingTime(int processes[], int n, int bt[], int wt[]) { + wt[0] = 0; + for (int i = 1; i < n ; i++ ) + wt[i] = bt[i-1] + wt[i-1] ; +} + +void findTurnAroundTime( int processes[], int n, int bt[], int wt[], int tat[]) { + for (int i = 0; i < n ; i++) + tat[i] = bt[i] + wt[i]; +} + +void findavgTime( int processes[], int n, int bt[]) { + int wt[n], tat[n], total_wt = 0, total_tat = 0; + + + findWaitingTime(processes, n, bt, wt); + findTurnAroundTime(processes, n, bt, wt, tat); + + + cout << "Processes "<< " Burst time "<< " Completion time " + << " Turn around time " << " Waiting time\n"; + for (int i=0; i