- Updated interface of pyloader to comply with the new plugin management system`s requirements

- Commented a lot of code to make it compile-able. But still it doesn`t link (at least for me...)

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@710 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-07-04 15:05:04 +00:00
parent b65adbe1cc
commit 401c569a9f
11 changed files with 751 additions and 719 deletions

View file

@ -386,3 +386,8 @@ ConcreteHistory::reset(bool notify)
notify_change();
}
void
ConcreteHistory::notify_change()
{
// FIXME write code for this method. won't link without this stub
}

View file

@ -62,6 +62,19 @@ DynamicSchedulable::get_total_cpu_time() const
return get_core().get_total_cpu_time();
}
int
DynamicSchedulable::set_priority_push(int new_value)
{
int old_priority_push = _priority_push;
_priority_push = new_value;
return old_priority_push;
}
int
DynamicSchedulable::get_priority_push() const
{
return _priority_push;
}
int
DynamicSchedulable::get_current_priority() const

View file

@ -36,12 +36,13 @@ Module::Module(const Glib::ustring& identifier) throw(InvalidPluginException) :
get_version_ptr(NULL)
{
// Type-safeness here is an optional, as always. :-)
if(!(get_symbol("on_init", (void*&) on_init_ptr) &&
get_symbol("on_exit", (void*&) on_exit_ptr) &&
get_symbol("describe", (void*&) describe_ptr) &&
get_symbol("get_name", (void*&) get_name_ptr) &&
get_symbol("get_author", (void*&) get_author_ptr) &&
get_symbol("get_version", (void*&) get_version_ptr)))
std::string prefix = "sgpem::Plugin::";
if(!(get_symbol(prefix + "on_init", (void*&) on_init_ptr) &&
get_symbol(prefix + "on_exit", (void*&) on_exit_ptr) &&
get_symbol(prefix + "describe", (void*&) describe_ptr) &&
get_symbol(prefix + "get_name", (void*&) get_name_ptr) &&
get_symbol(prefix + "get_author", (void*&) get_author_ptr) &&
get_symbol(prefix + "get_version", (void*&) get_version_ptr)))
throw InvalidPluginException("incomplete/wrong exported interface");
}

View file

@ -32,7 +32,7 @@
using namespace sgpem;
using namespace std;
template class Singleton<PluginManager>;
template class SG_DLLEXPORT Singleton<PluginManager>;
std::vector<Module*>

View file

@ -36,7 +36,7 @@ namespace sgpem
{
class PluginManager;
class PluginManager : public Singleton<PluginManager>
class SG_DLLEXPORT PluginManager : public Singleton<PluginManager>
{
friend class Singleton<PluginManager>;
public:

View file

@ -116,127 +116,127 @@ Scheduler::get_policy()
void
Scheduler::step_forward(History& history, Policy& cpu_policy) throw(UserInterruptException)
{
// This very method should be exclusive: no concurrent behaviour, from when we
// store a readyqueue and policy pointer for the user-policy to retrieve, to when
// the policy returns
// TODO: restrict this area to maximise parallelism
Glib::Mutex::Lock lock(_mutex);
// // This very method should be exclusive: no concurrent behaviour, from when we
// // store a readyqueue and policy pointer for the user-policy to retrieve, to when
// // the policy returns
// // TODO: restrict this area to maximise parallelism
// Glib::Mutex::Lock lock(_mutex);
// NOTE: Be sure to read the *ORIGINAL* documentation in the design document for this method!
// // NOTE: Be sure to read the *ORIGINAL* documentation in the design document for this method!
// 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.
// // 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.
ConcreteHistory& concrete_history = (ConcreteHistory&) history;
// Use an auto_ptr since we've some exceptions in the coming...
auto_ptr<ConcreteEnvironment> new_snapshot(new ConcreteEnvironment(concrete_history.get_last_environment()));
typedef std::vector<DynamicProcess*> Processes;
typedef std::vector<DynamicRequest*> Requests;
typedef std::vector<DynamicSubRequest*> SubRequests;
typedef std::vector<DynamicThread*> Threads;
Threads all_threads;
DynamicThread* running_thread = NULL;
// ConcreteHistory& concrete_history = (ConcreteHistory&) history;
//
// // Use an auto_ptr since we've some exceptions in the coming...
// auto_ptr<ConcreteEnvironment> new_snapshot(new ConcreteEnvironment(concrete_history.get_last_environment()));
//
// typedef std::vector<DynamicProcess*> Processes;
// typedef std::vector<DynamicRequest*> Requests;
// typedef std::vector<DynamicSubRequest*> SubRequests;
// typedef std::vector<DynamicThread*> Threads;
//
// Threads all_threads;
// DynamicThread* running_thread = NULL;
collect_threads(new_snapshot->get_processes(), all_threads);
// collect_threads(new_snapshot->get_processes(), all_threads);
// designer + implementer (Matteo) comment follows:
// // designer + implementer (Matteo) comment follows:
for(Threads::iterator it = all_threads.begin(); it != all_threads.end(); it++)
{
DynamicThread& current = **it;
// 1. mark future threads as ready, if appropriate
if(current.get_state() == Schedulable::state_future)
{
Process& parent = current.get_process();
if(parent.get_elapsed_time() == current.get_arrival_time())
current.set_state(Schedulable::state_ready);
}
// Save the current running thread for future usage, if it hasn't ended
// its allotted time
if(current.get_state() == Schedulable::state_running)
{
running_thread = &current; // 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);
}
// for(Threads::iterator it = all_threads.begin(); it != all_threads.end(); it++)
// {
// DynamicThread& current = **it;
//
// // 1. mark future threads as ready, if appropriate
// if(current.get_state() == Schedulable::state_future)
// {
// Process& parent = current.get_process();
// if(parent.get_elapsed_time() == current.get_arrival_time())
// current.set_state(Schedulable::state_ready);
// }
//
// // Save the current running thread for future usage, if it hasn't ended
// // its allotted time
// if(current.get_state() == Schedulable::state_running)
// {
// running_thread = &current; // 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);
// }
// 3. check for simulation termination (we can directly use threads
// for this check, since processes' state is based upon threads' one)
if( /* we still think that */ simulation_ended &&
(current.get_state() & (Schedulable::state_blocked |
Schedulable::state_terminated)) == 0)
simulation_ended = false;
}
// // 3. check for simulation termination (we can directly use threads
// // for this check, since processes' state is based upon threads' one)
// if( /* we still think that */ simulation_ended &&
// (current.get_state() & (Schedulable::state_blocked |
// Schedulable::state_terminated)) == 0)
// simulation_ended = false;
// }
// What to do now if the simulation ended?
// // What to do now if the simulation ended?
// FIXME: increasing the time elapsed of the running thread + process
// should maybe be done here as the first thing, instead than
// directly when selecting them
if(running_thread != NULL)
running_thread->decrease_remaining_time();
// 4a. Requests for the running thread exhausted
if(running_thread != NULL) {
Requests& reqs = running_thread->get_dynamic_requests();
// FIXME we lack a way to tell and/or remember for how
// much a subrequest has been being fulfilled
// THIS MEANS this part is NOT complete
// We should check if a request has been fulfilled
// // FIXME: increasing the time elapsed of the running thread + process
// // should maybe be done here as the first thing, instead than
// // directly when selecting them
// if(running_thread != NULL)
// running_thread->decrease_remaining_time();
//
// // 4a. Requests for the running thread exhausted
// if(running_thread != NULL) {
// Requests& reqs = running_thread->get_dynamic_requests();
//
// // FIXME we lack a way to tell and/or remember for how
// // much a subrequest has been being fulfilled
// // THIS MEANS this part is NOT complete
// // We should check if a request has been fulfilled
// FIXME If a request was being fulfilled to the running thread,
// we should decrease the request remaining time here.
// // FIXME If a request was being fulfilled to the running thread,
// // we should decrease the request remaining time here.
// This is why we kept a ref to the old running thread,
// even if it was terminated
if(running_thread->get_state() == Schedulable::state_terminated)
free_all_resources_of(*running_thread); // this function isn't complete
}
// // This is why we kept a ref to the old running thread,
// // even if it was terminated
// if(running_thread->get_state() == Schedulable::state_terminated)
// free_all_resources_of(*running_thread); // this function isn't complete
//
// }
//
// /
// /
// /
// (I'M HERE) < * * * * * * * * * * *
// \
// \
// \
//
// (is it visible enough for you?)
// // /
// // /
// // /
// // (I'M HERE) < * * * * * * * * * * *
// // \
// // \
// // \
// //
// // (is it visible enough for you?)
ReadyQueue& ready_queue = new_snapshot->get_sorted_queue();
prepare_ready_queue(ready_queue);
try
{
// ?. Use the policy to sort the queue
//
// ReadyQueue& ready_queue = new_snapshot->get_sorted_queue();
// prepare_ready_queue(ready_queue);
// try
// {
// // ?. Use the policy to sort the queue
// FIXME: how does it get the queue?
cpu_policy.sort_queue();
}
catch(UserInterruptException& e)
{
_policy_manager.init();
// ^^^^^
// Do we need to update something else?
// // FIXME: how does it get the queue?
// cpu_policy.sort_queue();
// }
// catch(UserInterruptException& e)
// {
// _policy_manager.init();
// // ^^^^^
// // Do we need to update something else?
// Going up unwinding the stack, tell:
// - the user that the policy sucks
// - SimulationController that everything stopped
throw;
}
// append the new snapshot...
// ...and remember to release the auto_ptr!
concrete_history.append_new_environment(new_snapshot.release());
// // Going up unwinding the stack, tell:
// // - the user that the policy sucks
// // - SimulationController that everything stopped
// throw;
// }
//
// // append the new snapshot...
// // ...and remember to release the auto_ptr!
// concrete_history.append_new_environment(new_snapshot.release());
}