From 736aa254569d71cf8c57a6c4288176c0c9eaf722 Mon Sep 17 00:00:00 2001 From: tchernobog Date: Tue, 4 Jul 2006 10:03:43 +0000 Subject: [PATCH] - Change pkg-config file to use ${prefix}/include rather thant ${prefix}/include/sgpemv2: users will be able to use directives like "#include " in their headers, which reduces name clashes. - Make _mutex a protected member of Singleton, so that inheriters can recycle it :-) - Add exclusive access control for step_forward() - Add two states (future and exhausted) to Request git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@707 3ecf2c5c-341e-0410-92b4-d18e462d057c --- config/sgpemv2.pc.in | 2 +- src/backend/request.hh | 8 +++++--- src/backend/scheduler.cc | 17 ++++++++++++++--- src/backend/scheduler.hh | 3 --- src/templates/singleton.hh | 4 +++- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/config/sgpemv2.pc.in b/config/sgpemv2.pc.in index fbbbb65..d037dab 100644 --- a/config/sgpemv2.pc.in +++ b/config/sgpemv2.pc.in @@ -14,4 +14,4 @@ URL: http://www.math.unipd.it/ Requires: glibmm-2.4 >= 2.8 gthread-2.0 >= 2.8 Libs: -L${libdir} -lbackend Libs.private: -lglibmm-2.4 -lgthread-2.0 -Cflags: -I${includedir}/sgpemv2 +Cflags: -I${includedir} diff --git a/src/backend/request.hh b/src/backend/request.hh index ad332f9..0640266 100644 --- a/src/backend/request.hh +++ b/src/backend/request.hh @@ -35,13 +35,15 @@ namespace sgpem public: enum state { - state_ready, - state_allocated + state_ready = 1 << 0, + state_allocated = 1 << 1, + state_future = 1 << 2, + state_exhausted = 1 << 3 }; virtual ~Request(); - virtual bool operator==(const Request& op2) const = 0; + virtual bool operator==(const Request& op2) const = 0; virtual std::vector get_subrequests() = 0; virtual unsigned int get_instant() const = 0; diff --git a/src/backend/scheduler.cc b/src/backend/scheduler.cc index 3ad872d..ef3839d 100644 --- a/src/backend/scheduler.cc +++ b/src/backend/scheduler.cc @@ -30,6 +30,8 @@ // Do not include full template definition in the header file #include "singleton.tcc" +#include + #include using namespace std; using namespace sgpem; @@ -114,6 +116,12 @@ 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); + // 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*! @@ -161,12 +169,15 @@ Scheduler::step_forward(History& history, Policy& cpu_policy) throw(UserInterrup // 3. check for simulation termination (we can directly use threads // for this check, since processes' state is based upon threads' one) - if(simulation_ended && - ((*it)->get_state() & (Schedulable::state_blocked | - Schedulable::state_terminated)) == 0) + 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? + + // 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 diff --git a/src/backend/scheduler.hh b/src/backend/scheduler.hh index 3c61c42..eb33e55 100644 --- a/src/backend/scheduler.hh +++ b/src/backend/scheduler.hh @@ -29,9 +29,6 @@ namespace sgpem #include "config.h" -#include -#include - #include "history.hh" #include "policy.hh" #include "ready_queue.hh" diff --git a/src/templates/singleton.hh b/src/templates/singleton.hh index 79fc24c..53c03c5 100644 --- a/src/templates/singleton.hh +++ b/src/templates/singleton.hh @@ -44,10 +44,12 @@ namespace sgpem * \return The instantiated object */ static Instantiated_class& get_instance(); + + protected: + static Glib::StaticMutex SG_DLLLOCAL _mutex; private: static Instantiated_class* _instance; - static Glib::StaticMutex SG_DLLLOCAL _mutex; } ; //~ class Singleton