0% found this document useful (0 votes)
6 views3 pages

Q4 Write Programs To Implement The Following Scheduling Algorithms

The document provides a C++ implementation of the First-Come, First-Served (FCFS) scheduling algorithm. It includes functions to calculate waiting time, turnaround time, and average times for a set of processes with given burst times. The main function initializes processes and burst times, then calls the average time function to display the results.

Uploaded by

CS 73 Mohit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Q4 Write Programs To Implement The Following Scheduling Algorithms

The document provides a C++ implementation of the First-Come, First-Served (FCFS) scheduling algorithm. It includes functions to calculate waiting time, turnaround time, and average times for a set of processes with given burst times. The main function initializes processes and burst times, then calls the average time function to display the results.

Uploaded by

CS 73 Mohit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Q4 Write programs to implement the following scheduling algorithms

(I) FCFS

(II)Round Robin

CODE(I)-

#include<iostream>

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 "

<< " Waiting time " << " Turn around time\n";

for (int i=0; i<n; i++)

total_wt = total_wt + wt[i];

total_tat = total_tat + tat[i];

cout << " " << i+1 << "\t\t" << bt[i] <<"\t "

<< wt[i] <<"\t\t " << tat[i] <<endl;

cout << "Average waiting time = "

<< (float)total_wt / (float)n;

cout << "\nAverage turn around time = "

<< (float)total_tat / (float)n;

int main()

int processes[] = { 1, 2, 3};

int n = sizeof processes / sizeof processes[0];

int burst_time[] = {10, 5, 8};


findavgTime(processes, n, burst_time);

return 0;

You might also like