- Fix deadlock that blocked PythonPolicy::sort_queue
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@796 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
ebeda15359
commit
6c79bc361c
|
@ -100,15 +100,12 @@ PythonPolicy::configure() throw(UserInterruptException)
|
||||||
void
|
void
|
||||||
PythonPolicy::sort_queue() const throw(UserInterruptException)
|
PythonPolicy::sort_queue() const throw(UserInterruptException)
|
||||||
{
|
{
|
||||||
PyObject* pMethodName = PyString_FromString("async_sort_queue");
|
PyObject* retval = PyObject_CallMethod(_adapter, "async_sort_queue", NULL);
|
||||||
PyObject* retval = PyObject_CallMethodObjArgs(_adapter, pMethodName, NULL, NULL);
|
|
||||||
|
|
||||||
// Do minimal debugging
|
// Do minimal debugging
|
||||||
if(!retval) PyErr_Print();
|
if(!retval) PyErr_Print();
|
||||||
else Py_DECREF(retval);
|
else Py_DECREF(retval);
|
||||||
|
|
||||||
Py_DECREF(pMethodName);
|
|
||||||
|
|
||||||
wait_unlock();
|
wait_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,14 +131,14 @@ update_requests_for_old_running_thread(DynamicThread& running_thread)
|
||||||
|
|
||||||
//private constructor. The parameter is discarded
|
//private constructor. The parameter is discarded
|
||||||
Scheduler::Scheduler()
|
Scheduler::Scheduler()
|
||||||
: _ready_queue(NULL), _policy(NULL)
|
: _ready_queue(NULL), _policy(NULL), _step_mutex()
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ReadyQueue*
|
ReadyQueue*
|
||||||
Scheduler::get_ready_queue()
|
Scheduler::get_ready_queue()
|
||||||
{
|
{
|
||||||
// FIXME return the correct queue accordingly to the value returned by Policy::wants()
|
|
||||||
return _ready_queue;
|
return _ready_queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ Scheduler::step_forward(History& history, Policy& cpu_policy) throw(UserInterrup
|
||||||
// store a readyqueue and policy pointer for the user-policy to retrieve, to when
|
// store a readyqueue and policy pointer for the user-policy to retrieve, to when
|
||||||
// the policy returns
|
// the policy returns
|
||||||
// TODO: restrict this area to maximise parallelism
|
// TODO: restrict this area to maximise parallelism
|
||||||
Glib::Mutex::Lock lock(_mutex);
|
Glib::Mutex::Lock lock(_step_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!
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@ namespace sgpem
|
||||||
// Do not include full template definition here
|
// Do not include full template definition here
|
||||||
#include "singleton.hh"
|
#include "singleton.hh"
|
||||||
|
|
||||||
|
#include <glibmm/thread.h>
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
class Scheduler;
|
class Scheduler;
|
||||||
|
@ -74,13 +76,7 @@ namespace sgpem
|
||||||
one instant with it.
|
one instant with it.
|
||||||
*/
|
*/
|
||||||
void step_forward(History& history, Policy& cpu_policy) throw(UserInterruptException);
|
void step_forward(History& history, Policy& cpu_policy) throw(UserInterruptException);
|
||||||
/**
|
|
||||||
Sets the policy that will be used to generate the simulation at the next instant.
|
|
||||||
\param policy the policy that will be used to generate the simulation at the next instant.
|
|
||||||
*/
|
|
||||||
/* DISABLED until we don't have PolicyManager::set_policy()
|
|
||||||
void set_policy(Policy* policy);
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
Returns the policy that will be used to generate the simulation at the next instant.
|
Returns the policy that will be used to generate the simulation at the next instant.
|
||||||
\return the policy that will be used to generate the simulation at the next instant.
|
\return the policy that will be used to generate the simulation at the next instant.
|
||||||
|
@ -92,6 +88,8 @@ namespace sgpem
|
||||||
|
|
||||||
ReadyQueue* _ready_queue;
|
ReadyQueue* _ready_queue;
|
||||||
Policy* _policy;
|
Policy* _policy;
|
||||||
|
|
||||||
|
Glib::Mutex _step_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
}//~ namespace sgpem
|
}//~ namespace sgpem
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace sgpem
|
||||||
static Instantiated_class& get_instance();
|
static Instantiated_class& get_instance();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static Glib::StaticMutex SG_DLLLOCAL _mutex;
|
static Glib::RecMutex SG_DLLLOCAL _mutex;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static SG_DLLLOCAL Instantiated_class* _instance;
|
static SG_DLLLOCAL Instantiated_class* _instance;
|
||||||
|
|
|
@ -26,15 +26,15 @@ Instantiated_class*
|
||||||
sgpem::Singleton<Instantiated_class>::_instance = NULL;
|
sgpem::Singleton<Instantiated_class>::_instance = NULL;
|
||||||
|
|
||||||
template<typename Instantiated_class>
|
template<typename Instantiated_class>
|
||||||
Glib::StaticMutex
|
Glib::RecMutex
|
||||||
sgpem::Singleton<Instantiated_class>::_mutex = GLIBMM_STATIC_MUTEX_INIT;
|
sgpem::Singleton<Instantiated_class>::_mutex;
|
||||||
|
|
||||||
|
|
||||||
template<typename Instantiated_class>
|
template<typename Instantiated_class>
|
||||||
Instantiated_class&
|
Instantiated_class&
|
||||||
sgpem::Singleton<Instantiated_class>::get_instance()
|
sgpem::Singleton<Instantiated_class>::get_instance()
|
||||||
{
|
{
|
||||||
Glib::Mutex::Lock lock(_mutex);
|
Glib::RecMutex::Lock lock(_mutex);
|
||||||
if(_instance == NULL)
|
if(_instance == NULL)
|
||||||
_instance = new Instantiated_class();
|
_instance = new Instantiated_class();
|
||||||
return *_instance;
|
return *_instance;
|
||||||
|
|
Loading…
Reference in New Issue