Reputation: 737
My problem is that I am getting a segmentation fault that occurs after I call "processList.pop_front()
". If I comment out "processList.pop_front()
", a segmentation then occurs during the second iteration of the outermost for loop, after a tt.pop_front()
call, after that inner for loop has gone through almost 5000 iterations. I can't see what the problem is. Any thoughts?
loopLimit = processList.size();
for(int i = 0; i < loopLimit; i++)
{
tempProcess = processList.front();
tt = tempProcess.memAccesses;
cout << "process number " << i << "\n";
while(!tt.empty())
{
t = tt.front();
tt.pop_front();
cout << "from processlist: " << t.instrType << " " << t.instrAddr << "\n";
}
if(!processList.empty())
{
cout << "size is now: " << processList.size() << "\n";
processList.pop_front();
}
}
Upvotes: 0
Views: 1689
Reputation: 21
I have a similar problem and I solved it by adding an invalid value to the deque:
loopLimit = processList.size();
for(int i = 0; i < loopLimit; i++)
{
tempProcess = processList.front();
tt = tempProcess.memAccesses;
cout << "process number " << i << "\n";
tt.push_back(-1); //I guess you don't have a -1 type, so you wont have colisions
while( tt.front()!=-1)
{
t = tt.front();
tt.pop_front();
cout << "from processlist: " << t.instrType << " " << t.instrAddr << "\n";
}
if(!processList.empty())
{
cout << "size is now: " << processList.size() << "\n";
processList.pop_front();
}
}
Probably you will have to adapt it a bit. Is not a very nice solution, but it works.
Upvotes: 2