- 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_history.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_request.cc \
|
||||
src/backend/dynamic_resource.cc \
|
||||
|
@ -167,9 +170,6 @@ src_backend_libbackend_la_SOURCES = \
|
|||
src/backend/module.cc \
|
||||
src/backend/null_policy_exception.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/process.cc \
|
||||
src/backend/ready_queue.cc \
|
||||
|
@ -195,6 +195,9 @@ src_backend_libbackend_la_SOURCES = \
|
|||
# For headers used internally by the backend, see below.
|
||||
pkginclude_HEADERS += \
|
||||
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/global_preferences.hh \
|
||||
src/backend/history.hh \
|
||||
|
@ -204,12 +207,9 @@ pkginclude_HEADERS += \
|
|||
src/backend/key_file.hh \
|
||||
src/backend/module.hh \
|
||||
src/backend/null_policy_exception.hh \
|
||||
src/backend/policy_parameters.hh \
|
||||
src/backend/plugin.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/request.hh \
|
||||
src/backend/resource.hh \
|
||||
|
|
|
@ -92,16 +92,16 @@ libpyloader_la_LDFLAGS = \
|
|||
# Please keep this in sorted order:
|
||||
libpyloader_la_SOURCES = \
|
||||
src/plugin.cc \
|
||||
src/python_policy.cc \
|
||||
src/python_policy_manager.cc
|
||||
src/cpu_python_policy.cc \
|
||||
src/cpu_python_policy_manager.cc
|
||||
|
||||
noinst_HEADERS += \
|
||||
src/python_policy.hh \
|
||||
src/python_policy_manager.hh
|
||||
src/cpu_python_policy.hh \
|
||||
src/cpu_python_policy_manager.hh
|
||||
|
||||
share_PYTHON = \
|
||||
src/Abstract.py \
|
||||
src/Policy.py \
|
||||
src/CPUPolicy.py \
|
||||
src/ScriptAdapter.py
|
||||
|
||||
# ############################################################
|
||||
|
@ -165,7 +165,7 @@ noinst_PROGRAMS = \
|
|||
|
||||
src_testsuite_test_pyloader_CPPFLAGS = \
|
||||
-I@top_srcdir@ \
|
||||
-DSHAREDIR="\"$(sharedir)\"" \
|
||||
-DSHAREDIR="\"$(sharedir)\"" \
|
||||
$(PYTHON_CPPFLAGS) \
|
||||
$(GLIBMM_CFLAGS) \
|
||||
$(GTHREAD_CFLAGS) \
|
||||
|
@ -181,8 +181,8 @@ src_testsuite_test_pyloader_LDFLAGS = \
|
|||
$(PYTHON_EXTRA_LDFLAGS)
|
||||
src_testsuite_test_pyloader_SOURCES = \
|
||||
src/testsuite/test-python_loader.cc \
|
||||
src/python_policy.cc \
|
||||
src/python_policy_manager.cc
|
||||
src/cpu_python_policy.cc \
|
||||
src/cpu_python_policy_manager.cc
|
||||
|
||||
noinst_PYTHON += src/testsuite/python_loader_configure.py \
|
||||
src/testsuite/python_loader_sort_queue.py \
|
||||
|
|
|
@ -7,7 +7,7 @@ import sgpem
|
|||
# This class also exposes the method sort(), which can be
|
||||
# used to easily sort the queue of ready process with a
|
||||
# user-defined given compare function.
|
||||
class Policy:
|
||||
class CPUPolicy:
|
||||
## @var Avoid instantiation of an abstract class.
|
||||
# @see Abstract.Metaclass
|
||||
__metaclass__ = Metaclass
|
|
@ -19,11 +19,11 @@
|
|||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
from Policy import Policy
|
||||
from CPUPolicy import CPUPolicy
|
||||
import sys
|
||||
#from sgpem import policy_sorts_processes
|
||||
|
||||
class fcfs(Policy) :
|
||||
class fcfs(CPUPolicy) :
|
||||
def __init__(self):
|
||||
pass;
|
||||
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
from Policy import Policy
|
||||
from CPUPolicy import CPUPolicy
|
||||
import sys
|
||||
|
||||
class rr_priority(Policy) :
|
||||
class rr_priority(CPUPolicy) :
|
||||
def __init__(self):
|
||||
pass;
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
from Policy import Policy
|
||||
from CPUPolicy import CPUPolicy
|
||||
import sys
|
||||
#from sgpem import policy_sorts_processes
|
||||
|
||||
class sjf(Policy) :
|
||||
class sjf(CPUPolicy) :
|
||||
def __init__(self):
|
||||
pass;
|
||||
|
||||
|
|
|
@ -18,10 +18,12 @@
|
|||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "python_policy.hh"
|
||||
#include "cpu_python_policy.hh"
|
||||
|
||||
#include <limits>
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
|
||||
using namespace sgpem;
|
||||
using namespace std;
|
||||
|
||||
|
@ -30,14 +32,14 @@ using namespace std;
|
|||
// WARNING : this class needs extensive and above all
|
||||
// *strong* exception checking / handling!
|
||||
|
||||
PythonPolicy::PythonPolicy(const char* name)
|
||||
PythonCPUPolicy::PythonCPUPolicy(const char* name)
|
||||
: _upolicy_dict(NULL), _adapter(NULL), _name(name)
|
||||
{
|
||||
PyObject* pLoadmeStr = PyString_FromString(name);
|
||||
PyObject* pUserPolicyModule = PyImport_Import(pLoadmeStr);
|
||||
PyObject* pUserCPUPolicyModule = PyImport_Import(pLoadmeStr);
|
||||
Py_DECREF(pLoadmeStr);
|
||||
|
||||
if( !pUserPolicyModule )
|
||||
if( !pUserCPUPolicyModule )
|
||||
{
|
||||
PyErr_Print(); // Error in import
|
||||
// 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
|
||||
_upolicy_dict = PyModule_GetDict(pUserPolicyModule);
|
||||
_upolicy_dict = PyModule_GetDict(pUserCPUPolicyModule);
|
||||
assert(_upolicy_dict);
|
||||
|
||||
// Loads ScriptAdapter module and get its dictionary
|
||||
|
@ -56,16 +58,16 @@ PythonPolicy::PythonPolicy(const char* name)
|
|||
PyObject* pAdapterDict = PyModule_GetDict(pScriptAdapterModule);
|
||||
assert(pAdapterDict);
|
||||
|
||||
// Now takes the user-defined policy class from pUserPolicyDict
|
||||
PyObject* pPolicyClass = PyDict_GetItemString(_upolicy_dict, name);
|
||||
assert(pPolicyClass); // FIXME needs stricter checking and exception throwing
|
||||
// Now takes the user-defined policy class from pUserCPUPolicyDict
|
||||
PyObject* pCPUPolicyClass = PyDict_GetItemString(_upolicy_dict, name);
|
||||
assert(pCPUPolicyClass); // FIXME needs stricter checking and exception throwing
|
||||
|
||||
// Creates a new object of type ScriptAdapter :
|
||||
// takes init function from ScriptAdapter class
|
||||
PyObject* pAdapterClass = PyDict_GetItemString(pAdapterDict, "ScriptAdapter");
|
||||
PyObject* pAdapterCtorParam = PyTuple_New(1);
|
||||
Py_INCREF(pPolicyClass); // PyTuple_SetItem steals a reference
|
||||
PyTuple_SetItem(pAdapterCtorParam, 0, pPolicyClass);
|
||||
Py_INCREF(pCPUPolicyClass); // PyTuple_SetItem steals a reference
|
||||
PyTuple_SetItem(pAdapterCtorParam, 0, pCPUPolicyClass);
|
||||
_adapter = PyInstance_New(pAdapterClass, pAdapterCtorParam, NULL);
|
||||
Py_DECREF(pAdapterCtorParam);
|
||||
assert(_adapter);
|
||||
|
@ -76,7 +78,7 @@ PythonPolicy::PythonPolicy(const char* name)
|
|||
}
|
||||
|
||||
|
||||
PythonPolicy::~PythonPolicy()
|
||||
PythonCPUPolicy::~PythonCPUPolicy()
|
||||
{
|
||||
if(_adapter) Py_DECREF(_adapter);
|
||||
|
||||
|
@ -88,7 +90,7 @@ PythonPolicy::~PythonPolicy()
|
|||
|
||||
|
||||
void
|
||||
PythonPolicy::configure() throw(UserInterruptException)
|
||||
PythonCPUPolicy::configure() throw(UserInterruptException)
|
||||
{
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, "async_configure", NULL);
|
||||
Py_DECREF(retval);
|
||||
|
@ -98,7 +100,7 @@ PythonPolicy::configure() throw(UserInterruptException)
|
|||
|
||||
|
||||
void
|
||||
PythonPolicy::sort_queue() const throw(UserInterruptException)
|
||||
PythonCPUPolicy::sort_queue() const throw(UserInterruptException)
|
||||
{
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, "async_sort_queue", NULL);
|
||||
|
||||
|
@ -111,20 +113,20 @@ PythonPolicy::sort_queue() const throw(UserInterruptException)
|
|||
|
||||
|
||||
Glib::ustring
|
||||
PythonPolicy::get_description() const
|
||||
PythonCPUPolicy::get_description() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
Glib::ustring
|
||||
PythonPolicy::get_name() const
|
||||
PythonCPUPolicy::get_name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
bool
|
||||
PythonPolicy::is_pre_emptive() const throw(UserInterruptException)
|
||||
PythonCPUPolicy::is_pre_emptive() const throw(UserInterruptException)
|
||||
{
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, "async_is_preemptive", NULL);
|
||||
Py_DECREF(retval);
|
||||
|
@ -141,7 +143,7 @@ PythonPolicy::is_pre_emptive() const throw(UserInterruptException)
|
|||
|
||||
|
||||
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);
|
||||
|
||||
|
@ -162,7 +164,7 @@ PythonPolicy::get_time_slice() const throw(UserInterruptException)
|
|||
|
||||
|
||||
void
|
||||
PythonPolicy::wait_unlock() const throw(UserInterruptException)
|
||||
PythonCPUPolicy::wait_unlock() const throw(UserInterruptException)
|
||||
{
|
||||
PyThreadState* _save;
|
||||
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
|
||||
// Mathematics
|
||||
//
|
||||
|
@ -18,8 +18,8 @@
|
|||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#ifndef PYTHON_POLICY_HH
|
||||
#define PYTHON_POLICY_HH 1
|
||||
#ifndef CPU_PYTHON_POLICY_HH
|
||||
#define CPU_PYTHON_POLICY_HH 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
@ -28,13 +28,13 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include "policy.hh"
|
||||
#include "cpu_policy.hh"
|
||||
#include "user_interrupt_exception.hh"
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class PythonPolicy;
|
||||
class PythonPolicyManager;
|
||||
class PythonCPUPolicy;
|
||||
class PythonCPUPolicyManager;
|
||||
class UserInterruptException;
|
||||
|
||||
/** \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.
|
||||
See the documentation of class Policy for more detailed informations.
|
||||
*/
|
||||
class SG_DLLEXPORT PythonPolicy : public Policy
|
||||
class SG_DLLEXPORT PythonCPUPolicy : public CPUPolicy
|
||||
{
|
||||
public:
|
||||
PythonPolicy(const char* name);
|
||||
virtual ~PythonPolicy();
|
||||
PythonCPUPolicy(const char* name);
|
||||
virtual ~PythonCPUPolicy();
|
||||
|
||||
/**
|
||||
Calls the method \c async_configure
|
||||
|
@ -87,8 +87,8 @@ namespace sgpem
|
|||
}
|
||||
|
||||
private:
|
||||
PythonPolicy(const PythonPolicy&);
|
||||
PythonPolicy& operator=(const PythonPolicy&);
|
||||
PythonCPUPolicy(const PythonCPUPolicy&);
|
||||
PythonCPUPolicy& operator=(const PythonCPUPolicy&);
|
||||
|
||||
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
|
||||
// Mathematics
|
||||
//
|
||||
|
@ -18,9 +18,9 @@
|
|||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// 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 "policies_gatekeeper.hh"
|
||||
#include "cpu_policies_gatekeeper.hh"
|
||||
|
||||
#include <Python.h>
|
||||
#include <glibmm/ustring.h>
|
||||
|
@ -35,6 +35,7 @@
|
|||
#include <string>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace sgpem;
|
||||
using std::vector;
|
||||
using std::cout;
|
||||
|
@ -57,21 +58,21 @@ private:
|
|||
};
|
||||
|
||||
|
||||
PythonPolicyManager::PythonPolicyManager()
|
||||
PythonCPUPolicyManager::PythonCPUPolicyManager()
|
||||
: _initialized(false)
|
||||
{
|
||||
PyEval_InitThreads();
|
||||
}
|
||||
|
||||
|
||||
PythonPolicyManager::~PythonPolicyManager()
|
||||
PythonCPUPolicyManager::~PythonCPUPolicyManager()
|
||||
{
|
||||
for_each(_policies.begin(), _policies.end(), ptr_fun(operator delete));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PythonPolicyManager::init()
|
||||
PythonCPUPolicyManager::init()
|
||||
{
|
||||
if(_initialized)
|
||||
// No-op
|
||||
|
@ -100,14 +101,14 @@ PythonPolicyManager::init()
|
|||
collect_policies();
|
||||
}
|
||||
|
||||
const vector<Policy*>&
|
||||
PythonPolicyManager::get_avail_policies()
|
||||
const vector<CPUPolicy*>&
|
||||
PythonCPUPolicyManager::get_avail_policies()
|
||||
{
|
||||
return _policies;
|
||||
}
|
||||
|
||||
void
|
||||
PythonPolicyManager::collect_policies()
|
||||
PythonCPUPolicyManager::collect_policies()
|
||||
{
|
||||
GlobalPreferences& prefs = GlobalPreferences::get_instance();
|
||||
GlobalPreferences::dir_iterator dir_it = prefs.policies_dir_begin();
|
||||
|
@ -132,7 +133,7 @@ PythonPolicyManager::collect_policies()
|
|||
//strip extension
|
||||
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);
|
||||
}
|
|
@ -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
|
||||
// Mathematics
|
||||
//
|
||||
|
@ -18,31 +18,31 @@
|
|||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#ifndef PYTHON_POLICY_MANAGER_HH
|
||||
#define PYTHON_POLICY_MANAGER_HH 1
|
||||
#ifndef CPU_PYTHON_POLICY_MANAGER_HH
|
||||
#define CPU_PYTHON_POLICY_MANAGER_HH 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include "policy_manager.hh"
|
||||
#include "python_policy.hh"
|
||||
#include "cpu_policy_manager.hh"
|
||||
#include "cpu_python_policy.hh"
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
//class PolicyManager;
|
||||
class PythonPolicyManager;
|
||||
//class CPUPolicyManager;
|
||||
class PythonCPUPolicyManager;
|
||||
|
||||
/** \brief Manages Python user-implemented policies
|
||||
*
|
||||
* This singleton manages the creation and destruction
|
||||
* of a Python policy.
|
||||
*/
|
||||
class SG_DLLEXPORT PythonPolicyManager : public PolicyManager
|
||||
class SG_DLLEXPORT PythonCPUPolicyManager : public CPUPolicyManager
|
||||
{
|
||||
public:
|
||||
PythonPolicyManager();
|
||||
~PythonPolicyManager();
|
||||
PythonCPUPolicyManager();
|
||||
~PythonCPUPolicyManager();
|
||||
|
||||
/** \brief Initialize the Python interpreter.
|
||||
*
|
||||
|
@ -51,15 +51,15 @@ namespace sgpem
|
|||
*/
|
||||
void init();
|
||||
|
||||
const std::vector<Policy*>& get_avail_policies();
|
||||
const std::vector<CPUPolicy*>& get_avail_policies();
|
||||
|
||||
protected:
|
||||
/** The selected and active PyhonPolicy object. */
|
||||
/** The selected and active PyhonCPUPolicy object. */
|
||||
void collect_policies();
|
||||
|
||||
private:
|
||||
PythonPolicyManager(const PythonPolicyManager&);
|
||||
PythonPolicyManager& operator=(const PythonPolicyManager&);
|
||||
PythonCPUPolicyManager(const PythonCPUPolicyManager&);
|
||||
PythonCPUPolicyManager& operator=(const PythonCPUPolicyManager&);
|
||||
|
||||
bool _initialized;
|
||||
};
|
|
@ -21,18 +21,18 @@
|
|||
#include "config.h"
|
||||
|
||||
#include "plugin.hh"
|
||||
#include "python_policy_manager.hh"
|
||||
#include "cpu_python_policy_manager.hh"
|
||||
|
||||
using namespace sgpem;
|
||||
|
||||
// Is this OK? If not, we must use a function with a local static variable...
|
||||
PythonPolicyManager* _policy_manager = NULL;
|
||||
PythonCPUPolicyManager* _policy_manager = NULL;
|
||||
|
||||
void
|
||||
sgpem__Plugin__on_init()
|
||||
{
|
||||
if(_policy_manager == NULL)
|
||||
_policy_manager = new sgpem::PythonPolicyManager();
|
||||
_policy_manager = new sgpem::PythonCPUPolicyManager();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
%module sgpem
|
||||
%{
|
||||
#include "policy.hh"
|
||||
#include "cpu_policy.hh"
|
||||
#include "policy_parameters.hh"
|
||||
#include "process.hh"
|
||||
#include "ready_queue.hh"
|
||||
|
@ -59,9 +59,9 @@ namespace std
|
|||
|
||||
namespace sgpem {
|
||||
|
||||
class Policy {
|
||||
class CPUPolicy {
|
||||
public:
|
||||
virtual ~Policy() = 0;
|
||||
virtual ~CPUPolicy() = 0;
|
||||
sgpem::PolicyParameters& get_parameters();
|
||||
};
|
||||
|
||||
|
@ -218,7 +218,7 @@ namespace sgpem {
|
|||
// ---------------------------------------------
|
||||
class Scheduler {
|
||||
public:
|
||||
sgpem::Policy* get_policy();
|
||||
sgpem::CPUPolicy* get_policy();
|
||||
static sgpem::Scheduler& get_instance();
|
||||
sgpem::ReadyQueue* get_ready_queue();
|
||||
private:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from Policy import Policy
|
||||
from CPUPolicy import CPUPolicy
|
||||
import sys
|
||||
|
||||
class python_loader_configure(Policy) :
|
||||
class python_loader_configure(CPUPolicy) :
|
||||
def __init__(self):
|
||||
pass;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from Policy import Policy
|
||||
from CPUPolicy import CPUPolicy
|
||||
import sys
|
||||
|
||||
class python_loader_get_time_slice(Policy) :
|
||||
class python_loader_get_time_slice(CPUPolicy) :
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from Policy import Policy
|
||||
from CPUPolicy import CPUPolicy
|
||||
import sys
|
||||
|
||||
class python_loader_is_preemptive(Policy) :
|
||||
class python_loader_is_preemptive(CPUPolicy) :
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from Policy import Policy
|
||||
from CPUPolicy import CPUPolicy
|
||||
import sys
|
||||
|
||||
class python_loader_sort_queue(Policy) :
|
||||
class python_loader_sort_queue(CPUPolicy) :
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
* class and its closely related cousins. More documentation to be written
|
||||
* here, thanks very much. */
|
||||
|
||||
#include "../python_policy_manager.hh"
|
||||
#include "../python_policy.hh"
|
||||
#include "../cpu_python_policy_manager.hh"
|
||||
#include "../cpu_python_policy.hh"
|
||||
|
||||
#include "simulation.hh"
|
||||
#include "global_preferences.hh"
|
||||
#include "policies_gatekeeper.hh"
|
||||
#include "cpu_policies_gatekeeper.hh"
|
||||
#include "simulation.hh"
|
||||
#include "scheduler.hh"
|
||||
#include "user_interrupt_exception.hh"
|
||||
|
@ -42,10 +42,10 @@
|
|||
using namespace sgpem;
|
||||
using namespace std;
|
||||
|
||||
static Policy*
|
||||
find_pol_by_name(const vector<Policy*>& pols, const Glib::ustring& name)
|
||||
static CPUPolicy*
|
||||
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++)
|
||||
if((*it)->get_name() == name)
|
||||
return *it;
|
||||
|
@ -69,24 +69,24 @@ main(int argc, char** argv)
|
|||
sgpem::GlobalPreferences::get_instance().add_policies_dir(argv[1]);
|
||||
|
||||
// Self-register itself to PoliciesGatekeeper, however we don't care about it
|
||||
PythonPolicyManager polman;
|
||||
PythonCPUPolicyManager polman;
|
||||
polman.init();
|
||||
|
||||
Simulation& sim = Simulation::get_instance();
|
||||
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
|
||||
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++)
|
||||
cout << "\t * " << (*it)->get_name() << endl;
|
||||
|
||||
try
|
||||
{
|
||||
Policy* pol = find_pol_by_name(policies, "python_loader_configure");
|
||||
CPUPolicy* pol = find_pol_by_name(policies, "python_loader_configure");
|
||||
assert(pol != NULL);
|
||||
|
||||
// FIXME : Maybe activating a policy only to configure it is an overkill?
|
||||
|
@ -103,7 +103,7 @@ main(int argc, char** argv)
|
|||
|
||||
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);
|
||||
pgk.activate_policy(&his, pol);
|
||||
pol->is_pre_emptive();
|
||||
|
@ -117,7 +117,7 @@ main(int argc, char** argv)
|
|||
|
||||
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);
|
||||
pgk.activate_policy(&his, pol);
|
||||
pol->get_time_slice();
|
||||
|
@ -132,7 +132,7 @@ main(int argc, char** argv)
|
|||
|
||||
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);
|
||||
pgk.activate_policy(&his, pol);
|
||||
pol->sort_queue();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "concrete_simulation.hh"
|
||||
#include "scheduler.hh"
|
||||
#include "policies_gatekeeper.hh"
|
||||
#include "cpu_policies_gatekeeper.hh"
|
||||
#include <glibmm/timer.h>
|
||||
|
||||
#include <cassert>
|
||||
|
@ -155,16 +155,16 @@ ConcreteSimulation::get_history()
|
|||
}
|
||||
|
||||
void
|
||||
ConcreteSimulation::set_policy(Policy* p)
|
||||
ConcreteSimulation::set_policy(CPUPolicy* p)
|
||||
{
|
||||
_policy = p;
|
||||
|
||||
if(p != NULL)
|
||||
PoliciesGatekeeper::get_instance().activate_policy(&_history, p);
|
||||
CPUPoliciesGatekeeper::get_instance().activate_policy(&_history, p);
|
||||
}
|
||||
|
||||
|
||||
Policy*
|
||||
CPUPolicy*
|
||||
ConcreteSimulation::get_policy()
|
||||
{
|
||||
return _policy;
|
||||
|
|
|
@ -49,18 +49,18 @@ namespace sgpem
|
|||
|
||||
state get_state() const;
|
||||
|
||||
void set_policy(Policy*);
|
||||
void set_policy(CPUPolicy*);
|
||||
|
||||
ConcreteHistory& get_history();
|
||||
|
||||
Policy* get_policy();
|
||||
CPUPolicy* get_policy();
|
||||
|
||||
private:
|
||||
state _state;
|
||||
bool _mode;
|
||||
int _timer_interval;
|
||||
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
|
||||
// Mathematics
|
||||
//
|
||||
|
@ -20,9 +20,9 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include "policies_gatekeeper.hh"
|
||||
#include "policy_manager.hh"
|
||||
#include "policy.hh"
|
||||
#include "cpu_policies_gatekeeper.hh"
|
||||
#include "cpu_policy_manager.hh"
|
||||
#include "cpu_policy.hh"
|
||||
|
||||
// Include full template definition only in implementation files:
|
||||
#include "singleton.tcc"
|
||||
|
@ -37,19 +37,19 @@ using std::runtime_error;
|
|||
using namespace sgpem;
|
||||
|
||||
// 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 map<History*, Policy*>::iterator ActiveIterator;
|
||||
typedef vector<CPUPolicyManager*>::iterator ManagerIterator;
|
||||
typedef map<History*, CPUPolicy*>::iterator ActiveIterator;
|
||||
|
||||
vector<PolicyManager*>
|
||||
PoliciesGatekeeper::get_registered() const
|
||||
vector<CPUPolicyManager*>
|
||||
CPUPoliciesGatekeeper::get_registered() const
|
||||
{
|
||||
return _registered;
|
||||
}
|
||||
|
||||
void
|
||||
PoliciesGatekeeper::register_manager(PolicyManager* manager)
|
||||
CPUPoliciesGatekeeper::register_manager(CPUPolicyManager* manager)
|
||||
{
|
||||
assert(manager != NULL);
|
||||
|
||||
|
@ -60,7 +60,7 @@ PoliciesGatekeeper::register_manager(PolicyManager* manager)
|
|||
}
|
||||
|
||||
void
|
||||
PoliciesGatekeeper::unregister_manager(PolicyManager* manager)
|
||||
CPUPoliciesGatekeeper::unregister_manager(CPUPolicyManager* manager)
|
||||
{
|
||||
assert(manager != NULL);
|
||||
|
||||
|
@ -74,8 +74,8 @@ PoliciesGatekeeper::unregister_manager(PolicyManager* manager)
|
|||
}
|
||||
}
|
||||
|
||||
Policy*
|
||||
PoliciesGatekeeper::get_current_policy(History* history) throw(runtime_error)
|
||||
CPUPolicy*
|
||||
CPUPoliciesGatekeeper::get_current_policy(History* history) throw(runtime_error)
|
||||
{
|
||||
assert(history != NULL);
|
||||
|
||||
|
@ -89,7 +89,7 @@ PoliciesGatekeeper::get_current_policy(History* history) throw(runtime_error)
|
|||
}
|
||||
|
||||
void
|
||||
PoliciesGatekeeper::activate_policy(History *history, Policy* policy)
|
||||
CPUPoliciesGatekeeper::activate_policy(History *history, CPUPolicy* policy)
|
||||
{
|
||||
assert(history != NULL && policy != NULL);
|
||||
|
||||
|
@ -106,18 +106,18 @@ PoliciesGatekeeper::activate_policy(History *history, Policy* policy)
|
|||
}
|
||||
}
|
||||
|
||||
PoliciesGatekeeper::PoliciesGatekeeper()
|
||||
CPUPoliciesGatekeeper::CPUPoliciesGatekeeper()
|
||||
{}
|
||||
|
||||
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();
|
||||
PolicyIterator avail_end = avail_policies.end();
|
||||
CPUPolicyIterator avail_it = avail_policies.begin();
|
||||
CPUPolicyIterator avail_end = avail_policies.end();
|
||||
|
||||
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
|
||||
// Mathematics
|
||||
//
|
||||
|
@ -18,13 +18,13 @@
|
|||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#ifndef POLICIES_GATEKEEPER_HH
|
||||
#define POLICIES_GATEKEEPER_HH 1
|
||||
#ifndef CPU_POLICIES_GATEKEEPER_HH
|
||||
#define CPU_POLICIES_GATEKEEPER_HH 1
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class PolicyManager;
|
||||
class Policy;
|
||||
class CPUPolicyManager;
|
||||
class CPUPolicy;
|
||||
class History;
|
||||
}
|
||||
|
||||
|
@ -38,41 +38,41 @@ namespace sgpem
|
|||
|
||||
namespace sgpem
|
||||
{
|
||||
class PoliciesGatekeeper;
|
||||
class CPUPoliciesGatekeeper;
|
||||
|
||||
/** \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:
|
||||
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:
|
||||
PoliciesGatekeeper(); //private constructor.
|
||||
PoliciesGatekeeper(const PoliciesGatekeeper&);
|
||||
PoliciesGatekeeper& operator=(const PoliciesGatekeeper&);
|
||||
CPUPoliciesGatekeeper(); //private constructor.
|
||||
CPUPoliciesGatekeeper(const CPUPoliciesGatekeeper&);
|
||||
CPUPoliciesGatekeeper& operator=(const CPUPoliciesGatekeeper&);
|
||||
|
||||
// Deactivates active policies managed by the specified manager.
|
||||
void deactivate_policies(PolicyManager* manager);
|
||||
void deactivate_policies(CPUPolicyManager* manager);
|
||||
|
||||
std::vector<PolicyManager*> _registered;
|
||||
std::map<History*, Policy*> _active_policies;
|
||||
std::vector<CPUPolicyManager*> _registered;
|
||||
std::map<History*, CPUPolicy*> _active_policies;
|
||||
};
|
||||
|
||||
}//~ 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
|
||||
// Mathematics
|
||||
//
|
||||
|
@ -18,16 +18,16 @@
|
|||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "policy.hh"
|
||||
#include "cpu_policy.hh"
|
||||
using namespace std;
|
||||
using namespace sgpem;
|
||||
|
||||
Policy::~Policy()
|
||||
CPUPolicy::~CPUPolicy()
|
||||
{}
|
||||
|
||||
|
||||
PolicyParameters&
|
||||
Policy::get_parameters()
|
||||
CPUPolicy::get_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
|
||||
// Mathematics
|
||||
//
|
||||
|
@ -18,8 +18,8 @@
|
|||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#ifndef POLICY_HH
|
||||
#define POLICY_HH 1
|
||||
#ifndef CPU_POLICY_HH
|
||||
#define CPU_POLICY_HH 1
|
||||
|
||||
#include "config.h"
|
||||
#include "gettext.h"
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
namespace sgpem
|
||||
{
|
||||
class Policy;
|
||||
class CPUPolicy;
|
||||
|
||||
/** \brief
|
||||
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
|
||||
mantained in a ReadyQueue.
|
||||
*/
|
||||
class SG_DLLEXPORT Policy
|
||||
class SG_DLLEXPORT CPUPolicy
|
||||
{
|
||||
public:
|
||||
virtual ~Policy();
|
||||
virtual ~CPUPolicy();
|
||||
|
||||
/**
|
||||
Initialize the inner components of the policy.
|
||||
|
@ -107,5 +107,4 @@ namespace sgpem
|
|||
|
||||
}//~ namespace sgpem
|
||||
|
||||
|
||||
#endif
|
||||
#endif //~ CPU_POLICY_HH
|
|
@ -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
|
||||
// Mathematics
|
||||
//
|
||||
|
@ -19,32 +19,32 @@
|
|||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
#include "policy_manager.hh"
|
||||
#include "policies_gatekeeper.hh"
|
||||
#include "cpu_policy_manager.hh"
|
||||
#include "cpu_policies_gatekeeper.hh"
|
||||
|
||||
PolicyManager*
|
||||
PolicyManager::_registered = NULL;
|
||||
CPUPolicyManager*
|
||||
CPUPolicyManager::_registered = NULL;
|
||||
|
||||
PolicyManager::PolicyManager()
|
||||
CPUPolicyManager::CPUPolicyManager()
|
||||
{
|
||||
//FIXME remove this when get_registered_manager is dropped
|
||||
_registered = this;
|
||||
|
||||
PoliciesGatekeeper::get_instance().register_manager(this);
|
||||
CPUPoliciesGatekeeper::get_instance().register_manager(this);
|
||||
}
|
||||
|
||||
|
||||
PolicyManager::~PolicyManager()
|
||||
CPUPolicyManager::~CPUPolicyManager()
|
||||
{
|
||||
// This check is necessary:
|
||||
//FIXME remove this when get_registered_manager is dropped
|
||||
if(_registered == this) _registered = NULL;
|
||||
|
||||
PoliciesGatekeeper::get_instance().unregister_manager(this);
|
||||
CPUPoliciesGatekeeper::get_instance().unregister_manager(this);
|
||||
}
|
||||
|
||||
PolicyManager&
|
||||
PolicyManager::get_registered_manager()
|
||||
CPUPolicyManager&
|
||||
CPUPolicyManager::get_registered_manager()
|
||||
{
|
||||
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
|
||||
// Mathematics
|
||||
//
|
||||
|
@ -18,38 +18,38 @@
|
|||
// along with SGPEMv2; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#ifndef POLICY_MANAGER_HH
|
||||
#define POLICY_MANAGER_HH 1
|
||||
#ifndef CPU_POLICY_MANAGER_HH
|
||||
#define CPU_POLICY_MANAGER_HH 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "policy.hh"
|
||||
#include "cpu_policy.hh"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
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:
|
||||
/** \brief PolicyManager constructor
|
||||
/** \brief CPUPolicyManager constructor
|
||||
*
|
||||
* Saves ``this'' pointer into the _registered attribute, so it can access
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
PolicyManager();
|
||||
CPUPolicyManager();
|
||||
|
||||
virtual ~PolicyManager() = 0;
|
||||
virtual ~CPUPolicyManager() = 0;
|
||||
|
||||
/**
|
||||
Gets THE policy (the only today) used.
|
||||
|
@ -57,7 +57,7 @@ namespace sgpem
|
|||
\return A reference to the policy.
|
||||
FIXME deprecated
|
||||
*/
|
||||
//virtual Policy& get_policy() = 0;
|
||||
//virtual CPUPolicy& get_policy() = 0;
|
||||
|
||||
/**
|
||||
Init (or reset if yet initialized) the manager.
|
||||
|
@ -65,23 +65,23 @@ namespace sgpem
|
|||
*/
|
||||
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
|
||||
* FIXME deprecated
|
||||
*
|
||||
* \return The registered policy manager instance.
|
||||
*/
|
||||
static PolicyManager& get_registered_manager();
|
||||
static CPUPolicyManager& get_registered_manager();
|
||||
|
||||
protected:
|
||||
virtual void collect_policies() = 0;
|
||||
|
||||
std::vector<Policy*> _policies;
|
||||
std::vector<CPUPolicy*> _policies;
|
||||
|
||||
private:
|
||||
/** A pointer to the registered instance */
|
||||
static PolicyManager* _registered;
|
||||
static CPUPolicyManager* _registered;
|
||||
};
|
||||
|
||||
} //~ namespace sgpem
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "concrete_environment.hh"
|
||||
#include "concrete_history.hh"
|
||||
#include "policy.hh"
|
||||
#include "cpu_policy.hh"
|
||||
#include "scheduler.hh"
|
||||
#include "user_interrupt_exception.hh"
|
||||
|
||||
|
@ -154,7 +154,7 @@ Scheduler::reset_status()
|
|||
}
|
||||
|
||||
|
||||
Policy*
|
||||
CPUPolicy*
|
||||
Scheduler::get_policy()
|
||||
{
|
||||
return _policy;
|
||||
|
@ -162,7 +162,7 @@ Scheduler::get_policy()
|
|||
|
||||
|
||||
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
|
||||
// store a readyqueue and policy pointer for the user-policy to retrieve, to when
|
||||
|
|
|
@ -23,14 +23,13 @@
|
|||
namespace sgpem
|
||||
{
|
||||
class Scheduler;
|
||||
class PolicyManager;
|
||||
class Policy;
|
||||
class CPUPolicy;
|
||||
}
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "history.hh"
|
||||
#include "policy.hh"
|
||||
#include "cpu_policy.hh"
|
||||
#include "ready_queue.hh"
|
||||
#include "user_interrupt_exception.hh"
|
||||
|
||||
|
@ -77,19 +76,19 @@ namespace sgpem
|
|||
|
||||
\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.
|
||||
\return the policy that will be used to generate the simulation at the next instant.
|
||||
*/
|
||||
Policy* get_policy();
|
||||
CPUPolicy* get_policy();
|
||||
|
||||
private:
|
||||
Scheduler(); //private constructor.
|
||||
|
||||
ReadyQueue* _ready_queue;
|
||||
Policy* _policy;
|
||||
CPUPolicy* _policy;
|
||||
|
||||
Glib::Mutex _step_mutex;
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
namespace sgpem
|
||||
{
|
||||
class ConcreteSimulation;
|
||||
class Policy;
|
||||
class CPUPolicy;
|
||||
class History;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ namespace sgpem
|
|||
check which schedulng algorithm is currently in use.
|
||||
|
||||
\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
|
||||
the Backend layers.
|
||||
*/
|
||||
|
@ -132,12 +132,12 @@ namespace sgpem
|
|||
/**
|
||||
\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.
|
||||
*/
|
||||
virtual Policy* get_policy() = 0;
|
||||
virtual CPUPolicy* get_policy() = 0;
|
||||
|
||||
virtual History& get_history() = 0;
|
||||
|
||||
|
|
|
@ -28,10 +28,6 @@
|
|||
#include <stdexcept>
|
||||
#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
|
||||
{
|
||||
typedef std::vector<Glib::ustring> Tokens;
|
||||
|
|
|
@ -23,14 +23,14 @@
|
|||
|
||||
#include "backend/global_preferences.hh"
|
||||
#include "backend/plugin_manager.hh"
|
||||
#include "backend/policy_manager.hh"
|
||||
#include "backend/policies_gatekeeper.hh"
|
||||
#include "backend/cpu_policy_manager.hh"
|
||||
#include "backend/cpu_policies_gatekeeper.hh"
|
||||
#include "backend/module.hh"
|
||||
#include "text_simulation.hh"
|
||||
#include "io_manager.hh"
|
||||
#include "gui_builder.hh"
|
||||
#include "parse_opts.hh"
|
||||
#
|
||||
|
||||
|
||||
#include <glibmm/optioncontext.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)
|
||||
(*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();
|
||||
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "backend/string_utils.hh"
|
||||
#include "backend/policies_gatekeeper.hh"
|
||||
#include "backend/policy_manager.hh"
|
||||
#include "backend/cpu_policies_gatekeeper.hh"
|
||||
#include "backend/cpu_policy_manager.hh"
|
||||
#include "backend/policy_parameters.hh"
|
||||
#include "backend/history.hh"
|
||||
#include "backend/static_process.hh"
|
||||
|
@ -382,7 +382,7 @@ TextSimulation::on_configure_cpu_policy(const Tokens& arguments)
|
|||
{
|
||||
check_arguments_num(arguments, 0);
|
||||
|
||||
Policy* policy = Simulation::get_instance().get_policy();
|
||||
CPUPolicy* policy = Simulation::get_instance().get_policy();
|
||||
|
||||
if(policy == NULL)
|
||||
{
|
||||
|
@ -620,17 +620,17 @@ TextSimulation::on_set(const Tokens& arguments)
|
|||
if(policy < 0)
|
||||
throw domain_error("");
|
||||
|
||||
typedef vector<PolicyManager*> ManagerVec;
|
||||
typedef vector<Policy*>::iterator PolicyIt;
|
||||
typedef vector<CPUPolicyManager*> ManagerVec;
|
||||
typedef vector<CPUPolicy*>::iterator CPUPolicyIt;
|
||||
|
||||
PoliciesGatekeeper& gatekeeper = PoliciesGatekeeper::get_instance();
|
||||
CPUPoliciesGatekeeper& gatekeeper = CPUPoliciesGatekeeper::get_instance();
|
||||
|
||||
ManagerVec managers = gatekeeper.get_registered();
|
||||
|
||||
for(ManagerVec::iterator it = managers.begin(); it != managers.end(); ++it)
|
||||
{
|
||||
vector<Policy*> policies = (*it)->get_avail_policies();
|
||||
for(PolicyIt it = policies.begin(); it != policies.end(); ++it)
|
||||
vector<CPUPolicy*> policies = (*it)->get_avail_policies();
|
||||
for(CPUPolicyIt it = policies.begin(); it != policies.end(); ++it)
|
||||
{
|
||||
if(policy == 0)
|
||||
Simulation::get_instance().set_policy(*it);
|
||||
|
@ -828,20 +828,20 @@ TextSimulation::on_show_subrequests(const Tokens& arguments)
|
|||
void
|
||||
TextSimulation::on_show_cpu_policies(const Tokens& arguments)
|
||||
{
|
||||
typedef vector<PolicyManager*> ManagerVec;
|
||||
typedef vector<Policy*>::iterator PolicyIt;
|
||||
typedef vector<CPUPolicyManager*> ManagerVec;
|
||||
typedef vector<CPUPolicy*>::iterator CPUPolicyIt;
|
||||
|
||||
check_arguments_num(arguments, 0);
|
||||
|
||||
PoliciesGatekeeper& gatekeeper = PoliciesGatekeeper::get_instance();
|
||||
CPUPoliciesGatekeeper& gatekeeper = CPUPoliciesGatekeeper::get_instance();
|
||||
|
||||
ManagerVec managers = gatekeeper.get_registered();
|
||||
|
||||
unsigned int index = 1;
|
||||
for(ManagerVec::iterator it = managers.begin(); it != managers.end(); ++it)
|
||||
{
|
||||
vector<Policy*> policies = (*it)->get_avail_policies();
|
||||
for(PolicyIt it = policies.begin(); it != policies.end(); ++it)
|
||||
vector<CPUPolicy*> policies = (*it)->get_avail_policies();
|
||||
for(CPUPolicyIt it = policies.begin(); it != policies.end(); ++it)
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << index << ". " << (*it)->get_name() << endl;
|
||||
|
|
Loading…
Reference in New Issue