-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessMgmt.cpp
60 lines (47 loc) · 1.23 KB
/
processMgmt.cpp
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 "processMgmt.h"
void ProcessManagement::readProcessFile(const string& fname)
{
stringstream ss;
ifstream in(fname.c_str());
string line, strItem;
Process proc;
unsigned int ioIDctrl(0), procIDctrl(0);
int ioTime, ioDur;
m_pending.clear();
if(!in.good())
{
cerr << "initProcessSetFromFile error unable to open file \"" << fname << "\"" << endl;
return;
}
m_pending.reserve(20);
while(getline(in, line))
{
ss.clear();
ss.str(line);
proc.id = procIDctrl;
++procIDctrl;
ss >> proc.arrivalTime;
ss >> proc.reqProcessorTime;
proc.ioEvents.clear();
while(ss >> ioTime)
{
ss >> ioDur;
proc.ioEvents.push_back(IOEvent(ioTime, ioDur, ioIDctrl));
++ioIDctrl;
}
proc.ioEvents.sort(ioComp);
m_pending.push_back(proc);
}
sort(m_pending.begin(), m_pending.end(), procComp);
}
void ProcessManagement::activateProcesses(const int& time)
{
if(m_pending.size() > 0)
{
while(m_pending.back().arrivalTime == time)
{
m_procList.push_back(m_pending.back());
m_pending.pop_back();
}
}
}