diff --git a/Codes/Group B/Assignment - 5/FCFS (Non-Preemptive).cpp b/Codes/Group B/Assignment - 5/FCFS (Non-Preemptive).cpp old mode 100644 new mode 100755 index d4cc495..9ceb16f --- a/Codes/Group B/Assignment - 5/FCFS (Non-Preemptive).cpp +++ b/Codes/Group B/Assignment - 5/FCFS (Non-Preemptive).cpp @@ -1,12 +1,14 @@ #include using namespace std; -struct fcfs{ - int burst, arrival, id, completion; +struct fcfs +{ + int burst, arrival, id, completion, waiting, turnaround, response; }; fcfs meh[30]; -class FCFS{ +class FCFS +{ public: int n; void fcfsIn(){ @@ -24,6 +26,7 @@ public: cout<<"P"< +#include // for INT_MAX using namespace std; struct sjf{ - int burst, arrival, id, completion; + int burst, arrival, id, completion, waiting, turnaround, response; bool active; }; + sjf meh[30]; class lesgo{ @@ -14,7 +16,7 @@ public: void sjfIn(){ cout<<"\nEnter number of processes: "; cin>>n; - for(int i = 0; i < n; i++){ + for(int i = 1; i <= n; i++){ cout<<"\nEnter arrival time of P"<>meh[i].arrival; cout<<"\nEnter burst time of P"< 0){ if(meh[i].burst < burst1){ burst1 = meh[i].burst; @@ -44,11 +46,19 @@ public: } } if(iddd != -1){ + // Mark the process as active + if(!meh[iddd].active) { + meh[iddd].response = k - meh[iddd].arrival; + meh[iddd].active = true; + } + cout<<"P"<