- Added a bit of resource policy mamagement. Still far from being usefu.

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@958 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
matrevis 2006-08-28 22:40:08 +00:00
parent 980d9b410a
commit f3dc9b77df
7 changed files with 65 additions and 16 deletions

View file

@ -56,7 +56,7 @@ static void collect_threads(const std::vector<Process*>& procs, Threads& collect
static void prepare_ready_queue(ConcreteEnvironment& snapshot, const Threads& all_threads);
static void terminate_all_requests_of(DynamicThread& thread, ConcreteEnvironment& environment);
static void update_allocated_requests(DynamicThread& running_thread, ConcreteEnvironment& environment);
static void raise_new_requests(DynamicThread& running_thread, ConcreteEnvironment& environment);
static void raise_new_requests(DynamicThread& running_thread, ConcreteEnvironment& environment, ResourcePolicy& resource_policy);
static void look_for_mutant_request_states(ConcreteEnvironment& environment, unsigned int& alive_threads);
static void determine_subr_allocable_status(const DynamicRequest& req, DynamicSubRequest& subr,
const Resource& res, SubRequestQueue& queue);
@ -152,7 +152,7 @@ update_allocated_requests(DynamicThread& running_thread,
// Remember that a thread may run only if all of its requests are either FUTURE,
// ALLOCATED or EXHAUSTED.
void
raise_new_requests(DynamicThread& running_thread, ConcreteEnvironment& environment)
raise_new_requests(DynamicThread& running_thread, ConcreteEnvironment& environment, ResourcePolicy& resource_policy)
{
// Go for all dynamic requests of this thread
Requests& reqs = running_thread.get_dynamic_requests();
@ -175,7 +175,8 @@ raise_new_requests(DynamicThread& running_thread, ConcreteEnvironment& environme
/// TODO: right here, right now we should call the resource policy to
/// update the queue. Updates the state of the subrequest depending
/// on the position in the queue, as explained before.
/// on the position in the queue, as explained before.
resource_policy.enforce();
// Get the number of places for the corresponding resource
Resource& resource = *environment.get_resources().find(rkey)->second;
@ -378,7 +379,7 @@ Scheduler::get_policy()
bool
Scheduler::step_forward(History& history, CPUPolicy& cpu_policy)
Scheduler::step_forward(History& history, CPUPolicy& cpu_policy, ResourcePolicy& resource_policy)
throw(UserInterruptException, MalformedPolicyException)
{
// This very method should be exclusive: no concurrent behaviour, from when we
@ -504,7 +505,7 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy)
// * else we've to select another running thread, so we continue down in the method
if(running_thread != NULL && running_thread->get_state() == Schedulable::state_running)
{
raise_new_requests(*running_thread, *new_snapshot);
raise_new_requests(*running_thread, *new_snapshot, resource_policy);
if(running_thread->get_state() != Schedulable::state_blocked)
goto final_cleanup;
else
@ -539,7 +540,7 @@ Scheduler::step_forward(History& history, CPUPolicy& cpu_policy)
}
// Now we check if our candidate blocks on a new request
raise_new_requests(candidate, *new_snapshot);
raise_new_requests(candidate, *new_snapshot, resource_policy);
if(candidate.get_state() != Schedulable::state_blocked)
// If we got here, our candidate can run
we_ve_got_a_winner /*!hurrah!*/ = true;