- Change pkg-config file to use ${prefix}/include

rather thant ${prefix}/include/sgpemv2: users will
be able to use directives like "#include <sgpemv2/scheduler.hh>"
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
This commit is contained in:
tchernobog 2006-07-04 10:03:43 +00:00
parent 899e20323a
commit 736aa25456
5 changed files with 23 additions and 11 deletions

View File

@ -14,4 +14,4 @@ URL: http://www.math.unipd.it/
Requires: glibmm-2.4 >= 2.8 gthread-2.0 >= 2.8 Requires: glibmm-2.4 >= 2.8 gthread-2.0 >= 2.8
Libs: -L${libdir} -lbackend Libs: -L${libdir} -lbackend
Libs.private: -lglibmm-2.4 -lgthread-2.0 Libs.private: -lglibmm-2.4 -lgthread-2.0
Cflags: -I${includedir}/sgpemv2 Cflags: -I${includedir}

View File

@ -35,13 +35,15 @@ namespace sgpem
public: public:
enum state enum state
{ {
state_ready, state_ready = 1 << 0,
state_allocated state_allocated = 1 << 1,
state_future = 1 << 2,
state_exhausted = 1 << 3
}; };
virtual ~Request(); virtual ~Request();
virtual bool operator==(const Request& op2) const = 0; virtual bool operator==(const Request& op2) const = 0;
virtual std::vector<SubRequest*> get_subrequests() = 0; virtual std::vector<SubRequest*> get_subrequests() = 0;
virtual unsigned int get_instant() const = 0; virtual unsigned int get_instant() const = 0;

View File

@ -30,6 +30,8 @@
// Do not include full template definition in the header file // Do not include full template definition in the header file
#include "singleton.tcc" #include "singleton.tcc"
#include <glibmm/thread.h>
#include <memory> #include <memory>
using namespace std; using namespace std;
using namespace sgpem; using namespace sgpem;
@ -114,6 +116,12 @@ Scheduler::get_policy()
void void
Scheduler::step_forward(History& history, Policy& cpu_policy) throw(UserInterruptException) 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! // 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*! // 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 // 3. check for simulation termination (we can directly use threads
// for this check, since processes' state is based upon threads' one) // for this check, since processes' state is based upon threads' one)
if(simulation_ended && if( /* we still think that */ simulation_ended &&
((*it)->get_state() & (Schedulable::state_blocked | (current.get_state() & (Schedulable::state_blocked |
Schedulable::state_terminated)) == 0) Schedulable::state_terminated)) == 0)
simulation_ended = false; simulation_ended = false;
} }
// What to do now if the simulation ended?
// FIXME: increasing the time elapsed of the running thread + process // FIXME: increasing the time elapsed of the running thread + process
// should maybe be done here as the first thing, instead than // should maybe be done here as the first thing, instead than
// directly when selecting them // directly when selecting them

View File

@ -29,9 +29,6 @@ namespace sgpem
#include "config.h" #include "config.h"
#include <limits>
#include <iostream>
#include "history.hh" #include "history.hh"
#include "policy.hh" #include "policy.hh"
#include "ready_queue.hh" #include "ready_queue.hh"

View File

@ -45,9 +45,11 @@ namespace sgpem
*/ */
static Instantiated_class& get_instance(); static Instantiated_class& get_instance();
protected:
static Glib::StaticMutex SG_DLLLOCAL _mutex;
private: private:
static Instantiated_class* _instance; static Instantiated_class* _instance;
static Glib::StaticMutex SG_DLLLOCAL _mutex;
} }
; //~ class Singleton ; //~ class Singleton