-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcess.java
More file actions
72 lines (64 loc) · 1.55 KB
/
Process.java
File metadata and controls
72 lines (64 loc) · 1.55 KB
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
69
70
71
72
/**
* Represent a process that uses memory
*/
public class Process implements Comparable<Process> {
private char pid;
private int size;
private int start_time;
private int end_time;
/**
* Default constructor
* @param pid The ASCII identifier of the new process
* @param size The amount of memory the process uses
* @param start_time The virtual time the process enters memory
* @param end_time The virtual time the process leaves memory
*/
public Process(char pid, int size, int start_time, int end_time) {
this.pid = pid;
this.size = size;
this.start_time = start_time;
this.end_time = end_time;
}
/**
* Get the PID of the process
* @return The PID of the process
*/
public char getPid() {
return pid;
}
/**
* Get the amount of memory the process needs
* @return The amount of memory the process takes up
*/
public int getSize() {
return size;
}
/**
* Get the virtual time at which the process enters memory
* @return The virtual time at which the process enters memory
*/
public int getStartTime() {
return start_time;
}
/**
* Get the virtual time at which the process leaves memory
* @return The virtual time at which the process leaves memory
*/
public int getEndTime() {
return end_time;
}
/**
* Compare this process with another process by start time
* @param o The other process
*/
@Override
public int compareTo(Process o) {
if (this.start_time < o.start_time) {
return -1;
} else if (this.start_time == o.start_time) {
return 0;
} else {
return 1;
}
}
}