From b9cbbacd1000ebc254828952bb7701e977d46d97 Mon Sep 17 00:00:00 2001 From: elvez Date: Tue, 1 Aug 2006 22:57:40 +0000 Subject: [PATCH] - Added ResourcePolicy class. I need to clear some doubts before writing the remaining part of resource policy management... git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@808 3ecf2c5c-341e-0410-92b4-d18e462d057c --- Makefile.am | 2 + src/backend/policy.hh | 3 -- src/backend/policy_manager.hh | 2 + src/backend/resource_policy.cc | 34 +++++++++++++ src/backend/resource_policy.hh | 90 ++++++++++++++++++++++++++++++++++ src/text_simulation.cc | 2 +- 6 files changed, 129 insertions(+), 4 deletions(-) create mode 100644 src/backend/resource_policy.cc create mode 100644 src/backend/resource_policy.hh diff --git a/Makefile.am b/Makefile.am index f11fbba..a8ef0cd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -174,6 +174,7 @@ src_backend_libbackend_la_SOURCES = \ src/backend/ready_queue.cc \ src/backend/request.cc \ src/backend/resource.cc \ + src/backend/resource_policy.cc \ src/backend/schedulable.cc \ src/backend/scheduler.cc \ src/backend/serialize_visitor.cc \ @@ -210,6 +211,7 @@ pkginclude_HEADERS += \ src/backend/ready_queue.hh \ src/backend/request.hh \ src/backend/resource.hh \ + src/backend/resource_policy.hh \ src/backend/process.hh \ src/backend/schedulable.hh \ src/backend/scheduler.hh \ diff --git a/src/backend/policy.hh b/src/backend/policy.hh index 61e3bc8..48c0c01 100644 --- a/src/backend/policy.hh +++ b/src/backend/policy.hh @@ -26,7 +26,6 @@ #include "glibmm/ustring.h" -#include "scheduler.hh" #include "policy_parameters.hh" #include "user_interrupt_exception.hh" @@ -98,8 +97,6 @@ namespace sgpem /** Gets the parameters related with this policy. - Because it's a pure virtual method, must be re-implemented - in concrete derived classes. \return The policy parameters. */ PolicyParameters& get_parameters(); diff --git a/src/backend/policy_manager.hh b/src/backend/policy_manager.hh index d598059..2ca0055 100644 --- a/src/backend/policy_manager.hh +++ b/src/backend/policy_manager.hh @@ -25,6 +25,8 @@ #include "policy.hh" +#include + namespace sgpem { diff --git a/src/backend/resource_policy.cc b/src/backend/resource_policy.cc new file mode 100644 index 0000000..d6c6422 --- /dev/null +++ b/src/backend/resource_policy.cc @@ -0,0 +1,34 @@ +// src/backend/resource_policy.cc - Copyright 2005, 2006, University +// of Padova, dept. of Pure and Applied +// Mathematics +// +// This file is part of SGPEMv2. +// +// This is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// SGPEMv2 is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with SGPEMv2; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +#include "resource_policy.hh" +using namespace std; +using namespace sgpem; + +ResourcePolicy::~ResourcePolicy() +{} + + +PolicyParameters& +ResourcePolicy::get_parameters() +{ + return _parameters; +} + diff --git a/src/backend/resource_policy.hh b/src/backend/resource_policy.hh new file mode 100644 index 0000000..d0c8d1c --- /dev/null +++ b/src/backend/resource_policy.hh @@ -0,0 +1,90 @@ +// src/backend/resource_policy.hh - Copyright 2005, 2006, University +// of Padova, dept. of Pure and Applied +// Mathematics +// +// This file is part of SGPEMv2. +// +// This is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// SGPEMv2 is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with SGPEMv2; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +#ifndef RESOURCE_POLICY_HH +#define RESOURCE_POLICY_HH 1 + +#include "config.h" +#include "gettext.h" + +#include "glibmm/ustring.h" + +#include "policy_parameters.hh" +#include "user_interrupt_exception.hh" + +namespace sgpem +{ + class ResourcePolicy; + + /** \brief + It's a Strategy wich stay for a resource allocating algorithm. + It implements the related resource allocation policy. + */ + class SG_DLLEXPORT ResourcePolicy + { + public: + virtual ~ResourcePolicy(); + + /** + Initialize the inner components of the policy. + + Because it's a pure virtual method, must be re-implemented + in concrete derived classes. + */ + virtual void configure() throw(UserInterruptException) = 0; + + /** + Allocate resources to the threads + + Because it's a pure virtual method, must be re-implemented + in concrete derived classes. + */ + virtual void enforce() throw(UserInterruptException) = 0; + + /** + Gets a string description of the policy. + + Because it's a pure virtual method, must be re-implemented + in concrete derived classes. + \return String description of the policy. + */ + virtual Glib::ustring get_description() const = 0; + + virtual Glib::ustring get_name() const = 0; + + virtual void activate() = 0; + + virtual void deactivate() = 0; + + /** + Gets the parameters related with this policy. + + \return The policy parameters. + */ + PolicyParameters& get_parameters(); + + protected: + PolicyParameters _parameters; + }; + +}//~ namespace sgpem + + +#endif diff --git a/src/text_simulation.cc b/src/text_simulation.cc index d6f11bd..b66befc 100644 --- a/src/text_simulation.cc +++ b/src/text_simulation.cc @@ -494,7 +494,7 @@ TextSimulation::on_help(const Tokens& arguments) "the cpu policy.\n\nThis is currently the only way to control the behaviour of " "cpu policies without modifying their source code.\n")); else if(command == "HELP") - p_stdout(_("-- HELP COMMAND --\nThe help you're reading")); + p_stdout(_("-- HELP COMMAND --\nThe help you're reading.\n")); else if(command == "GET") p_stdout(_("-- GET COMMAND --\nSyntax: GET \n" "\twhere may be simulation-tick or continuous.\n"));