-
Notifications
You must be signed in to change notification settings - Fork 2
/
process.h
40 lines (30 loc) · 1.08 KB
/
process.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <iostream>
using namespace std;
#pragma once
struct entry{ /* Holds all information of a process in the pcb */
string proc_name;
int priority;
float arrival_time;
float cpu_time;
float exec_time=0.0; //current executed time
int io_times; //number of times i/o has to be executed
int io_exec=0; //number of times i/o has been executed
char proc_type;
bool flag=false; //flag for delaying process i/o
string status="RUNNING";
};
struct compareEntry{ /* overloading operator for comparison related to priority queue */
bool operator()(entry* one, entry* two){
return one->priority<two->priority; //maximum is top priority
}
};
struct compareCpu{ /* overloading operator for comparison related to priority queue */
bool operator()(entry* one, entry* two){
return one->cpu_time>two->cpu_time; //minimum is top priority
}
};
struct sortEntry{ /* overloading operator for comparison for sorting */
inline bool operator()(const entry& one, const entry& two){
return one.arrival_time<two.arrival_time;
}
};