- Add method to set a request state
- Work on step_forward() a little more - Add extra check inside dynamic_thread()::decrease_remaining_time() git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@717 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
dd4898ca55
commit
22af0b9cdd
|
@ -90,6 +90,15 @@ DynamicRequest::get_state() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Request::state
|
||||||
|
DynamicRequest::set_state(state new_state)
|
||||||
|
{
|
||||||
|
state temp = _state;
|
||||||
|
_state = new_state;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicRequest::serialize(SerializeVisitor& translator) const
|
DynamicRequest::serialize(SerializeVisitor& translator) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,6 +53,7 @@ namespace sgpem
|
||||||
unsigned int get_instant() const;
|
unsigned int get_instant() const;
|
||||||
|
|
||||||
state get_state() const;
|
state get_state() const;
|
||||||
|
state set_state(state new_state);
|
||||||
|
|
||||||
void serialize(SerializeVisitor& translator) const;
|
void serialize(SerializeVisitor& translator) const;
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,10 @@ DynamicThread::get_elapsed_time() const
|
||||||
void
|
void
|
||||||
DynamicThread::decrease_remaining_time()
|
DynamicThread::decrease_remaining_time()
|
||||||
{
|
{
|
||||||
_ran_for++;
|
// strict check for us to better debug scheduler
|
||||||
|
assert(_ran_for < get_total_cpu_time());
|
||||||
|
if(_ran_for < get_total_cpu_time())
|
||||||
|
_ran_for++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace sgpem
|
||||||
std::vector<DynamicRequest*> _dynamic_requests;
|
std::vector<DynamicRequest*> _dynamic_requests;
|
||||||
DynamicProcess* _parent;
|
DynamicProcess* _parent;
|
||||||
|
|
||||||
int _ran_for;
|
unsigned int _ran_for;
|
||||||
int _last_acquisition;
|
int _last_acquisition;
|
||||||
int _last_release;
|
int _last_release;
|
||||||
};
|
};
|
||||||
|
|
|
@ -68,7 +68,7 @@ static void prepare_ready_queue(ConcreteEnvironment& snapshot,
|
||||||
it != all_threads.end(); it++)
|
it != all_threads.end(); it++)
|
||||||
{
|
{
|
||||||
if((*it)->get_state() == Schedulable::state_ready)
|
if((*it)->get_state() == Schedulable::state_ready)
|
||||||
all_threads.push_back(*it);
|
queue.append(**it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,20 +179,27 @@ Scheduler::step_forward(History& history, Policy& cpu_policy) throw(UserInterrup
|
||||||
simulation_ended = false;
|
simulation_ended = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 4a. Look for exhausted requests for the running thread
|
||||||
// ---------- FIXME ----------------
|
|
||||||
// What to do now if the simulation ended?
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 4a. Requests for the running thread exhausted
|
|
||||||
if(running_thread != NULL) {
|
if(running_thread != NULL) {
|
||||||
Requests& reqs = running_thread->get_dynamic_requests();
|
Requests& reqs = running_thread->get_dynamic_requests();
|
||||||
if(running_thread->get_state() == Schedulable::state_terminated)
|
bool running_terminated = running_thread->get_state() == Schedulable::state_terminated;
|
||||||
|
|
||||||
|
for(Requests::iterator it = reqs.begin(); it != reqs.end(); it++)
|
||||||
{
|
{
|
||||||
// for(Requests::iterator it = reqs.begin();
|
DynamicRequest& rq = **it;
|
||||||
|
if(rq.get_state() == Request::state_allocated)
|
||||||
|
/* decrease remaining time for request */;
|
||||||
|
|
||||||
|
// ASK MARCO : can we implement request::decrease_remaining_time() as
|
||||||
|
// a function that calls decrease_remaining_time() on all its subrequests,
|
||||||
|
// that in turn never go with a remaining time < 0?
|
||||||
|
|
||||||
|
// If the running thread terminated uncoditionally put them in exhausted state
|
||||||
|
if(running_terminated /* || rq.get_remaining_time() == 0 */ )
|
||||||
|
rq.set_state(Request::state_exhausted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FIXME we lack a way to tell and/or remember for how
|
// FIXME we lack a way to tell and/or remember for how
|
||||||
// much a subrequest has been being fulfilled
|
// much a subrequest has been being fulfilled
|
||||||
// THIS MEANS this part is NOT complete
|
// THIS MEANS this part is NOT complete
|
||||||
|
@ -205,18 +212,23 @@ Scheduler::step_forward(History& history, Policy& cpu_policy) throw(UserInterrup
|
||||||
// even if it was terminated
|
// even if it was terminated
|
||||||
|
|
||||||
|
|
||||||
}
|
} //~ if running_thread != NULL
|
||||||
|
|
||||||
|
|
||||||
// /
|
// ---------- FIXME ----------------
|
||||||
// /
|
// What to do now if the simulation ended?
|
||||||
// /
|
|
||||||
// (I'M HERE) < * * * * * * * * * * *
|
|
||||||
// \
|
/* /
|
||||||
// \
|
* /
|
||||||
// \
|
* /
|
||||||
//
|
* (I'M HERE) < * * * * * * * * * * *
|
||||||
// (is it visible enough for you?)
|
* \
|
||||||
|
* \
|
||||||
|
* \
|
||||||
|
*
|
||||||
|
* (is it visible enough for you?)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
prepare_ready_queue(*new_snapshot, all_threads);
|
prepare_ready_queue(*new_snapshot, all_threads);
|
||||||
|
|
Loading…
Reference in New Issue