Skip to content

Instantly share code, notes, and snippets.

@AbhijithMallya
Last active August 24, 2022 18:22
Show Gist options
  • Save AbhijithMallya/668a0352088e96af7bdb187004a507d3 to your computer and use it in GitHub Desktop.
Save AbhijithMallya/668a0352088e96af7bdb187004a507d3 to your computer and use it in GitHub Desktop.
Implementing FCFS in Python
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;
}
"""
@AbhijithMallya
Copy link
Author

Convert the C to Py code

@AbhijithMallya
Copy link
Author

Also Try Gant Chart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment