- Do the assignment before using the variable...

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@797 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2006-07-28 12:34:13 +00:00
parent 6c79bc361c
commit 5b22b503a5
1 changed files with 3 additions and 2 deletions

View File

@ -205,14 +205,15 @@ Scheduler::step_forward(History& history, Policy& cpu_policy) throw(UserInterrup
// its allotted time // its allotted time
if(current.get_state() == Schedulable::state_running) if(current.get_state() == Schedulable::state_running)
{ {
assert(running_thread == NULL); // ... and one to bind them all.
running_thread = &current; // Even if we change its state to terminate
// increasing the time elapsed of the running thread + process // increasing the time elapsed of the running thread + process
// should be done here as the first thing, instead than // should be done here as the first thing, instead than
// directly after selecting them // directly after selecting them
if(current.get_total_cpu_time() - current.get_elapsed_time() > 0) if(current.get_total_cpu_time() - current.get_elapsed_time() > 0)
running_thread->decrease_remaining_time(); running_thread->decrease_remaining_time();
assert(running_thread == NULL); // ... and one to bind them all.
running_thread = &current; // Even if we change its state to terminated
// 2. mark threads that used all their allotted time as terminated // 2. mark threads that used all their allotted time as terminated
if(current.get_total_cpu_time() - current.get_elapsed_time() == 0) if(current.get_total_cpu_time() - current.get_elapsed_time() == 0)
current.set_state(Schedulable::state_terminated); current.set_state(Schedulable::state_terminated);