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);