From a61b21d94b407d04d119e6ea9b1c3da5bfb99afd Mon Sep 17 00:00:00 2001 From: matrevis Date: Sun, 17 Sep 2006 16:26:02 +0000 Subject: [PATCH] - 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 --- distro/deb/control-file-v1.0 | 2 +- .../sgpemv2/malformed_policy_exception.hh | 10 ++- src/backend/sgpemv2/resource_policy.hh | 75 +++++++++++------- src/backend/sgpemv2/resource_policy_fifo.hh | 14 ++-- src/backend/sgpemv2/resource_policy_lifo.hh | 14 ++-- .../sgpemv2/resource_policy_priority.hh | 76 +++++++++++-------- .../resource_policy_priority_inheritance.hh | 11 +-- src/backend/sgpemv2/simulation_observer.hh | 2 +- 8 files changed, 115 insertions(+), 89 deletions(-) diff --git a/distro/deb/control-file-v1.0 b/distro/deb/control-file-v1.0 index 95fe12c..0fd85bd 100644 --- a/distro/deb/control-file-v1.0 +++ b/distro/deb/control-file-v1.0 @@ -6,7 +6,7 @@ Architecture: i386 Pre-Depends: libstdc++6 Depends: libgtkmm-2.4-1c2a, libglademm-2.4-1c2a, libxml2 (>= 2.6.10), libcairo, python (>= 2.3) Installed-Size: @SIZE@ -Maintainer: Marco Trevisan +Maintainer: Marco Trevisan Provides: sgpemv2 Description: A graphical process management simulator with educational purposes. . diff --git a/src/backend/sgpemv2/malformed_policy_exception.hh b/src/backend/sgpemv2/malformed_policy_exception.hh index a255175..2bdc67f 100644 --- a/src/backend/sgpemv2/malformed_policy_exception.hh +++ b/src/backend/sgpemv2/malformed_policy_exception.hh @@ -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 // Mathematics // @@ -31,11 +31,19 @@ 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 SG_DLLEXPORT MalformedPolicyException : public CPUPolicyException { 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 = ""); }; } //~ namespace sgpem diff --git a/src/backend/sgpemv2/resource_policy.hh b/src/backend/sgpemv2/resource_policy.hh index 85abed7..3e73ae9 100644 --- a/src/backend/sgpemv2/resource_policy.hh +++ b/src/backend/sgpemv2/resource_policy.hh @@ -38,51 +38,70 @@ 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 { public: + + /// \brief Standard virtual destructor. + /// + /// Standard virtual destructor. virtual ~ResourcePolicy(); - /** - \brief Initialize the inner components of the policy. - - Because it's a pure virtual method, must be re-implemented - in concrete derived classes. - */ + /// \brief Initializes 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; - /** - \brief Allocate resources to the threads - - Because it's a pure virtual method, must be re-implemented - in concrete derived classes. - */ + /// \brief Sorts the subrequest queue. + /// + /// Because it's a pure virtual method, must be re-implemented + /// 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; - /** - \brief 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. - */ + /// \brief Returns a description of the policy. + /// + /// Because it's a pure virtual method, must be re-implemented + /// in concrete derived classes. + /// Returns a description of the policy. + /// \return a description of the policy. 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; + /// \brief Activates the policy. + /// + /// Because it's a pure virtual method, must be re-implemented + /// in concrete derived classes. 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; - /** - \brief Gets the parameters related with this policy. - - \return The policy parameters. - */ + /// \brief Returns the parameters used to customize the policy. + /// + /// Returns the parameters used to customize the policy. + /// The user may modify them directly. + /// \return the parameters used to customize the policy. PolicyParameters& get_parameters(); protected: diff --git a/src/backend/sgpemv2/resource_policy_fifo.hh b/src/backend/sgpemv2/resource_policy_fifo.hh index 60eb34e..c3237dd 100644 --- a/src/backend/sgpemv2/resource_policy_fifo.hh +++ b/src/backend/sgpemv2/resource_policy_fifo.hh @@ -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 // Mathematics // @@ -21,16 +21,8 @@ #ifndef RESOURCE_POLICY_FIFO_HH #define RESOURCE_POLICY_FIFO_HH 1 -#include -#include "gettext.h" - -#include "glibmm/ustring.h" - #include -#include -#include - namespace sgpem { class ResourcePolicyFiFo; @@ -42,6 +34,10 @@ namespace sgpem class SG_DLLEXPORT ResourcePolicyFiFo : public ResourcePolicy { public: + + /// \brief Standard virtual destructor. + /// + /// Standard virtual destructor. virtual ~ResourcePolicyFiFo(); /** diff --git a/src/backend/sgpemv2/resource_policy_lifo.hh b/src/backend/sgpemv2/resource_policy_lifo.hh index 1bc4715..9148460 100644 --- a/src/backend/sgpemv2/resource_policy_lifo.hh +++ b/src/backend/sgpemv2/resource_policy_lifo.hh @@ -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 // Mathematics // @@ -21,16 +21,8 @@ #ifndef RESOURCE_POLICY_LIFO_HH #define RESOURCE_POLICY_LIFO_HH 1 -#include -#include "gettext.h" - -#include "glibmm/ustring.h" - #include -#include -#include - namespace sgpem { class ResourcePolicyLiFo; @@ -42,6 +34,10 @@ namespace sgpem class SG_DLLEXPORT ResourcePolicyLiFo : public ResourcePolicy { public: + + /// \brief Standard virtual destructor. + /// + /// Standard virtual destructor. virtual ~ResourcePolicyLiFo(); /** diff --git a/src/backend/sgpemv2/resource_policy_priority.hh b/src/backend/sgpemv2/resource_policy_priority.hh index 1d7be05..be1f3bf 100644 --- a/src/backend/sgpemv2/resource_policy_priority.hh +++ b/src/backend/sgpemv2/resource_policy_priority.hh @@ -21,62 +21,72 @@ #ifndef RESOURCE_POLICY_PRIORITY_HH #define RESOURCE_POLICY_PRIORITY_HH 1 -#include -#include "gettext.h" - -#include "glibmm/ustring.h" - #include -#include -#include - 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; - /** \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 { public: + + /// \brief Standard virtual destructor. + /// + /// Standard virtual destructor. virtual ~ResourcePolicyPriority(); - /** - Initialize the inner components of the policy. - - Because it's a pure virtual method, must be re-implemented - in concrete derived classes. - */ + /// \brief Initializes the inner components of the policy. + /// + /// Does nothing. virtual void configure() throw(UserInterruptException); - /** - Mixes the queues. - */ + /// \brief Sorts the subrequest queue letting higher priority threads to be the first ones + /// 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); - /** - 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. - */ + /// \brief Returns a description of the policy. + /// + /// Returns a description of the policy. + /// \return a description of the policy. 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; + + /// \brief Activates the policy. + /// + /// Does nothing. virtual void activate(); + /// \brief Deactivates the policy. + /// + /// Does nothing. virtual void deactivate(); - /** - Gets the parameters related with this policy. - - \return The policy parameters. - */ + /// \brief Returns the parameters used to customize the policy. + /// + /// Returns the parameters used to customize the policy. + /// The user may modify them directly. + /// \return the parameters used to customize the policy. PolicyParameters& get_parameters(); protected: diff --git a/src/backend/sgpemv2/resource_policy_priority_inheritance.hh b/src/backend/sgpemv2/resource_policy_priority_inheritance.hh index a2e7922..018bcdc 100644 --- a/src/backend/sgpemv2/resource_policy_priority_inheritance.hh +++ b/src/backend/sgpemv2/resource_policy_priority_inheritance.hh @@ -26,14 +26,7 @@ namespace sgpem class ResourcePolicyPriorityInheritance; } -#include -#include "gettext.h" - #include -#include -#include - -#include namespace sgpem { @@ -44,6 +37,10 @@ namespace sgpem class SG_DLLEXPORT ResourcePolicyPriorityInheritance : public ResourcePolicy { public: + + /// \brief Standard virtual destructor. + /// + /// Standard virtual destructor. virtual ~ResourcePolicyPriorityInheritance(); /** diff --git a/src/backend/sgpemv2/simulation_observer.hh b/src/backend/sgpemv2/simulation_observer.hh index 3486047..188d42d 100644 --- a/src/backend/sgpemv2/simulation_observer.hh +++ b/src/backend/sgpemv2/simulation_observer.hh @@ -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 // Mathematics //