From 5b22b503a56aae3c008fd760c39169264110cb4f Mon Sep 17 00:00:00 2001 From: tchernobog Date: Fri, 28 Jul 2006 12:34:13 +0000 Subject: [PATCH] - Do the assignment before using the variable... git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@797 3ecf2c5c-341e-0410-92b4-d18e462d057c --- src/backend/scheduler.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backend/scheduler.cc b/src/backend/scheduler.cc index fcff134..2d34a40 100644 --- a/src/backend/scheduler.cc +++ b/src/backend/scheduler.cc @@ -205,14 +205,15 @@ Scheduler::step_forward(History& history, Policy& cpu_policy) throw(UserInterrup // its allotted time if(current.get_state() == Schedulable::state_running) { + assert(running_thread == NULL); // ... and one to bind them all. + running_thread = ¤t; // Even if we change its state to terminate + // increasing the time elapsed of the running thread + process // should be done here as the first thing, instead than // directly after selecting them if(current.get_total_cpu_time() - current.get_elapsed_time() > 0) running_thread->decrease_remaining_time(); - assert(running_thread == NULL); // ... and one to bind them all. - running_thread = ¤t; // Even if we change its state to terminated // 2. mark threads that used all their allotted time as terminated if(current.get_total_cpu_time() - current.get_elapsed_time() == 0) current.set_state(Schedulable::state_terminated);