A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/dd/dca/class_f_c_f_s.html below:

TheAlgorithms/C++: FCFS< S, T, E

Class which implements the FCFS scheduling algorithm. More...

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 > >  scheduleForFcfs ()   Algorithm for scheduling CPU processes according to the First Come First Serve(FCFS) scheduling algorithm.
void  printResult ()   Utility function for printing the status of each process after execution.
priority_queue< tuple< S, T, E, double, double, double >, vector< tuple< S, T, E, double, double, double > >, Compare< S, T, E > >  schedule vector< tuple< S, T, E, double, double, double > >  result unordered_set< S >  idList

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

Definition at line 98 of file fcfs_scheduling.cpp.

◆ addProcess()

template<typename S, typename T, typename E>

void FCFS< S, T, E >::addProcess ( S id, T arrival, E burst ) inline

Adds the process to the ready queue if it isn't already there.

Parameters
id Process ID arrival Arrival time of the process burst Burst time of the process
Returns
void

Definition at line 130 of file fcfs_scheduling.cpp.

130 {

131

132 if (idList.find(id) == idList.end()) {

136 idList.insert(id);

137 }

138 }

Class which implements the FCFS scheduling algorithm.

priority_queue< tuple< S, T, E, double, double, double >, vector< tuple< S, T, E, double, double, double > >, Compare< S, T, E > > schedule

◆ printResult()

template<typename S, typename T, typename E>

void FCFS< S, T, E >::printResult ( ) inline

Utility function for printing the status of each process after execution.

Returns
void

Definition at line 192 of file fcfs_scheduling.cpp.

192 {

193 cout

<<

"Status of all the proceses post completion is as follows:"

195

200

<<

"Waiting Time"

<<

endl

;

201

202 for

(

size_t i

{};

i

< result.size();

i

++) {

210 }

211 }

◆ scheduleForFcfs()

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

Definition at line 155 of file fcfs_scheduling.cpp.

155 {

156

158

161

162

163

166 }

167

168

170

171

172

174

175

177

178

180

181

result.push_back(

cur

);

183 }

184 return result;

185 }

◆ idList ◆ result

template<typename S, typename T, typename E>

vector<tuple<S, T, E, double, double, double> > FCFS< S, T, E >::result private

Definition at line 115 of file fcfs_scheduling.cpp.

◆ schedule

template<typename S, typename T, typename E>

priority_queue<tuple<S, T, E, double, double, double>, vector<tuple<S, T, E, double, double, double> >, Compare<S, T, E> > FCFS< S, T, E >::schedule private

Priority queue of schedules(stored as tuples) of processes. In each tuple 1st element: Process ID 2nd element: Arrival Time 3rd element: Burst time 4th element: Completion time 5th element: Turnaround time 6th element: Waiting time

Definition at line 112 of file fcfs_scheduling.cpp.

The documentation for this class was generated from the following file:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4