diff --git a/Makefile.am b/Makefile.am index 9d3bf3b..60a1398 100644 --- a/Makefile.am +++ b/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 \ diff --git a/plugins/pyloader/Makefile.am b/plugins/pyloader/Makefile.am index 7f79f88..5a596a8 100644 --- a/plugins/pyloader/Makefile.am +++ b/plugins/pyloader/Makefile.am @@ -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 \ diff --git a/plugins/pyloader/src/Policy.py b/plugins/pyloader/src/CPUPolicy.py similarity index 99% rename from plugins/pyloader/src/Policy.py rename to plugins/pyloader/src/CPUPolicy.py index a9c5483..b075510 100644 --- a/plugins/pyloader/src/Policy.py +++ b/plugins/pyloader/src/CPUPolicy.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 diff --git a/plugins/pyloader/src/builtin-policies/fcfs.py b/plugins/pyloader/src/builtin-policies/fcfs.py index 80d8561..63c5ab6 100644 --- a/plugins/pyloader/src/builtin-policies/fcfs.py +++ b/plugins/pyloader/src/builtin-policies/fcfs.py @@ -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; diff --git a/plugins/pyloader/src/builtin-policies/rr_priority.py b/plugins/pyloader/src/builtin-policies/rr_priority.py index 041c629..b905bb2 100644 --- a/plugins/pyloader/src/builtin-policies/rr_priority.py +++ b/plugins/pyloader/src/builtin-policies/rr_priority.py @@ -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; diff --git a/plugins/pyloader/src/builtin-policies/sjf.py b/plugins/pyloader/src/builtin-policies/sjf.py index 0b460d5..b7e40e4 100644 --- a/plugins/pyloader/src/builtin-policies/sjf.py +++ b/plugins/pyloader/src/builtin-policies/sjf.py @@ -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; diff --git a/plugins/pyloader/src/python_policy.cc b/plugins/pyloader/src/cpu_python_policy.cc similarity index 82% rename from plugins/pyloader/src/python_policy.cc rename to plugins/pyloader/src/cpu_python_policy.cc index b1eebb6..a4426bd 100644 --- a/plugins/pyloader/src/python_policy.cc +++ b/plugins/pyloader/src/cpu_python_policy.cc @@ -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 #include #include + 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... diff --git a/plugins/pyloader/src/python_policy.hh b/plugins/pyloader/src/cpu_python_policy.hh similarity index 83% rename from plugins/pyloader/src/python_policy.hh rename to plugins/pyloader/src/cpu_python_policy.hh index e0f53f0..66d8801 100644 --- a/plugins/pyloader/src/python_policy.hh +++ b/plugins/pyloader/src/cpu_python_policy.hh @@ -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 -#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); diff --git a/plugins/pyloader/src/python_policy_manager.cc b/plugins/pyloader/src/cpu_python_policy_manager.cc similarity index 87% rename from plugins/pyloader/src/python_policy_manager.cc rename to plugins/pyloader/src/cpu_python_policy_manager.cc index 4b3488e..eb3ca82 100644 --- a/plugins/pyloader/src/python_policy_manager.cc +++ b/plugins/pyloader/src/cpu_python_policy_manager.cc @@ -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 #include @@ -35,6 +35,7 @@ #include #include #include + 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& -PythonPolicyManager::get_avail_policies() +const vector& +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); } diff --git a/plugins/pyloader/src/python_policy_manager.hh b/plugins/pyloader/src/cpu_python_policy_manager.hh similarity index 67% rename from plugins/pyloader/src/python_policy_manager.hh rename to plugins/pyloader/src/cpu_python_policy_manager.hh index 6f9db99..59aea2d 100644 --- a/plugins/pyloader/src/python_policy_manager.hh +++ b/plugins/pyloader/src/cpu_python_policy_manager.hh @@ -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 -#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& get_avail_policies(); + const std::vector& 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; }; diff --git a/plugins/pyloader/src/plugin.cc b/plugins/pyloader/src/plugin.cc index 0b13fa9..e1e20fd 100644 --- a/plugins/pyloader/src/plugin.cc +++ b/plugins/pyloader/src/plugin.cc @@ -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 diff --git a/plugins/pyloader/src/sgpem.i b/plugins/pyloader/src/sgpem.i index 8a3b3e7..21312f7 100644 --- a/plugins/pyloader/src/sgpem.i +++ b/plugins/pyloader/src/sgpem.i @@ -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: diff --git a/plugins/pyloader/src/testsuite/python_loader_configure.py b/plugins/pyloader/src/testsuite/python_loader_configure.py index e38a281..68cf333 100644 --- a/plugins/pyloader/src/testsuite/python_loader_configure.py +++ b/plugins/pyloader/src/testsuite/python_loader_configure.py @@ -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; diff --git a/plugins/pyloader/src/testsuite/python_loader_get_time_slice.py b/plugins/pyloader/src/testsuite/python_loader_get_time_slice.py index 5ba6ca1..3ac306a 100644 --- a/plugins/pyloader/src/testsuite/python_loader_get_time_slice.py +++ b/plugins/pyloader/src/testsuite/python_loader_get_time_slice.py @@ -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 diff --git a/plugins/pyloader/src/testsuite/python_loader_is_preemptive.py b/plugins/pyloader/src/testsuite/python_loader_is_preemptive.py index 995abd9..6452d44 100644 --- a/plugins/pyloader/src/testsuite/python_loader_is_preemptive.py +++ b/plugins/pyloader/src/testsuite/python_loader_is_preemptive.py @@ -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 diff --git a/plugins/pyloader/src/testsuite/python_loader_sort_queue.py b/plugins/pyloader/src/testsuite/python_loader_sort_queue.py index f91180f..301a97a 100644 --- a/plugins/pyloader/src/testsuite/python_loader_sort_queue.py +++ b/plugins/pyloader/src/testsuite/python_loader_sort_queue.py @@ -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 diff --git a/plugins/pyloader/src/testsuite/test-python_loader.cc b/plugins/pyloader/src/testsuite/test-python_loader.cc index 977e9fd..b1e0a1a 100644 --- a/plugins/pyloader/src/testsuite/test-python_loader.cc +++ b/plugins/pyloader/src/testsuite/test-python_loader.cc @@ -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& pols, const Glib::ustring& name) +static CPUPolicy* +find_pol_by_name(const vector& pols, const Glib::ustring& name) { - vector::const_iterator it = pols.begin(); + vector::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& policies = polman.get_avail_policies(); + const std::vector& policies = polman.get_avail_policies(); // Print out avail policies cout << "These are the policies I found:" << endl; - vector::const_iterator it = policies.begin(); + vector::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(); diff --git a/src/backend/concrete_simulation.cc b/src/backend/concrete_simulation.cc index ad9c15f..4a8c71b 100644 --- a/src/backend/concrete_simulation.cc +++ b/src/backend/concrete_simulation.cc @@ -20,7 +20,7 @@ #include "concrete_simulation.hh" #include "scheduler.hh" -#include "policies_gatekeeper.hh" +#include "cpu_policies_gatekeeper.hh" #include #include @@ -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; diff --git a/src/backend/concrete_simulation.hh b/src/backend/concrete_simulation.hh index 42af261..b07217e 100644 --- a/src/backend/concrete_simulation.hh +++ b/src/backend/concrete_simulation.hh @@ -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; }; } diff --git a/src/backend/policies_gatekeeper.cc b/src/backend/cpu_policies_gatekeeper.cc similarity index 71% rename from src/backend/policies_gatekeeper.cc rename to src/backend/cpu_policies_gatekeeper.cc index 87ea037..1022522 100644 --- a/src/backend/policies_gatekeeper.cc +++ b/src/backend/cpu_policies_gatekeeper.cc @@ -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; +template class SG_DLLEXPORT Singleton; -typedef vector::iterator ManagerIterator; -typedef map::iterator ActiveIterator; +typedef vector::iterator ManagerIterator; +typedef map::iterator ActiveIterator; -vector -PoliciesGatekeeper::get_registered() const +vector +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::iterator PolicyIterator; + typedef vector::iterator CPUPolicyIterator; - vector avail_policies = manager->get_avail_policies(); + vector 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) { diff --git a/src/backend/policies_gatekeeper.hh b/src/backend/cpu_policies_gatekeeper.hh similarity index 51% rename from src/backend/policies_gatekeeper.hh rename to src/backend/cpu_policies_gatekeeper.hh index 86306c6..eb0e1ac 100644 --- a/src/backend/policies_gatekeeper.hh +++ b/src/backend/cpu_policies_gatekeeper.hh @@ -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 + class SG_DLLEXPORT CPUPoliciesGatekeeper : public Singleton { - friend class Singleton; + friend class Singleton; public: - std::vector get_registered() const; + std::vector 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 _registered; - std::map _active_policies; + std::vector _registered; + std::map _active_policies; }; }//~ namespace sgpem -#endif //POLICIES_GATEKEEPER_HH +#endif //~ CPU_POLICIES_GATEKEEPER_HH diff --git a/src/backend/policy.cc b/src/backend/cpu_policy.cc similarity index 86% rename from src/backend/policy.cc rename to src/backend/cpu_policy.cc index 6980191..f42dfc7 100644 --- a/src/backend/policy.cc +++ b/src/backend/cpu_policy.cc @@ -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; } diff --git a/src/backend/policy.hh b/src/backend/cpu_policy.hh similarity index 93% rename from src/backend/policy.hh rename to src/backend/cpu_policy.hh index 48c0c01..636ee07 100644 --- a/src/backend/policy.hh +++ b/src/backend/cpu_policy.hh @@ -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 diff --git a/src/backend/policy_manager.cc b/src/backend/cpu_policy_manager.cc similarity index 69% rename from src/backend/policy_manager.cc rename to src/backend/cpu_policy_manager.cc index e929c79..9a89eff 100644 --- a/src/backend/policy_manager.cc +++ b/src/backend/cpu_policy_manager.cc @@ -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; } diff --git a/src/backend/policy_manager.hh b/src/backend/cpu_policy_manager.hh similarity index 71% rename from src/backend/policy_manager.hh rename to src/backend/cpu_policy_manager.hh index 2ca0055..65087a1 100644 --- a/src/backend/policy_manager.hh +++ b/src/backend/cpu_policy_manager.hh @@ -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 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& get_avail_policies() = 0; + virtual const std::vector& 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 _policies; + std::vector _policies; private: /** A pointer to the registered instance */ - static PolicyManager* _registered; + static CPUPolicyManager* _registered; }; } //~ namespace sgpem diff --git a/src/backend/scheduler.cc b/src/backend/scheduler.cc index 1d9a755..5094a09 100644 --- a/src/backend/scheduler.cc +++ b/src/backend/scheduler.cc @@ -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 diff --git a/src/backend/scheduler.hh b/src/backend/scheduler.hh index 80ceaa5..7a80572 100644 --- a/src/backend/scheduler.hh +++ b/src/backend/scheduler.hh @@ -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; }; diff --git a/src/backend/simulation.hh b/src/backend/simulation.hh index e1b6796..5abcc72 100644 --- a/src/backend/simulation.hh +++ b/src/backend/simulation.hh @@ -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; diff --git a/src/backend/string_utils.hh b/src/backend/string_utils.hh index 167379f..faaa303 100644 --- a/src/backend/string_utils.hh +++ b/src/backend/string_utils.hh @@ -28,10 +28,6 @@ #include #include -// 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 Tokens; diff --git a/src/parse_opts.cc b/src/parse_opts.cc index 5317ed3..a133fe7 100644 --- a/src/parse_opts.cc +++ b/src/parse_opts.cc @@ -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 #include @@ -119,9 +119,9 @@ parse_options(int argc, char** argv) for(vector::iterator it = modules.begin(); it != modules.end(); ++it) (*it)->set_enabled(true); - vector managers = PoliciesGatekeeper::get_instance().get_registered(); + vector managers = CPUPoliciesGatekeeper::get_instance().get_registered(); - for(vector::iterator it = managers.begin(); it != managers.end(); ++it) + for(vector::iterator it = managers.begin(); it != managers.end(); ++it) (*it)->init(); diff --git a/src/text_simulation.cc b/src/text_simulation.cc index b66befc..aa1e495 100644 --- a/src/text_simulation.cc +++ b/src/text_simulation.cc @@ -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 ManagerVec; - typedef vector::iterator PolicyIt; + typedef vector ManagerVec; + typedef vector::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 policies = (*it)->get_avail_policies(); - for(PolicyIt it = policies.begin(); it != policies.end(); ++it) + vector 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 ManagerVec; - typedef vector::iterator PolicyIt; + typedef vector ManagerVec; + typedef vector::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 policies = (*it)->get_avail_policies(); - for(PolicyIt it = policies.begin(); it != policies.end(); ++it) + vector policies = (*it)->get_avail_policies(); + for(CPUPolicyIt it = policies.begin(); it != policies.end(); ++it) { ostringstream oss; oss << index << ". " << (*it)->get_name() << endl;