0% found this document useful (0 votes)
28 views2 pages

Fcfs

This code implements the FCFS (First Come First Serve) CPU scheduling algorithm. It takes the arrival time of each process as input, calculates the waiting time and turnaround time of each process, and displays the total and average waiting and turnaround times. The functions defined are: getdata() to input the arrival time and burst time of each process, display() to output the details of each process, waitTime() to calculate waiting time, and turnAroundTime() to calculate turnaround time. Main() calls these functions to get the input, display the output, and calculate the performance metrics for FCFS scheduling.

Uploaded by

duration123
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Fcfs

This code implements the FCFS (First Come First Serve) CPU scheduling algorithm. It takes the arrival time of each process as input, calculates the waiting time and turnaround time of each process, and displays the total and average waiting and turnaround times. The functions defined are: getdata() to input the arrival time and burst time of each process, display() to output the details of each process, waitTime() to calculate waiting time, and turnAroundTime() to calculate turnaround time. Main() calls these functions to get the input, display the output, and calculate the performance metrics for FCFS scheduling.

Uploaded by

duration123
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Ques:-

WAP to write c-code for FCFS algorithm by taking into account the arrival time

!include"stdio h# !include"conio h# void void void void dis$lay%&' getdata%&' wait(ime%&' turnAround(ime%&'

int n) a*+,,-)b*+,,-' int main%& . $rintf%/00000 FCFS % F12S( C345 F12S( S5265 & SC7589:1;< 000000=n=n/&' getdata%&' dis$lay%&' wait(ime%&' turnAround(ime%&' getch%&'

>

void getdata%& . char c' $rintf%/5nter the number of $rocess /&' scanf%/?d/)@n&' $rintf%/=n8o you need to enter the arrival time of $rocess *yAn- or *BA;-=n/&' scanf%/?s/)@c&' for%int iC,' i"n' iDD& . $rintf%/5nter the ?d $rocess burst time : /)iD+&' scanf%/?d/)@b*i-&' if%cCCEyE FF cCCEBE& . $rintf%/5nter the ?d $rocess arrival time : /)iD+&' scanf%/?d/)@a*i-&' > else . a*i-C,' > >

>

void dis$lay%& . $rintf%/=nP23C5SS=tG92S( (145=tA2216A: (145H=n/&'

for%int iC,' i"n' iDD& . $rintf%/ ?d=t > >

?d=t

?d=n/)iD+)b*i-)a*i-&'

void wait(ime%& . int w*+,,-' float totalWaitC,' w*,-C,' for%int iC+' i"n' iDD& . w*i-Cb*i-+--a*i-Dw*i-+-' totalWaitCw*i-DtotalWait' > $rintf%/=n(otal Waiting time C ?f/)totalWait&' $rintf%/=nAverage Waiting time C ?f/)totalWait&' > void turnAround(ime%& . int tat*+,,-' float total(atC,' tat*-+-C,' for%int iC,' i"n' iDD& . tat*i-Cb*i--a*i-Dtat*i-+-' total(atCtotal(atDtat*i-' > $rintf%/=n=n(otal (urn Around (ime%(A(& C ?f/)total(at&' $rintf%/=nAverage (urn Around (ime Avg %(A(& C ?f/)total(atAn&' >

You might also like