TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Class which implements the FCFS scheduling algorithm. More...
Public Member Functions | |
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. | |
Private Attributes | |
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 |
Class which implements the FCFS scheduling algorithm.
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.
|
inline |
Adds the process to the ready queue if it isn't already there.
id | Process ID |
arrival | Arrival time of the process |
burst | Burst time of the process |
Definition at line 130 of file fcfs_scheduling.cpp.
|
inline |
Utility function for printing the status of each process after execution.
Definition at line 192 of file fcfs_scheduling.cpp.
|
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.
Definition at line 155 of file fcfs_scheduling.cpp.
|
private |
Definition at line 119 of file fcfs_scheduling.cpp.
|
private |
Definition at line 115 of file fcfs_scheduling.cpp.
|
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.