Posts

Showing posts from February, 2012

First-Come, First-Served Scheduling Algorithm

♣ Try it Out :: #include<cstdio> #include<cstdlib> #include<iostream> #define FOR(i,N) for(int i=1; i<=N; i++) #define MAX 51 using namespace std; class CacheMemory { public: string process; int burst_time, arrival_time; int waiting_time, turn_arround_time; } P[MAX]; int n, start_time, end_time; void setInput(); void sortByArrivalTime(int); void FCFS(); void generateTime(); void waitingTime(); void turnAroundTime(); int main() { // freopen("fcfs.in", "r", stdin); setInput(); cout<<"\nGrantt chart of FCFS:"<<endl<<endl; cout<<"Process\t\tTime (milliseconds)"<<endl; cout<<"-------\t\t-------------------"<<endl; FCFS(); cout<<endl; generateTime(); waitingTime(); cout<<endl; turnAroundTime(); return(0); } void setInput() { cin>>n; FOR(i,n) cin>>P[i].process>>P[i]