- Rename Policy to CPUPolicy where appropriate
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@811 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
5b577c5979
commit
43b817aaed
14
Makefile.am
14
Makefile.am
|
@ -151,6 +151,9 @@ src_backend_libbackend_la_SOURCES = \
|
||||||
src/backend/concrete_environment.cc \
|
src/backend/concrete_environment.cc \
|
||||||
src/backend/concrete_history.cc \
|
src/backend/concrete_history.cc \
|
||||||
src/backend/concrete_simulation.cc \
|
src/backend/concrete_simulation.cc \
|
||||||
|
src/backend/cpu_policies_gatekeeper.cc \
|
||||||
|
src/backend/cpu_policy.cc \
|
||||||
|
src/backend/cpu_policy_manager.cc \
|
||||||
src/backend/dynamic_process.cc \
|
src/backend/dynamic_process.cc \
|
||||||
src/backend/dynamic_request.cc \
|
src/backend/dynamic_request.cc \
|
||||||
src/backend/dynamic_resource.cc \
|
src/backend/dynamic_resource.cc \
|
||||||
|
@ -167,9 +170,6 @@ src_backend_libbackend_la_SOURCES = \
|
||||||
src/backend/module.cc \
|
src/backend/module.cc \
|
||||||
src/backend/null_policy_exception.cc \
|
src/backend/null_policy_exception.cc \
|
||||||
src/backend/plugin_manager.cc \
|
src/backend/plugin_manager.cc \
|
||||||
src/backend/policies_gatekeeper.cc \
|
|
||||||
src/backend/policy.cc \
|
|
||||||
src/backend/policy_manager.cc \
|
|
||||||
src/backend/policy_parameters.cc \
|
src/backend/policy_parameters.cc \
|
||||||
src/backend/process.cc \
|
src/backend/process.cc \
|
||||||
src/backend/ready_queue.cc \
|
src/backend/ready_queue.cc \
|
||||||
|
@ -195,6 +195,9 @@ src_backend_libbackend_la_SOURCES = \
|
||||||
# For headers used internally by the backend, see below.
|
# For headers used internally by the backend, see below.
|
||||||
pkginclude_HEADERS += \
|
pkginclude_HEADERS += \
|
||||||
config.h \
|
config.h \
|
||||||
|
src/backend/cpu_policies_gatekeeper.hh \
|
||||||
|
src/backend/cpu_policy.hh \
|
||||||
|
src/backend/cpu_policy_manager.hh \
|
||||||
src/backend/environment.hh \
|
src/backend/environment.hh \
|
||||||
src/backend/global_preferences.hh \
|
src/backend/global_preferences.hh \
|
||||||
src/backend/history.hh \
|
src/backend/history.hh \
|
||||||
|
@ -204,12 +207,9 @@ pkginclude_HEADERS += \
|
||||||
src/backend/key_file.hh \
|
src/backend/key_file.hh \
|
||||||
src/backend/module.hh \
|
src/backend/module.hh \
|
||||||
src/backend/null_policy_exception.hh \
|
src/backend/null_policy_exception.hh \
|
||||||
|
src/backend/policy_parameters.hh \
|
||||||
src/backend/plugin.hh \
|
src/backend/plugin.hh \
|
||||||
src/backend/plugin_manager.hh \
|
src/backend/plugin_manager.hh \
|
||||||
src/backend/policies_gatekeeper.hh \
|
|
||||||
src/backend/policy.hh \
|
|
||||||
src/backend/policy_manager.hh \
|
|
||||||
src/backend/policy_parameters.hh \
|
|
||||||
src/backend/ready_queue.hh \
|
src/backend/ready_queue.hh \
|
||||||
src/backend/request.hh \
|
src/backend/request.hh \
|
||||||
src/backend/resource.hh \
|
src/backend/resource.hh \
|
||||||
|
|
|
@ -92,16 +92,16 @@ libpyloader_la_LDFLAGS = \
|
||||||
# Please keep this in sorted order:
|
# Please keep this in sorted order:
|
||||||
libpyloader_la_SOURCES = \
|
libpyloader_la_SOURCES = \
|
||||||
src/plugin.cc \
|
src/plugin.cc \
|
||||||
src/python_policy.cc \
|
src/cpu_python_policy.cc \
|
||||||
src/python_policy_manager.cc
|
src/cpu_python_policy_manager.cc
|
||||||
|
|
||||||
noinst_HEADERS += \
|
noinst_HEADERS += \
|
||||||
src/python_policy.hh \
|
src/cpu_python_policy.hh \
|
||||||
src/python_policy_manager.hh
|
src/cpu_python_policy_manager.hh
|
||||||
|
|
||||||
share_PYTHON = \
|
share_PYTHON = \
|
||||||
src/Abstract.py \
|
src/Abstract.py \
|
||||||
src/Policy.py \
|
src/CPUPolicy.py \
|
||||||
src/ScriptAdapter.py
|
src/ScriptAdapter.py
|
||||||
|
|
||||||
# ############################################################
|
# ############################################################
|
||||||
|
@ -165,7 +165,7 @@ noinst_PROGRAMS = \
|
||||||
|
|
||||||
src_testsuite_test_pyloader_CPPFLAGS = \
|
src_testsuite_test_pyloader_CPPFLAGS = \
|
||||||
-I@top_srcdir@ \
|
-I@top_srcdir@ \
|
||||||
-DSHAREDIR="\"$(sharedir)\"" \
|
-DSHAREDIR="\"$(sharedir)\"" \
|
||||||
$(PYTHON_CPPFLAGS) \
|
$(PYTHON_CPPFLAGS) \
|
||||||
$(GLIBMM_CFLAGS) \
|
$(GLIBMM_CFLAGS) \
|
||||||
$(GTHREAD_CFLAGS) \
|
$(GTHREAD_CFLAGS) \
|
||||||
|
@ -181,8 +181,8 @@ src_testsuite_test_pyloader_LDFLAGS = \
|
||||||
$(PYTHON_EXTRA_LDFLAGS)
|
$(PYTHON_EXTRA_LDFLAGS)
|
||||||
src_testsuite_test_pyloader_SOURCES = \
|
src_testsuite_test_pyloader_SOURCES = \
|
||||||
src/testsuite/test-python_loader.cc \
|
src/testsuite/test-python_loader.cc \
|
||||||
src/python_policy.cc \
|
src/cpu_python_policy.cc \
|
||||||
src/python_policy_manager.cc
|
src/cpu_python_policy_manager.cc
|
||||||
|
|
||||||
noinst_PYTHON += src/testsuite/python_loader_configure.py \
|
noinst_PYTHON += src/testsuite/python_loader_configure.py \
|
||||||
src/testsuite/python_loader_sort_queue.py \
|
src/testsuite/python_loader_sort_queue.py \
|
||||||
|
|
|
@ -7,7 +7,7 @@ import sgpem
|
||||||
# This class also exposes the method sort(), which can be
|
# This class also exposes the method sort(), which can be
|
||||||
# used to easily sort the queue of ready process with a
|
# used to easily sort the queue of ready process with a
|
||||||
# user-defined given compare function.
|
# user-defined given compare function.
|
||||||
class Policy:
|
class CPUPolicy:
|
||||||
## @var Avoid instantiation of an abstract class.
|
## @var Avoid instantiation of an abstract class.
|
||||||
# @see Abstract.Metaclass
|
# @see Abstract.Metaclass
|
||||||
__metaclass__ = Metaclass
|
__metaclass__ = Metaclass
|
|
@ -19,11 +19,11 @@
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
|
||||||
from Policy import Policy
|
from CPUPolicy import CPUPolicy
|
||||||
import sys
|
import sys
|
||||||
#from sgpem import policy_sorts_processes
|
#from sgpem import policy_sorts_processes
|
||||||
|
|
||||||
class fcfs(Policy) :
|
class fcfs(CPUPolicy) :
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass;
|
pass;
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,10 @@
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
|
||||||
from Policy import Policy
|
from CPUPolicy import CPUPolicy
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
class rr_priority(Policy) :
|
class rr_priority(CPUPolicy) :
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass;
|
pass;
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
|
||||||
from Policy import Policy
|
from CPUPolicy import CPUPolicy
|
||||||
import sys
|
import sys
|
||||||
#from sgpem import policy_sorts_processes
|
#from sgpem import policy_sorts_processes
|
||||||
|
|
||||||
class sjf(Policy) :
|
class sjf(CPUPolicy) :
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass;
|
pass;
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,12 @@
|
||||||
// along with SGPEMv2; if not, write to the Free Software
|
// along with SGPEMv2; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#include "python_policy.hh"
|
#include "cpu_python_policy.hh"
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -30,14 +32,14 @@ using namespace std;
|
||||||
// WARNING : this class needs extensive and above all
|
// WARNING : this class needs extensive and above all
|
||||||
// *strong* exception checking / handling!
|
// *strong* exception checking / handling!
|
||||||
|
|
||||||
PythonPolicy::PythonPolicy(const char* name)
|
PythonCPUPolicy::PythonCPUPolicy(const char* name)
|
||||||
: _upolicy_dict(NULL), _adapter(NULL), _name(name)
|
: _upolicy_dict(NULL), _adapter(NULL), _name(name)
|
||||||
{
|
{
|
||||||
PyObject* pLoadmeStr = PyString_FromString(name);
|
PyObject* pLoadmeStr = PyString_FromString(name);
|
||||||
PyObject* pUserPolicyModule = PyImport_Import(pLoadmeStr);
|
PyObject* pUserCPUPolicyModule = PyImport_Import(pLoadmeStr);
|
||||||
Py_DECREF(pLoadmeStr);
|
Py_DECREF(pLoadmeStr);
|
||||||
|
|
||||||
if( !pUserPolicyModule )
|
if( !pUserCPUPolicyModule )
|
||||||
{
|
{
|
||||||
PyErr_Print(); // Error in import
|
PyErr_Print(); // Error in import
|
||||||
// FIXME : don't exit abruptly, but fall back gracefully
|
// FIXME : don't exit abruptly, but fall back gracefully
|
||||||
|
@ -45,7 +47,7 @@ PythonPolicy::PythonPolicy(const char* name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dictionary with defined ``symbols'' for .pyc file
|
// Dictionary with defined ``symbols'' for .pyc file
|
||||||
_upolicy_dict = PyModule_GetDict(pUserPolicyModule);
|
_upolicy_dict = PyModule_GetDict(pUserCPUPolicyModule);
|
||||||
assert(_upolicy_dict);
|
assert(_upolicy_dict);
|
||||||
|
|
||||||
// Loads ScriptAdapter module and get its dictionary
|
// Loads ScriptAdapter module and get its dictionary
|
||||||
|
@ -56,16 +58,16 @@ PythonPolicy::PythonPolicy(const char* name)
|
||||||
PyObject* pAdapterDict = PyModule_GetDict(pScriptAdapterModule);
|
PyObject* pAdapterDict = PyModule_GetDict(pScriptAdapterModule);
|
||||||
assert(pAdapterDict);
|
assert(pAdapterDict);
|
||||||
|
|
||||||
// Now takes the user-defined policy class from pUserPolicyDict
|
// Now takes the user-defined policy class from pUserCPUPolicyDict
|
||||||
PyObject* pPolicyClass = PyDict_GetItemString(_upolicy_dict, name);
|
PyObject* pCPUPolicyClass = PyDict_GetItemString(_upolicy_dict, name);
|
||||||
assert(pPolicyClass); // FIXME needs stricter checking and exception throwing
|
assert(pCPUPolicyClass); // FIXME needs stricter checking and exception throwing
|
||||||
|
|
||||||
// Creates a new object of type ScriptAdapter :
|
// Creates a new object of type ScriptAdapter :
|
||||||
// takes init function from ScriptAdapter class
|
// takes init function from ScriptAdapter class
|
||||||
PyObject* pAdapterClass = PyDict_GetItemString(pAdapterDict, "ScriptAdapter");
|
PyObject* pAdapterClass = PyDict_GetItemString(pAdapterDict, "ScriptAdapter");
|
||||||
PyObject* pAdapterCtorParam = PyTuple_New(1);
|
PyObject* pAdapterCtorParam = PyTuple_New(1);
|
||||||
Py_INCREF(pPolicyClass); // PyTuple_SetItem steals a reference
|
Py_INCREF(pCPUPolicyClass); // PyTuple_SetItem steals a reference
|
||||||
PyTuple_SetItem(pAdapterCtorParam, 0, pPolicyClass);
|
PyTuple_SetItem(pAdapterCtorParam, 0, pCPUPolicyClass);
|
||||||
_adapter = PyInstance_New(pAdapterClass, pAdapterCtorParam, NULL);
|
_adapter = PyInstance_New(pAdapterClass, pAdapterCtorParam, NULL);
|
||||||
Py_DECREF(pAdapterCtorParam);
|
Py_DECREF(pAdapterCtorParam);
|
||||||
assert(_adapter);
|
assert(_adapter);
|
||||||
|
@ -76,7 +78,7 @@ PythonPolicy::PythonPolicy(const char* name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PythonPolicy::~PythonPolicy()
|
PythonCPUPolicy::~PythonCPUPolicy()
|
||||||
{
|
{
|
||||||
if(_adapter) Py_DECREF(_adapter);
|
if(_adapter) Py_DECREF(_adapter);
|
||||||
|
|
||||||
|
@ -88,7 +90,7 @@ PythonPolicy::~PythonPolicy()
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PythonPolicy::configure() throw(UserInterruptException)
|
PythonCPUPolicy::configure() throw(UserInterruptException)
|
||||||
{
|
{
|
||||||
PyObject* retval = PyObject_CallMethod(_adapter, "async_configure", NULL);
|
PyObject* retval = PyObject_CallMethod(_adapter, "async_configure", NULL);
|
||||||
Py_DECREF(retval);
|
Py_DECREF(retval);
|
||||||
|
@ -98,7 +100,7 @@ PythonPolicy::configure() throw(UserInterruptException)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PythonPolicy::sort_queue() const throw(UserInterruptException)
|
PythonCPUPolicy::sort_queue() const throw(UserInterruptException)
|
||||||
{
|
{
|
||||||
PyObject* retval = PyObject_CallMethod(_adapter, "async_sort_queue", NULL);
|
PyObject* retval = PyObject_CallMethod(_adapter, "async_sort_queue", NULL);
|
||||||
|
|
||||||
|
@ -111,20 +113,20 @@ PythonPolicy::sort_queue() const throw(UserInterruptException)
|
||||||
|
|
||||||
|
|
||||||
Glib::ustring
|
Glib::ustring
|
||||||
PythonPolicy::get_description() const
|
PythonCPUPolicy::get_description() const
|
||||||
{
|
{
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Glib::ustring
|
Glib::ustring
|
||||||
PythonPolicy::get_name() const
|
PythonCPUPolicy::get_name() const
|
||||||
{
|
{
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PythonPolicy::is_pre_emptive() const throw(UserInterruptException)
|
PythonCPUPolicy::is_pre_emptive() const throw(UserInterruptException)
|
||||||
{
|
{
|
||||||
PyObject* retval = PyObject_CallMethod(_adapter, "async_is_preemptive", NULL);
|
PyObject* retval = PyObject_CallMethod(_adapter, "async_is_preemptive", NULL);
|
||||||
Py_DECREF(retval);
|
Py_DECREF(retval);
|
||||||
|
@ -141,7 +143,7 @@ PythonPolicy::is_pre_emptive() const throw(UserInterruptException)
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
PythonPolicy::get_time_slice() const throw(UserInterruptException)
|
PythonCPUPolicy::get_time_slice() const throw(UserInterruptException)
|
||||||
{
|
{
|
||||||
PyObject* retval = PyObject_CallMethod(_adapter, "async_get_time_slice", NULL);
|
PyObject* retval = PyObject_CallMethod(_adapter, "async_get_time_slice", NULL);
|
||||||
|
|
||||||
|
@ -162,7 +164,7 @@ PythonPolicy::get_time_slice() const throw(UserInterruptException)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PythonPolicy::wait_unlock() const throw(UserInterruptException)
|
PythonCPUPolicy::wait_unlock() const throw(UserInterruptException)
|
||||||
{
|
{
|
||||||
PyThreadState* _save;
|
PyThreadState* _save;
|
||||||
int i = 0; // We give the sort_queue() three seconds max time, then...
|
int i = 0; // We give the sort_queue() three seconds max time, then...
|
|
@ -1,4 +1,4 @@
|
||||||
// src/backend/pyloader/python_policy.hh - Copyright 2005, 2006, University
|
// src/cpu_python_policy.hh - Copyright 2005, 2006, University
|
||||||
// of Padova, dept. of Pure and Applied
|
// of Padova, dept. of Pure and Applied
|
||||||
// Mathematics
|
// Mathematics
|
||||||
//
|
//
|
||||||
|
@ -18,8 +18,8 @@
|
||||||
// along with SGPEMv2; if not, write to the Free Software
|
// along with SGPEMv2; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#ifndef PYTHON_POLICY_HH
|
#ifndef CPU_PYTHON_POLICY_HH
|
||||||
#define PYTHON_POLICY_HH 1
|
#define CPU_PYTHON_POLICY_HH 1
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
@ -28,13 +28,13 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "policy.hh"
|
#include "cpu_policy.hh"
|
||||||
#include "user_interrupt_exception.hh"
|
#include "user_interrupt_exception.hh"
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
class PythonPolicy;
|
class PythonCPUPolicy;
|
||||||
class PythonPolicyManager;
|
class PythonCPUPolicyManager;
|
||||||
class UserInterruptException;
|
class UserInterruptException;
|
||||||
|
|
||||||
/** \brief A specialization of abstract class Policy
|
/** \brief A specialization of abstract class Policy
|
||||||
|
@ -42,11 +42,11 @@ namespace sgpem
|
||||||
This class represents a policy written in Python. Its methods interact with Python interpreter.
|
This class represents a policy written in Python. Its methods interact with Python interpreter.
|
||||||
See the documentation of class Policy for more detailed informations.
|
See the documentation of class Policy for more detailed informations.
|
||||||
*/
|
*/
|
||||||
class SG_DLLEXPORT PythonPolicy : public Policy
|
class SG_DLLEXPORT PythonCPUPolicy : public CPUPolicy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PythonPolicy(const char* name);
|
PythonCPUPolicy(const char* name);
|
||||||
virtual ~PythonPolicy();
|
virtual ~PythonCPUPolicy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Calls the method \c async_configure
|
Calls the method \c async_configure
|
||||||
|
@ -87,8 +87,8 @@ namespace sgpem
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PythonPolicy(const PythonPolicy&);
|
PythonCPUPolicy(const PythonCPUPolicy&);
|
||||||
PythonPolicy& operator=(const PythonPolicy&);
|
PythonCPUPolicy& operator=(const PythonCPUPolicy&);
|
||||||
|
|
||||||
void wait_unlock() const throw(UserInterruptException);
|
void wait_unlock() const throw(UserInterruptException);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// src/python_policy_manager.cc - Copyright 2005, 2006, University
|
// src/cpu_python_policy_manager.cc - Copyright 2005, 2006, University
|
||||||
// of Padova, dept. of Pure and Applied
|
// of Padova, dept. of Pure and Applied
|
||||||
// Mathematics
|
// Mathematics
|
||||||
//
|
//
|
||||||
|
@ -18,9 +18,9 @@
|
||||||
// along with SGPEMv2; if not, write to the Free Software
|
// along with SGPEMv2; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#include "python_policy_manager.hh"
|
#include "cpu_python_policy_manager.hh"
|
||||||
#include "global_preferences.hh"
|
#include "global_preferences.hh"
|
||||||
#include "policies_gatekeeper.hh"
|
#include "cpu_policies_gatekeeper.hh"
|
||||||
|
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
|
@ -35,6 +35,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
@ -57,21 +58,21 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
PythonPolicyManager::PythonPolicyManager()
|
PythonCPUPolicyManager::PythonCPUPolicyManager()
|
||||||
: _initialized(false)
|
: _initialized(false)
|
||||||
{
|
{
|
||||||
PyEval_InitThreads();
|
PyEval_InitThreads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PythonPolicyManager::~PythonPolicyManager()
|
PythonCPUPolicyManager::~PythonCPUPolicyManager()
|
||||||
{
|
{
|
||||||
for_each(_policies.begin(), _policies.end(), ptr_fun(operator delete));
|
for_each(_policies.begin(), _policies.end(), ptr_fun(operator delete));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PythonPolicyManager::init()
|
PythonCPUPolicyManager::init()
|
||||||
{
|
{
|
||||||
if(_initialized)
|
if(_initialized)
|
||||||
// No-op
|
// No-op
|
||||||
|
@ -100,14 +101,14 @@ PythonPolicyManager::init()
|
||||||
collect_policies();
|
collect_policies();
|
||||||
}
|
}
|
||||||
|
|
||||||
const vector<Policy*>&
|
const vector<CPUPolicy*>&
|
||||||
PythonPolicyManager::get_avail_policies()
|
PythonCPUPolicyManager::get_avail_policies()
|
||||||
{
|
{
|
||||||
return _policies;
|
return _policies;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PythonPolicyManager::collect_policies()
|
PythonCPUPolicyManager::collect_policies()
|
||||||
{
|
{
|
||||||
GlobalPreferences& prefs = GlobalPreferences::get_instance();
|
GlobalPreferences& prefs = GlobalPreferences::get_instance();
|
||||||
GlobalPreferences::dir_iterator dir_it = prefs.policies_dir_begin();
|
GlobalPreferences::dir_iterator dir_it = prefs.policies_dir_begin();
|
||||||
|
@ -132,7 +133,7 @@ PythonPolicyManager::collect_policies()
|
||||||
//strip extension
|
//strip extension
|
||||||
std::string policy_name = (*file_it).substr(0, (*file_it).size() - 3);
|
std::string policy_name = (*file_it).substr(0, (*file_it).size() - 3);
|
||||||
|
|
||||||
PythonPolicy *pypolicy = new PythonPolicy(policy_name.c_str());
|
PythonCPUPolicy *pypolicy = new PythonCPUPolicy(policy_name.c_str());
|
||||||
|
|
||||||
_policies.push_back(pypolicy);
|
_policies.push_back(pypolicy);
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
// src/python_policy_manager.hh - Copyright 2005, 2006, University
|
// src/cpu_python_policy_manager.hh - Copyright 2005, 2006, University
|
||||||
// of Padova, dept. of Pure and Applied
|
// of Padova, dept. of Pure and Applied
|
||||||
// Mathematics
|
// Mathematics
|
||||||
//
|
//
|
||||||
|
@ -18,31 +18,31 @@
|
||||||
// along with SGPEMv2; if not, write to the Free Software
|
// along with SGPEMv2; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#ifndef PYTHON_POLICY_MANAGER_HH
|
#ifndef CPU_PYTHON_POLICY_MANAGER_HH
|
||||||
#define PYTHON_POLICY_MANAGER_HH 1
|
#define CPU_PYTHON_POLICY_MANAGER_HH 1
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|
||||||
#include "policy_manager.hh"
|
#include "cpu_policy_manager.hh"
|
||||||
#include "python_policy.hh"
|
#include "cpu_python_policy.hh"
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
//class PolicyManager;
|
//class CPUPolicyManager;
|
||||||
class PythonPolicyManager;
|
class PythonCPUPolicyManager;
|
||||||
|
|
||||||
/** \brief Manages Python user-implemented policies
|
/** \brief Manages Python user-implemented policies
|
||||||
*
|
*
|
||||||
* This singleton manages the creation and destruction
|
* This singleton manages the creation and destruction
|
||||||
* of a Python policy.
|
* of a Python policy.
|
||||||
*/
|
*/
|
||||||
class SG_DLLEXPORT PythonPolicyManager : public PolicyManager
|
class SG_DLLEXPORT PythonCPUPolicyManager : public CPUPolicyManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PythonPolicyManager();
|
PythonCPUPolicyManager();
|
||||||
~PythonPolicyManager();
|
~PythonCPUPolicyManager();
|
||||||
|
|
||||||
/** \brief Initialize the Python interpreter.
|
/** \brief Initialize the Python interpreter.
|
||||||
*
|
*
|
||||||
|
@ -51,15 +51,15 @@ namespace sgpem
|
||||||
*/
|
*/
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
const std::vector<Policy*>& get_avail_policies();
|
const std::vector<CPUPolicy*>& get_avail_policies();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** The selected and active PyhonPolicy object. */
|
/** The selected and active PyhonCPUPolicy object. */
|
||||||
void collect_policies();
|
void collect_policies();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PythonPolicyManager(const PythonPolicyManager&);
|
PythonCPUPolicyManager(const PythonCPUPolicyManager&);
|
||||||
PythonPolicyManager& operator=(const PythonPolicyManager&);
|
PythonCPUPolicyManager& operator=(const PythonCPUPolicyManager&);
|
||||||
|
|
||||||
bool _initialized;
|
bool _initialized;
|
||||||
};
|
};
|
|
@ -21,18 +21,18 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "plugin.hh"
|
#include "plugin.hh"
|
||||||
#include "python_policy_manager.hh"
|
#include "cpu_python_policy_manager.hh"
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
|
|
||||||
// Is this OK? If not, we must use a function with a local static variable...
|
// Is this OK? If not, we must use a function with a local static variable...
|
||||||
PythonPolicyManager* _policy_manager = NULL;
|
PythonCPUPolicyManager* _policy_manager = NULL;
|
||||||
|
|
||||||
void
|
void
|
||||||
sgpem__Plugin__on_init()
|
sgpem__Plugin__on_init()
|
||||||
{
|
{
|
||||||
if(_policy_manager == NULL)
|
if(_policy_manager == NULL)
|
||||||
_policy_manager = new sgpem::PythonPolicyManager();
|
_policy_manager = new sgpem::PythonCPUPolicyManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
%module sgpem
|
%module sgpem
|
||||||
%{
|
%{
|
||||||
#include "policy.hh"
|
#include "cpu_policy.hh"
|
||||||
#include "policy_parameters.hh"
|
#include "policy_parameters.hh"
|
||||||
#include "process.hh"
|
#include "process.hh"
|
||||||
#include "ready_queue.hh"
|
#include "ready_queue.hh"
|
||||||
|
@ -59,9 +59,9 @@ namespace std
|
||||||
|
|
||||||
namespace sgpem {
|
namespace sgpem {
|
||||||
|
|
||||||
class Policy {
|
class CPUPolicy {
|
||||||
public:
|
public:
|
||||||
virtual ~Policy() = 0;
|
virtual ~CPUPolicy() = 0;
|
||||||
sgpem::PolicyParameters& get_parameters();
|
sgpem::PolicyParameters& get_parameters();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ namespace sgpem {
|
||||||
// ---------------------------------------------
|
// ---------------------------------------------
|
||||||
class Scheduler {
|
class Scheduler {
|
||||||
public:
|
public:
|
||||||
sgpem::Policy* get_policy();
|
sgpem::CPUPolicy* get_policy();
|
||||||
static sgpem::Scheduler& get_instance();
|
static sgpem::Scheduler& get_instance();
|
||||||
sgpem::ReadyQueue* get_ready_queue();
|
sgpem::ReadyQueue* get_ready_queue();
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from Policy import Policy
|
from CPUPolicy import CPUPolicy
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
class python_loader_configure(Policy) :
|
class python_loader_configure(CPUPolicy) :
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass;
|
pass;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from Policy import Policy
|
from CPUPolicy import CPUPolicy
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
class python_loader_get_time_slice(Policy) :
|
class python_loader_get_time_slice(CPUPolicy) :
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from Policy import Policy
|
from CPUPolicy import CPUPolicy
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
class python_loader_is_preemptive(Policy) :
|
class python_loader_is_preemptive(CPUPolicy) :
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from Policy import Policy
|
from CPUPolicy import CPUPolicy
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
class python_loader_sort_queue(Policy) :
|
class python_loader_sort_queue(CPUPolicy) :
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -22,12 +22,12 @@
|
||||||
* class and its closely related cousins. More documentation to be written
|
* class and its closely related cousins. More documentation to be written
|
||||||
* here, thanks very much. */
|
* here, thanks very much. */
|
||||||
|
|
||||||
#include "../python_policy_manager.hh"
|
#include "../cpu_python_policy_manager.hh"
|
||||||
#include "../python_policy.hh"
|
#include "../cpu_python_policy.hh"
|
||||||
|
|
||||||
#include "simulation.hh"
|
#include "simulation.hh"
|
||||||
#include "global_preferences.hh"
|
#include "global_preferences.hh"
|
||||||
#include "policies_gatekeeper.hh"
|
#include "cpu_policies_gatekeeper.hh"
|
||||||
#include "simulation.hh"
|
#include "simulation.hh"
|
||||||
#include "scheduler.hh"
|
#include "scheduler.hh"
|
||||||
#include "user_interrupt_exception.hh"
|
#include "user_interrupt_exception.hh"
|
||||||
|
@ -42,10 +42,10 @@
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static Policy*
|
static CPUPolicy*
|
||||||
find_pol_by_name(const vector<Policy*>& pols, const Glib::ustring& name)
|
find_pol_by_name(const vector<CPUPolicy*>& pols, const Glib::ustring& name)
|
||||||
{
|
{
|
||||||
vector<Policy*>::const_iterator it = pols.begin();
|
vector<CPUPolicy*>::const_iterator it = pols.begin();
|
||||||
for( ; it != pols.end(); it++)
|
for( ; it != pols.end(); it++)
|
||||||
if((*it)->get_name() == name)
|
if((*it)->get_name() == name)
|
||||||
return *it;
|
return *it;
|
||||||
|
@ -69,24 +69,24 @@ main(int argc, char** argv)
|
||||||
sgpem::GlobalPreferences::get_instance().add_policies_dir(argv[1]);
|
sgpem::GlobalPreferences::get_instance().add_policies_dir(argv[1]);
|
||||||
|
|
||||||
// Self-register itself to PoliciesGatekeeper, however we don't care about it
|
// Self-register itself to PoliciesGatekeeper, however we don't care about it
|
||||||
PythonPolicyManager polman;
|
PythonCPUPolicyManager polman;
|
||||||
polman.init();
|
polman.init();
|
||||||
|
|
||||||
Simulation& sim = Simulation::get_instance();
|
Simulation& sim = Simulation::get_instance();
|
||||||
History& his = sim.get_history();
|
History& his = sim.get_history();
|
||||||
PoliciesGatekeeper& pgk = PoliciesGatekeeper::get_instance();
|
CPUPoliciesGatekeeper& pgk = CPUPoliciesGatekeeper::get_instance();
|
||||||
|
|
||||||
const std::vector<Policy*>& policies = polman.get_avail_policies();
|
const std::vector<CPUPolicy*>& policies = polman.get_avail_policies();
|
||||||
|
|
||||||
// Print out avail policies
|
// Print out avail policies
|
||||||
cout << "These are the policies I found:" << endl;
|
cout << "These are the policies I found:" << endl;
|
||||||
vector<Policy*>::const_iterator it = policies.begin();
|
vector<CPUPolicy*>::const_iterator it = policies.begin();
|
||||||
for(; it != policies.end(); it++)
|
for(; it != policies.end(); it++)
|
||||||
cout << "\t * " << (*it)->get_name() << endl;
|
cout << "\t * " << (*it)->get_name() << endl;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Policy* pol = find_pol_by_name(policies, "python_loader_configure");
|
CPUPolicy* pol = find_pol_by_name(policies, "python_loader_configure");
|
||||||
assert(pol != NULL);
|
assert(pol != NULL);
|
||||||
|
|
||||||
// FIXME : Maybe activating a policy only to configure it is an overkill?
|
// FIXME : Maybe activating a policy only to configure it is an overkill?
|
||||||
|
@ -103,7 +103,7 @@ main(int argc, char** argv)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Policy* pol = find_pol_by_name(policies, "python_loader_is_preemptive");
|
CPUPolicy* pol = find_pol_by_name(policies, "python_loader_is_preemptive");
|
||||||
assert(pol != NULL);
|
assert(pol != NULL);
|
||||||
pgk.activate_policy(&his, pol);
|
pgk.activate_policy(&his, pol);
|
||||||
pol->is_pre_emptive();
|
pol->is_pre_emptive();
|
||||||
|
@ -117,7 +117,7 @@ main(int argc, char** argv)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Policy* pol = find_pol_by_name(policies, "python_loader_get_time_slice");
|
CPUPolicy* pol = find_pol_by_name(policies, "python_loader_get_time_slice");
|
||||||
assert(pol != NULL);
|
assert(pol != NULL);
|
||||||
pgk.activate_policy(&his, pol);
|
pgk.activate_policy(&his, pol);
|
||||||
pol->get_time_slice();
|
pol->get_time_slice();
|
||||||
|
@ -132,7 +132,7 @@ main(int argc, char** argv)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Policy* pol = find_pol_by_name(policies, "python_loader_get_time_slice");
|
CPUPolicy* pol = find_pol_by_name(policies, "python_loader_get_time_slice");
|
||||||
assert(pol != NULL);
|
assert(pol != NULL);
|
||||||
pgk.activate_policy(&his, pol);
|
pgk.activate_policy(&his, pol);
|
||||||
pol->sort_queue();
|
pol->sort_queue();
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "concrete_simulation.hh"
|
#include "concrete_simulation.hh"
|
||||||
#include "scheduler.hh"
|
#include "scheduler.hh"
|
||||||
#include "policies_gatekeeper.hh"
|
#include "cpu_policies_gatekeeper.hh"
|
||||||
#include <glibmm/timer.h>
|
#include <glibmm/timer.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
@ -155,16 +155,16 @@ ConcreteSimulation::get_history()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ConcreteSimulation::set_policy(Policy* p)
|
ConcreteSimulation::set_policy(CPUPolicy* p)
|
||||||
{
|
{
|
||||||
_policy = p;
|
_policy = p;
|
||||||
|
|
||||||
if(p != NULL)
|
if(p != NULL)
|
||||||
PoliciesGatekeeper::get_instance().activate_policy(&_history, p);
|
CPUPoliciesGatekeeper::get_instance().activate_policy(&_history, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Policy*
|
CPUPolicy*
|
||||||
ConcreteSimulation::get_policy()
|
ConcreteSimulation::get_policy()
|
||||||
{
|
{
|
||||||
return _policy;
|
return _policy;
|
||||||
|
|
|
@ -49,18 +49,18 @@ namespace sgpem
|
||||||
|
|
||||||
state get_state() const;
|
state get_state() const;
|
||||||
|
|
||||||
void set_policy(Policy*);
|
void set_policy(CPUPolicy*);
|
||||||
|
|
||||||
ConcreteHistory& get_history();
|
ConcreteHistory& get_history();
|
||||||
|
|
||||||
Policy* get_policy();
|
CPUPolicy* get_policy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
state _state;
|
state _state;
|
||||||
bool _mode;
|
bool _mode;
|
||||||
int _timer_interval;
|
int _timer_interval;
|
||||||
ConcreteHistory _history;
|
ConcreteHistory _history;
|
||||||
Policy* _policy;
|
CPUPolicy* _policy;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// src/backend/policies_gatekeeper.cc - Copyright 2005, 2006, University
|
// src/backend/cpu_policies_gatekeeper.cc - Copyright 2005, 2006, University
|
||||||
// of Padova, dept. of Pure and Applied
|
// of Padova, dept. of Pure and Applied
|
||||||
// Mathematics
|
// Mathematics
|
||||||
//
|
//
|
||||||
|
@ -20,9 +20,9 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "policies_gatekeeper.hh"
|
#include "cpu_policies_gatekeeper.hh"
|
||||||
#include "policy_manager.hh"
|
#include "cpu_policy_manager.hh"
|
||||||
#include "policy.hh"
|
#include "cpu_policy.hh"
|
||||||
|
|
||||||
// Include full template definition only in implementation files:
|
// Include full template definition only in implementation files:
|
||||||
#include "singleton.tcc"
|
#include "singleton.tcc"
|
||||||
|
@ -37,19 +37,19 @@ using std::runtime_error;
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
|
|
||||||
// Explicit template instantiation to allow to export symbols from the DSO.
|
// Explicit template instantiation to allow to export symbols from the DSO.
|
||||||
template class SG_DLLEXPORT Singleton<PoliciesGatekeeper>;
|
template class SG_DLLEXPORT Singleton<CPUPoliciesGatekeeper>;
|
||||||
|
|
||||||
typedef vector<PolicyManager*>::iterator ManagerIterator;
|
typedef vector<CPUPolicyManager*>::iterator ManagerIterator;
|
||||||
typedef map<History*, Policy*>::iterator ActiveIterator;
|
typedef map<History*, CPUPolicy*>::iterator ActiveIterator;
|
||||||
|
|
||||||
vector<PolicyManager*>
|
vector<CPUPolicyManager*>
|
||||||
PoliciesGatekeeper::get_registered() const
|
CPUPoliciesGatekeeper::get_registered() const
|
||||||
{
|
{
|
||||||
return _registered;
|
return _registered;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PoliciesGatekeeper::register_manager(PolicyManager* manager)
|
CPUPoliciesGatekeeper::register_manager(CPUPolicyManager* manager)
|
||||||
{
|
{
|
||||||
assert(manager != NULL);
|
assert(manager != NULL);
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ PoliciesGatekeeper::register_manager(PolicyManager* manager)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PoliciesGatekeeper::unregister_manager(PolicyManager* manager)
|
CPUPoliciesGatekeeper::unregister_manager(CPUPolicyManager* manager)
|
||||||
{
|
{
|
||||||
assert(manager != NULL);
|
assert(manager != NULL);
|
||||||
|
|
||||||
|
@ -74,8 +74,8 @@ PoliciesGatekeeper::unregister_manager(PolicyManager* manager)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Policy*
|
CPUPolicy*
|
||||||
PoliciesGatekeeper::get_current_policy(History* history) throw(runtime_error)
|
CPUPoliciesGatekeeper::get_current_policy(History* history) throw(runtime_error)
|
||||||
{
|
{
|
||||||
assert(history != NULL);
|
assert(history != NULL);
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ PoliciesGatekeeper::get_current_policy(History* history) throw(runtime_error)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PoliciesGatekeeper::activate_policy(History *history, Policy* policy)
|
CPUPoliciesGatekeeper::activate_policy(History *history, CPUPolicy* policy)
|
||||||
{
|
{
|
||||||
assert(history != NULL && policy != NULL);
|
assert(history != NULL && policy != NULL);
|
||||||
|
|
||||||
|
@ -106,18 +106,18 @@ PoliciesGatekeeper::activate_policy(History *history, Policy* policy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PoliciesGatekeeper::PoliciesGatekeeper()
|
CPUPoliciesGatekeeper::CPUPoliciesGatekeeper()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void
|
void
|
||||||
PoliciesGatekeeper::deactivate_policies(PolicyManager* manager)
|
CPUPoliciesGatekeeper::deactivate_policies(CPUPolicyManager* manager)
|
||||||
{
|
{
|
||||||
typedef vector<Policy*>::iterator PolicyIterator;
|
typedef vector<CPUPolicy*>::iterator CPUPolicyIterator;
|
||||||
|
|
||||||
vector<Policy*> avail_policies = manager->get_avail_policies();
|
vector<CPUPolicy*> avail_policies = manager->get_avail_policies();
|
||||||
|
|
||||||
PolicyIterator avail_it = avail_policies.begin();
|
CPUPolicyIterator avail_it = avail_policies.begin();
|
||||||
PolicyIterator avail_end = avail_policies.end();
|
CPUPolicyIterator avail_end = avail_policies.end();
|
||||||
|
|
||||||
for(; avail_it != avail_end; ++avail_it)
|
for(; avail_it != avail_end; ++avail_it)
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
// src/backend/policies_gatekeeper.hh - Copyright 2005, 2006, University
|
// src/backend/cpu_policies_gatekeeper.hh - Copyright 2005, 2006, University
|
||||||
// of Padova, dept. of Pure and Applied
|
// of Padova, dept. of Pure and Applied
|
||||||
// Mathematics
|
// Mathematics
|
||||||
//
|
//
|
||||||
|
@ -18,13 +18,13 @@
|
||||||
// along with SGPEMv2; if not, write to the Free Software
|
// along with SGPEMv2; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#ifndef POLICIES_GATEKEEPER_HH
|
#ifndef CPU_POLICIES_GATEKEEPER_HH
|
||||||
#define POLICIES_GATEKEEPER_HH 1
|
#define CPU_POLICIES_GATEKEEPER_HH 1
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
class PolicyManager;
|
class CPUPolicyManager;
|
||||||
class Policy;
|
class CPUPolicy;
|
||||||
class History;
|
class History;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,41 +38,41 @@ namespace sgpem
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
class PoliciesGatekeeper;
|
class CPUPoliciesGatekeeper;
|
||||||
|
|
||||||
/** \brief FIXME document me
|
/** \brief FIXME document me
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SG_DLLEXPORT PoliciesGatekeeper : public Singleton<PoliciesGatekeeper>
|
class SG_DLLEXPORT CPUPoliciesGatekeeper : public Singleton<CPUPoliciesGatekeeper>
|
||||||
{
|
{
|
||||||
friend class Singleton<PoliciesGatekeeper>;
|
friend class Singleton<CPUPoliciesGatekeeper>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<PolicyManager*> get_registered() const;
|
std::vector<CPUPolicyManager*> get_registered() const;
|
||||||
|
|
||||||
void register_manager(PolicyManager* manager);
|
void register_manager(CPUPolicyManager* manager);
|
||||||
|
|
||||||
void unregister_manager(PolicyManager* manager);
|
void unregister_manager(CPUPolicyManager* manager);
|
||||||
|
|
||||||
Policy* get_current_policy(History* history) throw(std::runtime_error);
|
CPUPolicy* get_current_policy(History* history) throw(std::runtime_error);
|
||||||
|
|
||||||
void activate_policy(History* history, Policy* policy);
|
void activate_policy(History* history, CPUPolicy* policy);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PoliciesGatekeeper(); //private constructor.
|
CPUPoliciesGatekeeper(); //private constructor.
|
||||||
PoliciesGatekeeper(const PoliciesGatekeeper&);
|
CPUPoliciesGatekeeper(const CPUPoliciesGatekeeper&);
|
||||||
PoliciesGatekeeper& operator=(const PoliciesGatekeeper&);
|
CPUPoliciesGatekeeper& operator=(const CPUPoliciesGatekeeper&);
|
||||||
|
|
||||||
// Deactivates active policies managed by the specified manager.
|
// Deactivates active policies managed by the specified manager.
|
||||||
void deactivate_policies(PolicyManager* manager);
|
void deactivate_policies(CPUPolicyManager* manager);
|
||||||
|
|
||||||
std::vector<PolicyManager*> _registered;
|
std::vector<CPUPolicyManager*> _registered;
|
||||||
std::map<History*, Policy*> _active_policies;
|
std::map<History*, CPUPolicy*> _active_policies;
|
||||||
};
|
};
|
||||||
|
|
||||||
}//~ namespace sgpem
|
}//~ namespace sgpem
|
||||||
|
|
||||||
#endif //POLICIES_GATEKEEPER_HH
|
#endif //~ CPU_POLICIES_GATEKEEPER_HH
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// src/backend/policy.cc - Copyright 2005, 2006, University
|
// src/backend/cpu_policy.cc - Copyright 2005, 2006, University
|
||||||
// of Padova, dept. of Pure and Applied
|
// of Padova, dept. of Pure and Applied
|
||||||
// Mathematics
|
// Mathematics
|
||||||
//
|
//
|
||||||
|
@ -18,16 +18,16 @@
|
||||||
// along with SGPEMv2; if not, write to the Free Software
|
// along with SGPEMv2; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#include "policy.hh"
|
#include "cpu_policy.hh"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
|
|
||||||
Policy::~Policy()
|
CPUPolicy::~CPUPolicy()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
PolicyParameters&
|
PolicyParameters&
|
||||||
Policy::get_parameters()
|
CPUPolicy::get_parameters()
|
||||||
{
|
{
|
||||||
return _parameters;
|
return _parameters;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
// src/backend/policy.hh - Copyright 2005, 2006, University
|
// src/backend/cpu_policy.hh - Copyright 2005, 2006, University
|
||||||
// of Padova, dept. of Pure and Applied
|
// of Padova, dept. of Pure and Applied
|
||||||
// Mathematics
|
// Mathematics
|
||||||
//
|
//
|
||||||
|
@ -18,8 +18,8 @@
|
||||||
// along with SGPEMv2; if not, write to the Free Software
|
// along with SGPEMv2; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#ifndef POLICY_HH
|
#ifndef CPU_POLICY_HH
|
||||||
#define POLICY_HH 1
|
#define CPU_POLICY_HH 1
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
class Policy;
|
class CPUPolicy;
|
||||||
|
|
||||||
/** \brief
|
/** \brief
|
||||||
It's a Strategy wich stay for a scheduling algorithm.
|
It's a Strategy wich stay for a scheduling algorithm.
|
||||||
|
@ -39,10 +39,10 @@ namespace sgpem
|
||||||
Its goal is, usually, to keep a list of Schedulable objects
|
Its goal is, usually, to keep a list of Schedulable objects
|
||||||
mantained in a ReadyQueue.
|
mantained in a ReadyQueue.
|
||||||
*/
|
*/
|
||||||
class SG_DLLEXPORT Policy
|
class SG_DLLEXPORT CPUPolicy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~Policy();
|
virtual ~CPUPolicy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize the inner components of the policy.
|
Initialize the inner components of the policy.
|
||||||
|
@ -107,5 +107,4 @@ namespace sgpem
|
||||||
|
|
||||||
}//~ namespace sgpem
|
}//~ namespace sgpem
|
||||||
|
|
||||||
|
#endif //~ CPU_POLICY_HH
|
||||||
#endif
|
|
|
@ -1,4 +1,4 @@
|
||||||
// src/backend/policy_manager.cc - Copyright 2005, 2006, University
|
// src/backend/cpu_policy_manager.cc - Copyright 2005, 2006, University
|
||||||
// of Padova, dept. of Pure and Applied
|
// of Padova, dept. of Pure and Applied
|
||||||
// Mathematics
|
// Mathematics
|
||||||
//
|
//
|
||||||
|
@ -19,32 +19,32 @@
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
|
||||||
#include "policy_manager.hh"
|
#include "cpu_policy_manager.hh"
|
||||||
#include "policies_gatekeeper.hh"
|
#include "cpu_policies_gatekeeper.hh"
|
||||||
|
|
||||||
PolicyManager*
|
CPUPolicyManager*
|
||||||
PolicyManager::_registered = NULL;
|
CPUPolicyManager::_registered = NULL;
|
||||||
|
|
||||||
PolicyManager::PolicyManager()
|
CPUPolicyManager::CPUPolicyManager()
|
||||||
{
|
{
|
||||||
//FIXME remove this when get_registered_manager is dropped
|
//FIXME remove this when get_registered_manager is dropped
|
||||||
_registered = this;
|
_registered = this;
|
||||||
|
|
||||||
PoliciesGatekeeper::get_instance().register_manager(this);
|
CPUPoliciesGatekeeper::get_instance().register_manager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PolicyManager::~PolicyManager()
|
CPUPolicyManager::~CPUPolicyManager()
|
||||||
{
|
{
|
||||||
// This check is necessary:
|
// This check is necessary:
|
||||||
//FIXME remove this when get_registered_manager is dropped
|
//FIXME remove this when get_registered_manager is dropped
|
||||||
if(_registered == this) _registered = NULL;
|
if(_registered == this) _registered = NULL;
|
||||||
|
|
||||||
PoliciesGatekeeper::get_instance().unregister_manager(this);
|
CPUPoliciesGatekeeper::get_instance().unregister_manager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
PolicyManager&
|
CPUPolicyManager&
|
||||||
PolicyManager::get_registered_manager()
|
CPUPolicyManager::get_registered_manager()
|
||||||
{
|
{
|
||||||
return *_registered;
|
return *_registered;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
// src/backend/policy_manager.hh - Copyright 2005, 2006, University
|
// src/backend/cpu_policy_manager.hh - Copyright 2005, 2006, University
|
||||||
// of Padova, dept. of Pure and Applied
|
// of Padova, dept. of Pure and Applied
|
||||||
// Mathematics
|
// Mathematics
|
||||||
//
|
//
|
||||||
|
@ -18,38 +18,38 @@
|
||||||
// along with SGPEMv2; if not, write to the Free Software
|
// along with SGPEMv2; if not, write to the Free Software
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#ifndef POLICY_MANAGER_HH
|
#ifndef CPU_POLICY_MANAGER_HH
|
||||||
#define POLICY_MANAGER_HH 1
|
#define CPU_POLICY_MANAGER_HH 1
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "policy.hh"
|
#include "cpu_policy.hh"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
class PolicyManager;
|
class CPUPolicyManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
PolicyManager is the Abstract Factory for \ref Policy objects.
|
CPUPolicyManager is the Abstract Factory for \ref CPUPolicy objects.
|
||||||
*/
|
*/
|
||||||
class SG_DLLEXPORT PolicyManager
|
class SG_DLLEXPORT CPUPolicyManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** \brief PolicyManager constructor
|
/** \brief CPUPolicyManager constructor
|
||||||
*
|
*
|
||||||
* Saves ``this'' pointer into the _registered attribute, so it can access
|
* Saves ``this'' pointer into the _registered attribute, so it can access
|
||||||
* it when requested. This is done so that concrete subclasses can be defined
|
* it when requested. This is done so that concrete subclasses can be defined
|
||||||
* even if they are found in external dynamic modules not known at compile time.
|
* even if they are found in external dynamic modules not known at compile time.
|
||||||
*
|
*
|
||||||
* For the moment, just an instance of PolicyManager can be saved. This will
|
* For the moment, just an instance of CPUPolicyManager can be saved. This will
|
||||||
* be expanded in next milestones.
|
* be expanded in next milestones.
|
||||||
*/
|
*/
|
||||||
PolicyManager();
|
CPUPolicyManager();
|
||||||
|
|
||||||
virtual ~PolicyManager() = 0;
|
virtual ~CPUPolicyManager() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gets THE policy (the only today) used.
|
Gets THE policy (the only today) used.
|
||||||
|
@ -57,7 +57,7 @@ namespace sgpem
|
||||||
\return A reference to the policy.
|
\return A reference to the policy.
|
||||||
FIXME deprecated
|
FIXME deprecated
|
||||||
*/
|
*/
|
||||||
//virtual Policy& get_policy() = 0;
|
//virtual CPUPolicy& get_policy() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Init (or reset if yet initialized) the manager.
|
Init (or reset if yet initialized) the manager.
|
||||||
|
@ -65,23 +65,23 @@ namespace sgpem
|
||||||
*/
|
*/
|
||||||
virtual void init() = 0;
|
virtual void init() = 0;
|
||||||
|
|
||||||
virtual const std::vector<Policy*>& get_avail_policies() = 0;
|
virtual const std::vector<CPUPolicy*>& get_avail_policies() = 0;
|
||||||
|
|
||||||
/** \brief Get the registered manager instance
|
/** \brief Get the registered manager instance
|
||||||
* FIXME deprecated
|
* FIXME deprecated
|
||||||
*
|
*
|
||||||
* \return The registered policy manager instance.
|
* \return The registered policy manager instance.
|
||||||
*/
|
*/
|
||||||
static PolicyManager& get_registered_manager();
|
static CPUPolicyManager& get_registered_manager();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void collect_policies() = 0;
|
virtual void collect_policies() = 0;
|
||||||
|
|
||||||
std::vector<Policy*> _policies;
|
std::vector<CPUPolicy*> _policies;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** A pointer to the registered instance */
|
/** A pointer to the registered instance */
|
||||||
static PolicyManager* _registered;
|
static CPUPolicyManager* _registered;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //~ namespace sgpem
|
} //~ namespace sgpem
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "concrete_environment.hh"
|
#include "concrete_environment.hh"
|
||||||
#include "concrete_history.hh"
|
#include "concrete_history.hh"
|
||||||
#include "policy.hh"
|
#include "cpu_policy.hh"
|
||||||
#include "scheduler.hh"
|
#include "scheduler.hh"
|
||||||
#include "user_interrupt_exception.hh"
|
#include "user_interrupt_exception.hh"
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ Scheduler::reset_status()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Policy*
|
CPUPolicy*
|
||||||
Scheduler::get_policy()
|
Scheduler::get_policy()
|
||||||
{
|
{
|
||||||
return _policy;
|
return _policy;
|
||||||
|
@ -162,7 +162,7 @@ Scheduler::get_policy()
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Scheduler::step_forward(History& history, Policy& cpu_policy) throw(UserInterruptException)
|
Scheduler::step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInterruptException)
|
||||||
{
|
{
|
||||||
// This very method should be exclusive: no concurrent behaviour, from when we
|
// 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
|
// store a readyqueue and policy pointer for the user-policy to retrieve, to when
|
||||||
|
|
|
@ -23,14 +23,13 @@
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
class Scheduler;
|
class Scheduler;
|
||||||
class PolicyManager;
|
class CPUPolicy;
|
||||||
class Policy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "history.hh"
|
#include "history.hh"
|
||||||
#include "policy.hh"
|
#include "cpu_policy.hh"
|
||||||
#include "ready_queue.hh"
|
#include "ready_queue.hh"
|
||||||
#include "user_interrupt_exception.hh"
|
#include "user_interrupt_exception.hh"
|
||||||
|
|
||||||
|
@ -77,19 +76,19 @@ namespace sgpem
|
||||||
|
|
||||||
\return false If the simulation has ended, true otherwise
|
\return false If the simulation has ended, true otherwise
|
||||||
*/
|
*/
|
||||||
bool step_forward(History& history, Policy& cpu_policy) throw(UserInterruptException);
|
bool step_forward(History& history, CPUPolicy& cpu_policy) throw(UserInterruptException);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
Policy* get_policy();
|
CPUPolicy* get_policy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Scheduler(); //private constructor.
|
Scheduler(); //private constructor.
|
||||||
|
|
||||||
ReadyQueue* _ready_queue;
|
ReadyQueue* _ready_queue;
|
||||||
Policy* _policy;
|
CPUPolicy* _policy;
|
||||||
|
|
||||||
Glib::Mutex _step_mutex;
|
Glib::Mutex _step_mutex;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
class ConcreteSimulation;
|
class ConcreteSimulation;
|
||||||
class Policy;
|
class CPUPolicy;
|
||||||
class History;
|
class History;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ namespace sgpem
|
||||||
check which schedulng algorithm is currently in use.
|
check which schedulng algorithm is currently in use.
|
||||||
|
|
||||||
\remarks Implements the Observer pattern: observes classes \ref History, \ref Scheduler,
|
\remarks Implements the Observer pattern: observes classes \ref History, \ref Scheduler,
|
||||||
\ref Policy.
|
\ref CPUPolicy.
|
||||||
\remarks Implements the Controller pattern: ensures Low Coupling between the Frontend and
|
\remarks Implements the Controller pattern: ensures Low Coupling between the Frontend and
|
||||||
the Backend layers.
|
the Backend layers.
|
||||||
*/
|
*/
|
||||||
|
@ -132,12 +132,12 @@ namespace sgpem
|
||||||
/**
|
/**
|
||||||
\brief Setup the policy to be used by the system.
|
\brief Setup the policy to be used by the system.
|
||||||
*/
|
*/
|
||||||
virtual void set_policy(Policy*) = 0;
|
virtual void set_policy(CPUPolicy*) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\return The policy currently in use.
|
\return The policy currently in use.
|
||||||
*/
|
*/
|
||||||
virtual Policy* get_policy() = 0;
|
virtual CPUPolicy* get_policy() = 0;
|
||||||
|
|
||||||
virtual History& get_history() = 0;
|
virtual History& get_history() = 0;
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,6 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <glibmm/ustring.h>
|
#include <glibmm/ustring.h>
|
||||||
|
|
||||||
// FIXME : mark this file as deprecated.
|
|
||||||
#warning "This file is obsolete and deprecated."
|
|
||||||
#warning "It will be removed soon. Please update your code!"
|
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
typedef std::vector<Glib::ustring> Tokens;
|
typedef std::vector<Glib::ustring> Tokens;
|
||||||
|
|
|
@ -23,14 +23,14 @@
|
||||||
|
|
||||||
#include "backend/global_preferences.hh"
|
#include "backend/global_preferences.hh"
|
||||||
#include "backend/plugin_manager.hh"
|
#include "backend/plugin_manager.hh"
|
||||||
#include "backend/policy_manager.hh"
|
#include "backend/cpu_policy_manager.hh"
|
||||||
#include "backend/policies_gatekeeper.hh"
|
#include "backend/cpu_policies_gatekeeper.hh"
|
||||||
#include "backend/module.hh"
|
#include "backend/module.hh"
|
||||||
#include "text_simulation.hh"
|
#include "text_simulation.hh"
|
||||||
#include "io_manager.hh"
|
#include "io_manager.hh"
|
||||||
#include "gui_builder.hh"
|
#include "gui_builder.hh"
|
||||||
#include "parse_opts.hh"
|
#include "parse_opts.hh"
|
||||||
#
|
|
||||||
|
|
||||||
#include <glibmm/optioncontext.h>
|
#include <glibmm/optioncontext.h>
|
||||||
#include <gtkmm/main.h>
|
#include <gtkmm/main.h>
|
||||||
|
@ -119,9 +119,9 @@ parse_options(int argc, char** argv)
|
||||||
for(vector<Module*>::iterator it = modules.begin(); it != modules.end(); ++it)
|
for(vector<Module*>::iterator it = modules.begin(); it != modules.end(); ++it)
|
||||||
(*it)->set_enabled(true);
|
(*it)->set_enabled(true);
|
||||||
|
|
||||||
vector<PolicyManager*> managers = PoliciesGatekeeper::get_instance().get_registered();
|
vector<CPUPolicyManager*> managers = CPUPoliciesGatekeeper::get_instance().get_registered();
|
||||||
|
|
||||||
for(vector<PolicyManager*>::iterator it = managers.begin(); it != managers.end(); ++it)
|
for(vector<CPUPolicyManager*>::iterator it = managers.begin(); it != managers.end(); ++it)
|
||||||
(*it)->init();
|
(*it)->init();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#include "backend/string_utils.hh"
|
#include "backend/string_utils.hh"
|
||||||
#include "backend/policies_gatekeeper.hh"
|
#include "backend/cpu_policies_gatekeeper.hh"
|
||||||
#include "backend/policy_manager.hh"
|
#include "backend/cpu_policy_manager.hh"
|
||||||
#include "backend/policy_parameters.hh"
|
#include "backend/policy_parameters.hh"
|
||||||
#include "backend/history.hh"
|
#include "backend/history.hh"
|
||||||
#include "backend/static_process.hh"
|
#include "backend/static_process.hh"
|
||||||
|
@ -382,7 +382,7 @@ TextSimulation::on_configure_cpu_policy(const Tokens& arguments)
|
||||||
{
|
{
|
||||||
check_arguments_num(arguments, 0);
|
check_arguments_num(arguments, 0);
|
||||||
|
|
||||||
Policy* policy = Simulation::get_instance().get_policy();
|
CPUPolicy* policy = Simulation::get_instance().get_policy();
|
||||||
|
|
||||||
if(policy == NULL)
|
if(policy == NULL)
|
||||||
{
|
{
|
||||||
|
@ -620,17 +620,17 @@ TextSimulation::on_set(const Tokens& arguments)
|
||||||
if(policy < 0)
|
if(policy < 0)
|
||||||
throw domain_error("");
|
throw domain_error("");
|
||||||
|
|
||||||
typedef vector<PolicyManager*> ManagerVec;
|
typedef vector<CPUPolicyManager*> ManagerVec;
|
||||||
typedef vector<Policy*>::iterator PolicyIt;
|
typedef vector<CPUPolicy*>::iterator CPUPolicyIt;
|
||||||
|
|
||||||
PoliciesGatekeeper& gatekeeper = PoliciesGatekeeper::get_instance();
|
CPUPoliciesGatekeeper& gatekeeper = CPUPoliciesGatekeeper::get_instance();
|
||||||
|
|
||||||
ManagerVec managers = gatekeeper.get_registered();
|
ManagerVec managers = gatekeeper.get_registered();
|
||||||
|
|
||||||
for(ManagerVec::iterator it = managers.begin(); it != managers.end(); ++it)
|
for(ManagerVec::iterator it = managers.begin(); it != managers.end(); ++it)
|
||||||
{
|
{
|
||||||
vector<Policy*> policies = (*it)->get_avail_policies();
|
vector<CPUPolicy*> policies = (*it)->get_avail_policies();
|
||||||
for(PolicyIt it = policies.begin(); it != policies.end(); ++it)
|
for(CPUPolicyIt it = policies.begin(); it != policies.end(); ++it)
|
||||||
{
|
{
|
||||||
if(policy == 0)
|
if(policy == 0)
|
||||||
Simulation::get_instance().set_policy(*it);
|
Simulation::get_instance().set_policy(*it);
|
||||||
|
@ -828,20 +828,20 @@ TextSimulation::on_show_subrequests(const Tokens& arguments)
|
||||||
void
|
void
|
||||||
TextSimulation::on_show_cpu_policies(const Tokens& arguments)
|
TextSimulation::on_show_cpu_policies(const Tokens& arguments)
|
||||||
{
|
{
|
||||||
typedef vector<PolicyManager*> ManagerVec;
|
typedef vector<CPUPolicyManager*> ManagerVec;
|
||||||
typedef vector<Policy*>::iterator PolicyIt;
|
typedef vector<CPUPolicy*>::iterator CPUPolicyIt;
|
||||||
|
|
||||||
check_arguments_num(arguments, 0);
|
check_arguments_num(arguments, 0);
|
||||||
|
|
||||||
PoliciesGatekeeper& gatekeeper = PoliciesGatekeeper::get_instance();
|
CPUPoliciesGatekeeper& gatekeeper = CPUPoliciesGatekeeper::get_instance();
|
||||||
|
|
||||||
ManagerVec managers = gatekeeper.get_registered();
|
ManagerVec managers = gatekeeper.get_registered();
|
||||||
|
|
||||||
unsigned int index = 1;
|
unsigned int index = 1;
|
||||||
for(ManagerVec::iterator it = managers.begin(); it != managers.end(); ++it)
|
for(ManagerVec::iterator it = managers.begin(); it != managers.end(); ++it)
|
||||||
{
|
{
|
||||||
vector<Policy*> policies = (*it)->get_avail_policies();
|
vector<CPUPolicy*> policies = (*it)->get_avail_policies();
|
||||||
for(PolicyIt it = policies.begin(); it != policies.end(); ++it)
|
for(CPUPolicyIt it = policies.begin(); it != policies.end(); ++it)
|
||||||
{
|
{
|
||||||
ostringstream oss;
|
ostringstream oss;
|
||||||
oss << index << ". " << (*it)->get_name() << endl;
|
oss << index << ". " << (*it)->get_name() << endl;
|
||||||
|
|
Loading…
Reference in New Issue