-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProcess.java
157 lines (150 loc) · 5.85 KB
/
Process.java
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/* File: Process.java
* Author: Nicholas Steuart c3330826
* Date Created: 12/8/24
* Date Last Modified: 5/9/24
* Description: The Process class represents a process in a CPU scheduling simulation.
* Each process contains essential information that is used by various
* CPU scheduling algorithms to manage and prioritize execution order.
*/
public class Process
{
// CLASS VARIABLES //
private String pID; //Process ID
private int arrTime, srvTime, tickets, timeRemaining; //Arrival Time, ServeTime, Tickets, and Time Remaining before a process has finished executing
private int turnTime = 0, waitTime = 0, priority = 1, starvationTime = 0; //Turnaround Time, Wait Time, Priority of the Process, and time before a process must be priority boosted
// CONSTRUCTORS //
//PRE-CONDITION: No PRE-CONDITION
//POST-CONDITION: Class variables pID, arrTime, srvTime, tickets and timeRemaining instantiated with default values
public Process()
{
pID = "";
arrTime = 0;
srvTime = 0;
tickets = 0;
timeRemaining = 0;
}
//PRE-CONDITION:
//Parameter pID must be a String of the from pn where n is a positive integer
//Parameter arrTime must be a non-negative integer
//Parameter srvTime must be a positive integer
//Parameter tickets must be a positive integer
//POST-CONDITION: Specialised Constructor instantiated with parameters pID, arrTime, srvTime and tickets mutating their respective Class variables
public Process(String pID, int arrTime, int srvTime, int tickets)
{
this.pID = pID;
this.arrTime = arrTime;
this.srvTime = srvTime;
this.tickets = tickets;
timeRemaining = srvTime;
}
// MUTATORS //
//PRE-CONDITION: Process Constructor instantiated and Parameter pID must be a String of the form pn where n is a positive integer
//POST-CONDITION: Class variable pID mutated by parameter pID
public void setPID(String pID)
{
this.pID = pID;
}
//PRE-CONDITION: Process Constructor instantiated and Parameter arrTime must be a non-negative integer
//POST-CONDITION: Class variable arrTime mutated by parameter arrTime
public void setArrTime(int arrTime)
{
this.arrTime = arrTime;
}
//PRE-CONDITION: Process Constructor instantiated and Parameter srvTime must be a positive integer
//POST-CONDITION: Class variable srvTime mutated by parameter srvTime
public void setSrvTime(int srvTime)
{
this.srvTime = srvTime;
}
//PRE-CONDITION: Process Constructor instantiated and Parameter tickets must be a positive integer
//POST-CONDITION: Class variable tickets mutated by parameter tickets
public void setTickets(int tickets)
{
this.tickets = tickets;
}
//PRE-CONDITION: Process Constructor instantiated and Parameter turnTime must be a non-negative integer
//POST-CONDITION: Class variable turnTime mutated by parameter turnTime
public void setTurnTime(int turnTime)
{
this.turnTime = turnTime;
}
//PRE-CONDITION: Process Constructor instantiated and Parameter waitTime must be a non-negative integer
//POST-CONDITION: Class variable waitTime mutated by parameter waitTime
public void setWaitTime(int waitTime)
{
this.waitTime = waitTime;
}
//PRE-CONDITION: Process Constructor instantiated and Parameter timeRemaining must be a non-negative integer
//POST-CONDITION: Class variable timeRemaining mutated by parameter timeRemaining
public void setTimeRemaining(int timeRemaining)
{
this.timeRemaining = timeRemaining;
}
//PRE-CONDITION: Process Constructor instantiated and Parameter priority must be of the value 1, 2 or 3
//POST-CONDITION: Class variable priority mutated by parameter priority
public void setPriority(int priority)
{
this.priority = priority;
}
//PRE-CONDITION: Process Constructor instantiated and Parameter starvationTime must be a non-negative value
//POST-CONDITION: Class variable starvationTime mutated by parameter starvationTime
public void setStarvationTime(int starvationTime)
{
this.starvationTime = starvationTime;
}
// ACCESSORS //
//PRE-CONDITION: Process Constructor instantiated and pID must not be null
//POST-CONDITION: Class variable pID returned
public String getPID()
{
return pID;
}
//PRE-CONDITION: Process Constructor instantiated
//POST-CONDITION: Class variable arrTime returned
public int getArrTime()
{
return arrTime;
}
//PRE-CONDITION: Process Constructor instantiated
//POST-CONDITION: Class variable srvTime returned
public int getSrvTime()
{
return srvTime;
}
//PRE-CONDITION: Process Constructor instantiated
//POST-CONDITION: Class variable tickets returned
public int getTickets()
{
return tickets;
}
//PRE-CONDITION: Process Constructor instantiated and setTurnTime(turnTime) called at some point prior
//POST-CONDITION: Class variable turnTime returned
public int getTurnTime()
{
return turnTime;
}
//PRE-CONDITION: Process Constructor instantiated and setWaitTime(waitTime) called at some point prior
//POST-CONDITION: Class variable waitTime returned
public int getWaitTime()
{
return waitTime;
}
//PRE-CONDITION: Process Constructor instantiated
//POST-CONDITION: Class variable timeRemaining returned
public int getTimeRemaining()
{
return timeRemaining;
}
//PRE-CONDITION: Process Constructor instantiated
//POST-CONDITION: Class variable returned
public int getPriority()
{
return priority;
}
//PRE-CONDITION: Process Constructor instantiated
//POST-CONDITION: Class variable starvationTime returned
public int getStarvationTime()
{
return starvationTime;
}
}