fixed a bug involving scheduler keeping a running thread in the ready queue
when that thread had just been given the cpu. fixed a bug involving text-simulation displaying the wrong timestamp for each snaphot. Now the first snapshot printed is correctly tagged "-1". added (for the sake of lazyness) a method to readyqueue letting anyone delete the first element on the queue. Not having this would imply rebuilding the whole queue each time a thread was selected to run. Small commits avoid complex mergings. git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@814 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
01490e24ac
commit
56a7ce1221
4 changed files with 21 additions and 2 deletions
|
@ -70,3 +70,9 @@ ReadyQueue::append(Thread& thread)
|
|||
{
|
||||
_scheds.push_back(&thread);
|
||||
}
|
||||
|
||||
void
|
||||
ReadyQueue::erase_first()
|
||||
{
|
||||
_scheds.erase(_scheds.begin());
|
||||
}
|
|
@ -42,6 +42,7 @@ namespace sgpem
|
|||
Thread& get_item_at(position index) throw (std::out_of_range);
|
||||
const Thread& get_item_at(position index) const throw (std::out_of_range);
|
||||
void append(Thread& schedulable);
|
||||
void erase_first();
|
||||
|
||||
private:
|
||||
typedef std::vector<Thread*> Threads;
|
||||
|
|
|
@ -314,6 +314,10 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
|
|||
DynamicThread& new_running = (DynamicThread&) _ready_queue->get_item_at(0);
|
||||
new_running.set_state(Schedulable::state_running);
|
||||
new_running.set_last_acquisition(current_instant);
|
||||
// removes running element from the ready queue
|
||||
// since no method was provided to erase an item in the queue, we should rebuild it.
|
||||
// this is pointless. I just added the method.
|
||||
_ready_queue->erase_first();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue