|
void | addProcess (S id, T arrival, E burst) |
| Adds the process to the ready queue if it isn't already there.
|
|
vector< tuple< S, T, E, double, double, double > > | scheduleForSJF () |
| Algorithm for scheduling CPU processes according to the Shortest Job First (SJF) scheduling algorithm.
|
|
void | printResult (const vector< tuple< S, T, E, double, double, double > > &processes) |
| Utility function for printing the status of each process after execution.
|
|
template<typename S, typename T, typename E>
class SJF< S, T, E >
Class which implements the SJF scheduling algorithm.
- Template Parameters
-
S | Data type of Process ID |
T | Data type of Arrival time |
E | Data type of Burst time |
Definition at line 96 of file non_preemptive_sjf_scheduling.cpp.
template<typename S, typename T, typename E>
vector< tuple< S, T, E, double, double, double > > SJF< S, T, E >::scheduleForSJF |
( |
| ) |
|
|
inline |
Algorithm for scheduling CPU processes according to the Shortest Job First (SJF) scheduling algorithm.
Non pre-emptive SJF is an algorithm that schedules processes based on the length of their burst times. The process with the smallest burst time is executed first.In a non-preemptive scheduling algorithm, once a process starts executing,it runs to completion without being interrupted.
I used a min priority queue because it allows you to efficiently pick the process with the smallest burst time in constant time, by maintaining a priority order where the shortest burst process is always at the front.
- Returns
- void
Definition at line 154 of file non_preemptive_sjf_scheduling.cpp.
154 {
155
157
160
161
162
165 }
166
167
169
170
171
173
174
176
177
179
180
182
183
185
186 result.push_back(
cur);
188 }
189 return result;
190 }