-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.h
63 lines (60 loc) · 2.29 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
#include <iostream>
#include <vector>
#include <cmath>
#include "cpuBurst.h"
class process
{
public:
process(int aState, int aPid, double aTime, std::vector<cpuBurst> aBurstList, int atotal_bursts, int abursts_completed, cpuBurst acurrently_on, int atotal_time, int aremaining_time, int atau);
process();
process(const process &i);
int pid;
// ACCESSORS
int getState() { return state; }
int getpID() { return pid; }
int getArrivialTime() { return arrival_time; }
int getTotalBursts() { return total_bursts; }
int getBurstsCompleted() { return bursts_completed; }
int getRemainingBursts() { return all_bursts.size(); }
int getRemainingTime() { return total_time - remaining_time; }
int getTau() { return tau; }
int CPU_use_time(){return total_time;}
cpuBurst &getCurrent();
double getWait() { return wait_queue; }
std::vector<cpuBurst> &getAllBursts() { return all_bursts; }
double getTurnaroundTime() { return turnaround_time; }
double getCompletionTime() { return completion_time; }
double getWaitTime() { return wait_time; }
bool operator<(const process &other) const { return pid < other.pid; }
double getSwitches(){return num_switches;}
// cpuBurst cpuBurst::getBurstAt(int i){return all_bursts[i]}
// MODIFIERS
void setWaitTime(double set_time) { wait_time = set_time; }
void setTurnaroundTime(double set_time) { turnaround_time = set_time; }
void setCompletionTime(double set_time) { completion_time = set_time; }
void removeBurst(cpuBurst removethis);
void setBurst(cpuBurst &setthis) { currently_on = setthis; }
void updateWaitTime() { wait_queue += 1; }
void decWaitTime(double time) {wait_queue -= time;}
void updateTau(double al, double time) {tau = ceil((al * time) + ((1-al) * tau)); }
void updateSwitches(double num){num_switches += num;}
//private member variables
private:
std::vector<cpuBurst> all_bursts;
cpuBurst currently_on;
int state;
double arrival_time;
double num_switches;
double wait_time;
double turnaround_time;
double completion_time;
int bursts_completed;
int total_bursts;
int remaining_time;
int total_time;
double wait_queue;
int tau;
int cpu_time;
};
//bools we will use in sorting
bool less_names();