- 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
This commit is contained in:
elvez 2006-08-01 22:57:40 +00:00
parent c6ebe792e4
commit b9cbbacd10
6 changed files with 129 additions and 4 deletions

View File

@ -174,6 +174,7 @@ src_backend_libbackend_la_SOURCES = \
src/backend/ready_queue.cc \ src/backend/ready_queue.cc \
src/backend/request.cc \ src/backend/request.cc \
src/backend/resource.cc \ src/backend/resource.cc \
src/backend/resource_policy.cc \
src/backend/schedulable.cc \ src/backend/schedulable.cc \
src/backend/scheduler.cc \ src/backend/scheduler.cc \
src/backend/serialize_visitor.cc \ src/backend/serialize_visitor.cc \
@ -210,6 +211,7 @@ pkginclude_HEADERS += \
src/backend/ready_queue.hh \ src/backend/ready_queue.hh \
src/backend/request.hh \ src/backend/request.hh \
src/backend/resource.hh \ src/backend/resource.hh \
src/backend/resource_policy.hh \
src/backend/process.hh \ src/backend/process.hh \
src/backend/schedulable.hh \ src/backend/schedulable.hh \
src/backend/scheduler.hh \ src/backend/scheduler.hh \

View File

@ -26,7 +26,6 @@
#include "glibmm/ustring.h" #include "glibmm/ustring.h"
#include "scheduler.hh"
#include "policy_parameters.hh" #include "policy_parameters.hh"
#include "user_interrupt_exception.hh" #include "user_interrupt_exception.hh"
@ -98,8 +97,6 @@ namespace sgpem
/** /**
Gets the parameters related with this policy. 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. \return The policy parameters.
*/ */
PolicyParameters& get_parameters(); PolicyParameters& get_parameters();

View File

@ -25,6 +25,8 @@
#include "policy.hh" #include "policy.hh"
#include <vector>
namespace sgpem namespace sgpem
{ {

View File

@ -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;
}

View File

@ -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

View File

@ -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 " "the cpu policy.\n\nThis is currently the only way to control the behaviour of "
"cpu policies without modifying their source code.\n")); "cpu policies without modifying their source code.\n"));
else if(command == "HELP") 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") else if(command == "GET")
p_stdout(_("-- GET COMMAND --\nSyntax: GET <attr_name>\n" p_stdout(_("-- GET COMMAND --\nSyntax: GET <attr_name>\n"
"\twhere <attr_name> may be simulation-tick or continuous.\n")); "\twhere <attr_name> may be simulation-tick or continuous.\n"));