- Audited resource_policy_prioirty.hh and others

- Minor corrections to other policies
- Corrected email address in deb distro


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1239 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
matrevis 2006-09-17 16:26:02 +00:00
parent a8beb17e76
commit a61b21d94b
8 changed files with 115 additions and 89 deletions

View File

@ -6,7 +6,7 @@ Architecture: i386
Pre-Depends: libstdc++6 Pre-Depends: libstdc++6
Depends: libgtkmm-2.4-1c2a, libglademm-2.4-1c2a, libxml2 (>= 2.6.10), libcairo, python (>= 2.3) Depends: libgtkmm-2.4-1c2a, libglademm-2.4-1c2a, libxml2 (>= 2.6.10), libcairo, python (>= 2.3)
Installed-Size: @SIZE@ Installed-Size: @SIZE@
Maintainer: Marco Trevisan <evenjin@gmail.com> Maintainer: Marco Trevisan <evenjn@gmail.com>
Provides: sgpemv2 Provides: sgpemv2
Description: A graphical process management simulator with educational purposes. Description: A graphical process management simulator with educational purposes.
. .

View File

@ -1,4 +1,4 @@
// src/backend/malformed_policy_exception.hh - Copyright 2005, 2006, University // src/backend/sgpemv2/malformed_policy_exception.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied // of Padova, dept. of Pure and Applied
// Mathematics // Mathematics
// //
@ -31,11 +31,19 @@
namespace sgpem namespace sgpem
{ {
/// \brief An exception signaling a non well-formed script.
/// Represents an exception which may be raised to signal that a script which
/// was supposed to represent a policy is not well-formed.
class MalformedPolicyException; class MalformedPolicyException;
class SG_DLLEXPORT MalformedPolicyException : public CPUPolicyException class SG_DLLEXPORT MalformedPolicyException : public CPUPolicyException
{ {
public: public:
/// \brief Constructor taking a message as parameter.
///
/// Creates a MalformedPolicyException with an optional detailed message.
/// \param msg a message carrying detailed information.
explicit MalformedPolicyException(const std::string& msg = ""); explicit MalformedPolicyException(const std::string& msg = "");
}; };
} //~ namespace sgpem } //~ namespace sgpem

View File

@ -38,51 +38,70 @@ namespace sgpem
namespace sgpem namespace sgpem
{ {
/** \brief It's a Strategy wich stay for a resource allocating algorithm.
It implements the related resource allocation policy. /// \brief A resource allocation policy.
*/ ///
/// A resource allocation policy manages the queues of requests.
/// Its purpose is to decide which threads may use the available
/// resources first.
class SG_DLLEXPORT ResourcePolicy class SG_DLLEXPORT ResourcePolicy
{ {
public: public:
/// \brief Standard virtual destructor.
///
/// Standard virtual destructor.
virtual ~ResourcePolicy(); virtual ~ResourcePolicy();
/** /// \brief Initializes the inner components of the policy.
\brief Initialize the inner components of the policy. ///
/// Because it's a pure virtual method, must be re-implemented
Because it's a pure virtual method, must be re-implemented /// in concrete derived classes.
in concrete derived classes.
*/
virtual void configure() throw(UserInterruptException) = 0; virtual void configure() throw(UserInterruptException) = 0;
/** /// \brief Sorts the subrequest queue.
\brief Allocate resources to the threads ///
/// Because it's a pure virtual method, must be re-implemented
Because it's a pure virtual method, must be re-implemented /// in concrete derived classes.
in concrete derived classes. ///
*/ /// \param environment the environment on which the policy applies.
/// \param queue the queue where a subrequest has just been added.
/// \param sr the subrequest which has just been added.
virtual void enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr) throw(UserInterruptException) = 0; virtual void enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr) throw(UserInterruptException) = 0;
/** /// \brief Returns a description of the policy.
\brief Gets a string description of the policy. ///
/// Because it's a pure virtual method, must be re-implemented
Because it's a pure virtual method, must be re-implemented /// in concrete derived classes.
in concrete derived classes. /// Returns a description of the policy.
\return String description of the policy. /// \return a description of the policy.
*/
virtual Glib::ustring get_description() const = 0; virtual Glib::ustring get_description() const = 0;
/// \brief Returns the name of the policy.
///
/// Because it's a pure virtual method, must be re-implemented
/// in concrete derived classes.
/// Returns the name of the policy.
/// \return the name of the policy.
virtual Glib::ustring get_name() const = 0; virtual Glib::ustring get_name() const = 0;
/// \brief Activates the policy.
///
/// Because it's a pure virtual method, must be re-implemented
/// in concrete derived classes.
virtual void activate() = 0; virtual void activate() = 0;
/// \brief Deactivates the policy.
///
/// Because it's a pure virtual method, must be re-implemented
/// in concrete derived classes.
virtual void deactivate() = 0; virtual void deactivate() = 0;
/** /// \brief Returns the parameters used to customize the policy.
\brief Gets the parameters related with this policy. ///
/// Returns the parameters used to customize the policy.
\return The policy parameters. /// The user may modify them directly.
*/ /// \return the parameters used to customize the policy.
PolicyParameters& get_parameters(); PolicyParameters& get_parameters();
protected: protected:

View File

@ -1,4 +1,4 @@
// src/backend/resource_policy_fifo.hh - Copyright 2005, 2006, University // src/backend/sgpemv2/resource_policy_fifo.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied // of Padova, dept. of Pure and Applied
// Mathematics // Mathematics
// //
@ -21,16 +21,8 @@
#ifndef RESOURCE_POLICY_FIFO_HH #ifndef RESOURCE_POLICY_FIFO_HH
#define RESOURCE_POLICY_FIFO_HH 1 #define RESOURCE_POLICY_FIFO_HH 1
#include <sgpemv2/sgpemv2-visibility.hh>
#include "gettext.h"
#include "glibmm/ustring.h"
#include <sgpemv2/resource_policy.hh> #include <sgpemv2/resource_policy.hh>
#include <sgpemv2/policy_parameters.hh>
#include <sgpemv2/user_interrupt_exception.hh>
namespace sgpem namespace sgpem
{ {
class ResourcePolicyFiFo; class ResourcePolicyFiFo;
@ -42,6 +34,10 @@ namespace sgpem
class SG_DLLEXPORT ResourcePolicyFiFo : public ResourcePolicy class SG_DLLEXPORT ResourcePolicyFiFo : public ResourcePolicy
{ {
public: public:
/// \brief Standard virtual destructor.
///
/// Standard virtual destructor.
virtual ~ResourcePolicyFiFo(); virtual ~ResourcePolicyFiFo();
/** /**

View File

@ -1,4 +1,4 @@
// src/backend/resource_policy_lifo.hh - Copyright 2005, 2006, University // src/backend/sgpemv2/resource_policy_lifo.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied // of Padova, dept. of Pure and Applied
// Mathematics // Mathematics
// //
@ -21,16 +21,8 @@
#ifndef RESOURCE_POLICY_LIFO_HH #ifndef RESOURCE_POLICY_LIFO_HH
#define RESOURCE_POLICY_LIFO_HH 1 #define RESOURCE_POLICY_LIFO_HH 1
#include <sgpemv2/sgpemv2-visibility.hh>
#include "gettext.h"
#include "glibmm/ustring.h"
#include <sgpemv2/resource_policy.hh> #include <sgpemv2/resource_policy.hh>
#include <sgpemv2/policy_parameters.hh>
#include <sgpemv2/user_interrupt_exception.hh>
namespace sgpem namespace sgpem
{ {
class ResourcePolicyLiFo; class ResourcePolicyLiFo;
@ -42,6 +34,10 @@ namespace sgpem
class SG_DLLEXPORT ResourcePolicyLiFo : public ResourcePolicy class SG_DLLEXPORT ResourcePolicyLiFo : public ResourcePolicy
{ {
public: public:
/// \brief Standard virtual destructor.
///
/// Standard virtual destructor.
virtual ~ResourcePolicyLiFo(); virtual ~ResourcePolicyLiFo();
/** /**

View File

@ -21,62 +21,72 @@
#ifndef RESOURCE_POLICY_PRIORITY_HH #ifndef RESOURCE_POLICY_PRIORITY_HH
#define RESOURCE_POLICY_PRIORITY_HH 1 #define RESOURCE_POLICY_PRIORITY_HH 1
#include <sgpemv2/sgpemv2-visibility.hh>
#include "gettext.h"
#include "glibmm/ustring.h"
#include <sgpemv2/resource_policy.hh> #include <sgpemv2/resource_policy.hh>
#include <sgpemv2/policy_parameters.hh>
#include <sgpemv2/user_interrupt_exception.hh>
namespace sgpem namespace sgpem
{ {
/// \brief A resource allocation policy which provides a better service
/// to higer priority threads.
///
/// A resource allocation policy which provides a better service
/// to higer priority threads. This policy sorts the request queues
/// following the priority of the owners of the requests.
class ResourcePolicyPriority; class ResourcePolicyPriority;
/** \brief
It's a Strategy wich stay for a resource allocating algorithm.
It implements the related resource allocation policy.
*/
class SG_DLLEXPORT ResourcePolicyPriority : public ResourcePolicy class SG_DLLEXPORT ResourcePolicyPriority : public ResourcePolicy
{ {
public: public:
/// \brief Standard virtual destructor.
///
/// Standard virtual destructor.
virtual ~ResourcePolicyPriority(); virtual ~ResourcePolicyPriority();
/** /// \brief Initializes the inner components of the policy.
Initialize the inner components of the policy. ///
/// Does nothing.
Because it's a pure virtual method, must be re-implemented
in concrete derived classes.
*/
virtual void configure() throw(UserInterruptException); virtual void configure() throw(UserInterruptException);
/** /// \brief Sorts the subrequest queue letting higher priority threads to be the first ones
Mixes the queues. /// to get the resources.
*/ ///
/// Sorts the subrequest queue letting higher priority threads to be the first ones
/// to get the resources.
///
/// \param environment the environment on which the policy applies.
/// \param queue the queue where a subrequest has just been added.
/// \param sr the subrequest which has just been added.
virtual void enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr) throw(UserInterruptException); virtual void enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr) throw(UserInterruptException);
/** /// \brief Returns a description of the policy.
Gets a string description of the policy. ///
/// Returns a description of the policy.
Because it's a pure virtual method, must be re-implemented /// \return a description of the policy.
in concrete derived classes.
\return String description of the policy.
*/
virtual Glib::ustring get_description() const; virtual Glib::ustring get_description() const;
/// \brief Returns the name of the policy.
///
/// Returns the name of the policy.
/// \return the name of the policy.
virtual Glib::ustring get_name() const; virtual Glib::ustring get_name() const;
/// \brief Activates the policy.
///
/// Does nothing.
virtual void activate(); virtual void activate();
/// \brief Deactivates the policy.
///
/// Does nothing.
virtual void deactivate(); virtual void deactivate();
/** /// \brief Returns the parameters used to customize the policy.
Gets the parameters related with this policy. ///
/// Returns the parameters used to customize the policy.
\return The policy parameters. /// The user may modify them directly.
*/ /// \return the parameters used to customize the policy.
PolicyParameters& get_parameters(); PolicyParameters& get_parameters();
protected: protected:

View File

@ -26,14 +26,7 @@ namespace sgpem
class ResourcePolicyPriorityInheritance; class ResourcePolicyPriorityInheritance;
} }
#include <sgpemv2/sgpemv2-visibility.hh>
#include "gettext.h"
#include <sgpemv2/resource_policy.hh> #include <sgpemv2/resource_policy.hh>
#include <sgpemv2/policy_parameters.hh>
#include <sgpemv2/user_interrupt_exception.hh>
#include <glibmm/ustring.h>
namespace sgpem namespace sgpem
{ {
@ -44,6 +37,10 @@ namespace sgpem
class SG_DLLEXPORT ResourcePolicyPriorityInheritance : public ResourcePolicy class SG_DLLEXPORT ResourcePolicyPriorityInheritance : public ResourcePolicy
{ {
public: public:
/// \brief Standard virtual destructor.
///
/// Standard virtual destructor.
virtual ~ResourcePolicyPriorityInheritance(); virtual ~ResourcePolicyPriorityInheritance();
/** /**

View File

@ -1,4 +1,4 @@
// src/backend/simulation_observer.hh - Copyright 2005, 2006, University // src/backend/sgpemv2/simulation_observer.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied // of Padova, dept. of Pure and Applied
// Mathematics // Mathematics
// //