Last active
August 24, 2022 18:22
-
-
Save AbhijithMallya/668a0352088e96af7bdb187004a507d3 to your computer and use it in GitHub Desktop.
Implementing FCFS in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
burst_time = [] | |
wait_time = [] | |
turn_around_time = [] | |
n = int(input(("Enter the total number of process :: "))) | |
print("Enter the Burst Time\n") | |
for i in range(n) : | |
item = int(input("P["+(i+1)+"] = ")) | |
burst_time.append(item) | |
""" | |
C Version | |
int main() { | |
int n,bt[20],wt[20],tat[20],avwt=0,avtat=0,i,j; | |
cout<<"Enter total number of processes(maximum 20):"; | |
cin>>n; | |
cout<<"\nEnter Process Burst Time "; | |
for (i=0;i<n;i++) { | |
cout<<"\nP["<<i+1<<"]:"; | |
cin>>bt[i]; | |
} | |
wt[0]=0; | |
for (i=1;i<n;i++) { | |
wt[i]=0; | |
for (j=0;j<i;j++) | |
wt[i]+=bt[j]; | |
} | |
cout<<"\nProcess\t\tBurst Time\t\tWaiting Timet\t\tTurnaround Time"; | |
for (i=0;i<n;i++) { | |
tat[i]=bt[i]+wt[i]; | |
avwt+=wt[i]; | |
avtat+=tat[i]; | |
cout<<"\nP["<<i+1<<"]"<<"\t\t"<<bt[i]<<"\t\t\t"<<wt[i]<<"\t\t\t"<<tat[i]; | |
} | |
avwt/=i; | |
avtat/=i; | |
cout<<"\nAverage Waiting Time:"<<avwt; | |
cout<<"\nAverage Turnaround Time:"<<avtat; | |
return 0; | |
} | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also Try Gant Chart