- Corrected a bug in step forward, which was incorrectly assuming

that the size of the history was the coordinate of the instant
  to add.
- Corrected a bug in step forward, which was incorrectly assuming
  that all processes started at instant 0.
- Added a wizard to show a bug in step forward, which thinks that
  the simulation is terminated while it isn't since some processes
  are still future.
- Commented some unused code in step forward (extendThread()).
- Still to extract methods from Extender and provide them to 
  step forward in a more suitable (static) way.


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@828 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
matrevis 2006-08-07 23:59:21 +00:00
parent a7fc644043
commit d72ce96508
2 changed files with 93 additions and 7 deletions

View File

@ -281,6 +281,9 @@ class Extender
}
}
}
/*
// the following methods are never used in step forward (by now)
/// \brief Manages a single Thread object, depending on its state.
///
@ -299,7 +302,7 @@ class Extender
front = t.get_elapsed_time();
switch (walk)
{
/*
/// If the thread is RUNNING, its requests are updated in cascade,
/// the counters are decreased, and the state is updated depending
/// on the remaining time and the remaining quantum.
@ -361,7 +364,7 @@ class Extender
}
break;
}
*/
/// If the thread is the first on the ready_queue, try to run. The
/// thread may block on a request.
case walk_to_allocate_cpu:
@ -393,10 +396,11 @@ class Extender
}
break;
}
}
front = old_front;
}
*/
@ -507,7 +511,9 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
// FIXME: handle me! I'm not just a pretty boolean, I want to be *USED*! *EXPLOITED*!
// *RAPED*! *MAKE ME BLEED*!
bool simulation_ended = true; // Assume we've finished. Then prove me wrong.
unsigned int current_instant = history.get_size(); /* They should be equivalent */
// since history always contains at leas one element..
assert (history.get_size() > 0);
unsigned int current_instant = history.get_size() - 1; /* They should be equivalent */
ConcreteHistory& concrete_history = (ConcreteHistory&) history;
@ -528,8 +534,12 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
// 1. mark future threads as ready, if appropriate
if(current.get_state() == Schedulable::state_future)
{
// if there is at least a future process, don't terminate the simulation
Process& parent = current.get_process();
if(parent.get_elapsed_time() == current.get_arrival_time())
if (parent.get_state() == Schedulable::state_future)
simulation_ended = false;
// start a thread only if its parent is arrived!
if(parent.get_arrival_time() <= current_instant && parent.get_elapsed_time() == current.get_arrival_time())
{
current.set_state(Schedulable::state_ready);
// in this way we will never have threads ready having remaining time == 0
@ -537,7 +547,7 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
current.set_state(Schedulable::state_terminated);
}
}
// Save the current running thread for future usage, if it hasn't ended
// its allotted time
if(current.get_state() == Schedulable::state_running)
@ -706,7 +716,11 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInter
// FIXME
// FIXME
// FIXME
// the following condition is not sufficient. we must also
// be sure that no other processes are ready.
if (!found)
simulation_ended = true;

View File

@ -0,0 +1,72 @@
set cpu-policy 3
add resource
add resource
forchetta
false
1
0
add process
Pitagorici
0
0
add thread 1
Pitagora
4
0
0
add request 1 1
0
add subrequest 1 1 1
0
4
add subrequest 1 1 1
0
4
add request 1 1
2
add subrequest 1 1 2
0
4
add process
Scuola di Mileto
3
0
add thread 2
Anassimene
6
0
0
add thread 2
Anassimandro
2
0
0
add request 2 1
0
add subrequest 2 1 1
0
2
add request 2 2
0
add subrequest 2 2 1
0
2
run