template<typename S, typename T, typename E>
class FCFS< S, T, E >
Class which implements the FCFS scheduling algorithm.
- Template Parameters
-
S | Data type of Process ID |
T | Data type of Arrival time |
E | Data type of Burst time |
template<typename S , typename T , typename E >
vector< tuple< S, T, E, double, double, double > > FCFS< S, T, E >::scheduleForFcfs |
( |
| ) |
|
|
inline |
Algorithm for scheduling CPU processes according to the First Come First Serve(FCFS) scheduling algorithm.
FCFS is a non-preemptive algorithm in which the process which arrives first gets executed first. If two or more processes arrive together then the process with smaller process ID runs first (each process has a unique proces ID).
I used a min priority queue of tuples to accomplish this task. The processes are ordered by their arrival times. If arrival times of some processes are equal, then they are ordered by their process ID.
- Returns
- void
154 {
155
156 double timeElapsed = 0;
157
160
161
162
163 if (get<1>(cur) > timeElapsed) {
164 timeElapsed += get<1>(cur) - timeElapsed;
165 }
166
167
168 timeElapsed += get<2>(cur);
169
170
171
172 get<3>(cur) = timeElapsed;
173
174
175 get<4>(cur) = get<3>(cur) - get<1>(cur);
176
177
178 get<5>(cur) = get<4>(cur) - get<2>(cur);
179
180 result.push_back(cur);
182 }
183 return result;
184 }