- 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:
tchernobog 2006-07-28 12:21:49 +00:00
parent ebeda15359
commit 6c79bc361c
5 changed files with 15 additions and 20 deletions

View File

@ -100,15 +100,12 @@ PythonPolicy::configure() throw(UserInterruptException)
void
PythonPolicy::sort_queue() const throw(UserInterruptException)
{
PyObject* pMethodName = PyString_FromString("async_sort_queue");
PyObject* retval = PyObject_CallMethodObjArgs(_adapter, pMethodName, NULL, NULL);
PyObject* retval = PyObject_CallMethod(_adapter, "async_sort_queue", NULL);
// Do minimal debugging
if(!retval) PyErr_Print();
else Py_DECREF(retval);
Py_DECREF(pMethodName);
wait_unlock();
}

View File

@ -131,14 +131,14 @@ update_requests_for_old_running_thread(DynamicThread& running_thread)
//private constructor. The parameter is discarded
Scheduler::Scheduler()
: _ready_queue(NULL), _policy(NULL)
{}
: _ready_queue(NULL), _policy(NULL), _step_mutex()
{
}
ReadyQueue*
Scheduler::get_ready_queue()
{
// FIXME return the correct queue accordingly to the value returned by Policy::wants()
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
// the policy returns
// 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!

View File

@ -37,6 +37,8 @@ namespace sgpem
// Do not include full template definition here
#include "singleton.hh"
#include <glibmm/thread.h>
namespace sgpem
{
class Scheduler;
@ -74,13 +76,7 @@ namespace sgpem
one instant with it.
*/
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.
\return the policy that will be used to generate the simulation at the next instant.
@ -89,9 +85,11 @@ namespace sgpem
private:
Scheduler(); //private constructor.
ReadyQueue* _ready_queue;
Policy* _policy;
Glib::Mutex _step_mutex;
};
}//~ namespace sgpem

View File

@ -46,7 +46,7 @@ namespace sgpem
static Instantiated_class& get_instance();
protected:
static Glib::StaticMutex SG_DLLLOCAL _mutex;
static Glib::RecMutex SG_DLLLOCAL _mutex;
private:
static SG_DLLLOCAL Instantiated_class* _instance;

View File

@ -26,15 +26,15 @@ Instantiated_class*
sgpem::Singleton<Instantiated_class>::_instance = NULL;
template<typename Instantiated_class>
Glib::StaticMutex
sgpem::Singleton<Instantiated_class>::_mutex = GLIBMM_STATIC_MUTEX_INIT;
Glib::RecMutex
sgpem::Singleton<Instantiated_class>::_mutex;
template<typename Instantiated_class>
Instantiated_class&
sgpem::Singleton<Instantiated_class>::get_instance()
{
Glib::Mutex::Lock lock(_mutex);
Glib::RecMutex::Lock lock(_mutex);
if(_instance == NULL)
_instance = new Instantiated_class();
return *_instance;