-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.h
68 lines (56 loc) · 1.21 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;
#ifndef process_def
#define process_def
static int pid_count = 1; // constructor
class process{
public:
unsigned int pid;
unsigned int cpu_burst;
unsigned int arrive;
unsigned int priority;
unsigned int waiting_time;
unsigned int done_time;
unsigned int bursted;
process(){
pid = pid_count++;
cpu_burst = rand()%2 + 1;
bursted = 0;
arrive = rand()%5;
priority = rand()%5 + 1;
waiting_time = 0;
done_time = 0;
}
process(const process& p) {
pid = p.pid;
cpu_burst = p.cpu_burst;
arrive = p.arrive;
priority = p.priority;
waiting_time = p.waiting_time;
done_time = p.done_time;
bursted = p.bursted;
pid_count--;
}
~process() {
}
process& operator= (const process &p) {
pid = p.pid;
cpu_burst = p.cpu_burst;
arrive = p.arrive;
priority = p.priority;
waiting_time = p.waiting_time;
done_time = p.done_time;
bursted = p.bursted;
}
bool operator> (const process& l) const { // for FIFO
return arrive > l.arrive;
}
bool operator< (const process& l) const {
return priority > l.priority;
}
};
void createProcess(vector <process> &p, int amount);
void printProcess(vector <process> p_list);
#endif