- Fix all policies to ensure that the sort *IS* stable

- Erase the newly selected running thread from the ready queue
as per Marco feedback (or so I believe to have understood...)


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1024 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-09-06 13:04:31 +00:00
parent df4b1b4205
commit dbfc7393ed
5 changed files with 9 additions and 7 deletions

View File

@ -42,6 +42,6 @@ the simplest of them all."""
def sort_queue(self, queue):
cmpf = lambda a, b: \
a.get_arrival_time() < \
a.get_arrival_time() <= \
b.get_arrival_time()
self.sort(queue,cmpf)

View File

@ -45,6 +45,6 @@ priority in account. Use rr_priority for that."""
def sort_queue(self, queue):
by_ltime = lambda a, b: \
a.get_last_acquisition() > \
a.get_last_acquisition() <= \
b.get_last_acquisition()
self.sort(queue,by_ltime)

View File

@ -49,12 +49,13 @@ the time slice will have to end before the former can run."""
return self.get_parameters().get_int("Time slice")
def sort_queue(self, queue):
by_prio = lambda a, b: \
a.get_current_priority() < \
b.get_current_priority()
by_ltime = lambda a, b: \
a.get_last_acquisition() > \
a.get_last_acquisition() <= \
b.get_last_acquisition()
by_prio = lambda a, b: \
a.get_current_priority() <= \
b.get_current_priority()
self.sort(queue,by_ltime)
self.sort(queue,by_prio)

View File

@ -50,7 +50,7 @@ Time Next in this case."""
def sort_queue(self, queue):
cmpf = lambda a, b: \
a.get_total_cpu_time() - a.get_elapsed_time() < \
a.get_total_cpu_time() - a.get_elapsed_time() <= \
b.get_total_cpu_time() - b.get_elapsed_time()
self.sort(queue,cmpf)

View File

@ -634,6 +634,7 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy, ResourcePolicy&
{
// Fix fields of running thread
DynamicThread& new_running = (DynamicThread&) _ready_queue->get_item_at(0);
_ready_queue->erase_first();
new_running.set_state(Schedulable::state_running);
// If the new running is different from the old one,