-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScheduler.cpp
More file actions
60 lines (49 loc) · 1.38 KB
/
Copy pathScheduler.cpp
File metadata and controls
60 lines (49 loc) · 1.38 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
#include "Scheduler.hpp"
RoundRobin::RoundRobin() {
procQueue = new ArrayList<Process *>();
}
RoundRobin::~RoundRobin() {
delete procQueue;
}
void RoundRobin::addProcess(Process* proc) {
procQueue->pushBack(proc);
}
Process* RoundRobin::popNext(int curCycle) {
Process* result = procQueue->getFront(), *first = result;
procQueue->popFront();
while (result != NULL && result->isBlocked(curCycle)) {
procQueue->pushBack(result);
result = procQueue->getFront();
procQueue->popFront();
if (result == first) {
return NULL;
}
}
return result;
}
FastRoundRobin::FastRoundRobin() {
delete procQueue;
procQueue = new LinkedList<Process *>();
}
CompletelyFair::CompletelyFair() {
procTree = new BSTMultimap<int, Process*>();
}
CompletelyFair::~CompletelyFair() {
delete procTree;
}
void CompletelyFair::addProcess(Process* proc) {
procTree->insert(proc->getCPUTime(), proc);
}
Process* CompletelyFair::popNext(int curCycle) {
BSTForwardIterator<int, Process*> processIter = procTree->getMin();
while(processIter.getValue()->isBlocked(curCycle)) {
processIter.next();
}
Process* result = processIter.getValue();
procTree->remove(processIter);
return result;
}
FastCompletelyFair::FastCompletelyFair() {
delete procTree;
procTree = new RBTMultimap<int, Process*>();
}