- Another bit of auditing

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1202 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-09-16 17:04:20 +00:00
parent ee1810df10
commit ec84480e2d
11 changed files with 176 additions and 158 deletions

View File

@ -21,20 +21,23 @@
#ifndef CONCRETE_ENVIRONMENT_HH
#define CONCRETE_ENVIRONMENT_HH 1
namespace sgpem
{
class ConcreteEnvironment;
class SerializeVisitor;
}
#include "dynamic_process.hh"
#include "dynamic_request.hh"
#include <sgpemv2/environment.hh>
#include <sgpemv2/resource.hh>
#include "dynamic_process.hh"
#include "dynamic_request.hh"
#include <sgpemv2/ready_queue.hh>
namespace sgpem
{
class SerializeVisitor;
/// \brief An implementation of the Environment class
/// \brief An implementation of the Environment class.
///
/// Class ConcreteEnvironment implements the Environment
/// abstract class.
///
@ -45,18 +48,26 @@ namespace sgpem
/// \see Environment
class SG_DLLLOCAL ConcreteEnvironment : public Environment
{
public:
typedef std::map<resource_key_t, SubRequestQueue> SubRequestQueues;
/// \brief Standard constructor.
///
/// Builds an empty environment.
ConcreteEnvironment();
/// \brief Copy constructor.
///
/// Performs a deep copy of all structures.
ConcreteEnvironment(const ConcreteEnvironment& c);
/// \brief The standard virtual destructor.
///
/// The standard virtual destructor.
virtual ~ConcreteEnvironment();
/// \brief Returns an indexed set of snapshots of the processes
///
/// Returns a standard vector of Process objects describing
/// all the processes of the simulated environment at the
/// considered instant.
@ -66,21 +77,16 @@ namespace sgpem
/// always safe.
///
/// \return a constant set of snapshots of processes
virtual const Processes&
get_processes() const;
virtual const Processes& get_processes() const;
/// \brief Non-constant version of get_processes()
///
/// \return a set of snapshots of processes
/// \see get_processes()
virtual Processes&
get_processes();
virtual Processes& get_processes();
/// \brief Returns an indexed set of snapshots of the resources
///
/// Returns a standard map of \code int \endcode to Resource
/// objects describing the all resources of the simulated environment
/// at the considered instant.
@ -98,21 +104,16 @@ namespace sgpem
///
/// \return a indexed constant set of snapshot of resources.
/// \see DynamicSybrequest::get_resource()
virtual const Resources&
get_resources() const;
virtual const Resources& get_resources() const;
/// \brief Non-constant version of get_resources()
///
/// \return an indexed set of snapshots of resources
/// \see get_resources()
virtual Resources&
get_resources();
virtual Resources& get_resources();
/// \brief Returns a snapshot of the current request queue for a resource.
///
/// Returns a standard vector of Request objects
/// representing the queue of ready requests of threads which
/// are waiting for getting control of a limited-access resource.
@ -123,72 +124,55 @@ namespace sgpem
///
/// \param resource The resource the requests are for
/// \return The current ready requests queue.
virtual const SubRequestQueue&
get_request_queue(resource_key_t resource_key) const;
SubRequestQueue&
get_request_queue(resource_key_t resource_key);
typedef std::map<resource_key_t, SubRequestQueue> SubRequestQueues;
virtual const SubRequestQueue& get_request_queue(resource_key_t resource_key) const;
SubRequestQueue& get_request_queue(resource_key_t resource_key);
/// \brief Returns the set of request queues.
///
/// Returns a reference to the map from resources to subreuqest queues.
/// It is needed by history to delete the queue associated to a deleted
/// resource.
SubRequestQueues&
get_subrequest_queues();
SubRequestQueues& get_subrequest_queues();
/// \brief Returns a snapshot of the current scheduler's ready queue.
///
/// Returns a ReadyQueue object representing the queue
/// of ready processes or ready threads, depending on the
/// scheduling policy, which are waiting for getting control
/// of the CPU.
///
/// \return the current ready queue (constant).
virtual const ReadyQueue&
get_sorted_queue() const;
virtual const ReadyQueue& get_sorted_queue() const;
/// \brief Non-constant version of get_sorted_queue()
///
/// \return the current ready queue.
/// \see get_sorted_queue()
virtual ReadyQueue&
get_sorted_queue();
/// \brief The standard virtual destructor.
/// The standard virtual destructor.
virtual
~ConcreteEnvironment();
virtual ReadyQueue& get_sorted_queue();
private:
/// \brief The container of all Resource objecs.
///
/// Actually contains only DynamicResource objects.
// resources come before processes because of
// destruction order. See destructor implementation
Resources _resources;
/// \brief The container of all Process objecs.
///
/// Actually contains only DynamicProcess objects.
Processes _processes;
/// \brief The queue of the ready schedulables
///
/// Does not contain the running process.
ReadyQueue _sched_queue;
SubRequestQueues _sreq_queues;
}
; //~ class ConcreteEnvironment
}; //~ class ConcreteEnvironment
} //~ namespace sgpem

View File

@ -21,7 +21,10 @@
#ifndef CONCRETE_HISTORY_HH
#define CONCRETE_HISTORY_HH 1
namespace sgpem
{
class ConcreteHistory;
}
#include "concrete_environment.hh"
#include "dynamic_process.hh"
@ -29,6 +32,7 @@
#include "dynamic_resource.hh"
#include "dynamic_sub_request.hh"
#include "dynamic_thread.hh"
#include <sgpemv2/history.hh>
#include <glibmm/ustring.h>
@ -40,8 +44,6 @@
namespace sgpem
{
class ConcreteHistory;
class SG_DLLLOCAL ConcreteHistory : public History
{
public:

View File

@ -21,8 +21,8 @@
#include "dynamic_process.hh"
#include "static_process.hh"
#include "dynamic_thread.hh"
#include <sgpemv2/serialize_visitor.hh>
#include <sgpemv2/serialize_visitor.hh>
#include <sgpemv2/templates/deletor.tcc>
#include <sgpemv2/templates/sequences.tcc>
@ -54,7 +54,8 @@ DynamicProcess::DynamicProcess(const DynamicProcess &other) :
DynamicProcess::~DynamicProcess()
{
for_each(_dynamic_threads.begin(), _dynamic_threads.end(),
for_each(_dynamic_threads.begin(),
_dynamic_threads.end(),
memory::deletor<DynamicThread>());
}
@ -73,7 +74,7 @@ DynamicProcess::get_threads() const
Schedulable::state
DynamicProcess::get_state() const
{
static const int uninitialized = -1;
const int uninitialized = -1;
state result = state_terminated;
int next_thread_starts_at = uninitialized;
@ -99,7 +100,7 @@ DynamicProcess::get_state() const
for(Iseq<ConstThreadIt> seq = iseq(_dynamic_threads); seq; ++seq)
{
state thread_state = (*seq)->get_state();
const state thread_state = (*seq)->get_state();
switch(thread_state)
{
@ -133,7 +134,8 @@ DynamicProcess::get_state() const
// the next thread to start, e.g. the one with the least arrival_time,
// has start time greater than the current process elapsed time, then
// pass from state_future to state_terminated:
if (result == state_future && next_thread_starts_at > static_cast<int>(get_elapsed_time()))
if (result == state_future &&
next_thread_starts_at > static_cast<int>(get_elapsed_time()))
return state_terminated;
return result;

View File

@ -21,23 +21,27 @@
#ifndef DYNAMIC_REQUEST_HH
#define DYNAMIC_REQUEST_HH 1
#include <sgpemv2/request.hh>
#include "static_request.hh"
#include "dynamic_thread.hh"
#include <sgpemv2/templates/smartp.hh>
#include <vector>
namespace sgpem
{
class DynamicRequest;
class SerializeVisitor;
class SubRequest;
class DynamicSubRequest;
}
#include "static_request.hh"
#include "dynamic_thread.hh"
#include <sgpemv2/request.hh>
#include <sgpemv2/templates/smartp.hh>
#include <vector>
namespace sgpem
{
/** \brief A "dynamic" request, which represents the state
* of a request at a particular temporal instant
*/
class SG_DLLLOCAL DynamicRequest : public Request
{
public:
@ -60,9 +64,9 @@ namespace sgpem
StaticRequest& get_core();
const StaticRequest& get_core() const;
// Since this method is visible only by the backend,
// return directly a reference that lets us to
// add and remove subrequests at will.
/// \internal Since this method is visible only by the backend,
/// return directly a reference that lets us to
/// add and remove subrequests at will.
std::vector<DynamicSubRequest*>& get_dynamic_subrequests();
private:

View File

@ -20,9 +20,9 @@
#include "dynamic_sub_request.hh"
#include "dynamic_request.hh"
#include <sgpemv2/request.hh>
#include <sgpemv2/serialize_visitor.hh>
#include <sgpemv2/templates/down_cast.tcc>
#include <sgpemv2/templates/smartp.tcc>
@ -38,8 +38,9 @@ DynamicSubRequest::DynamicSubRequest(StaticSubRequest* core,
{
assert(core != NULL);
assert(owner != NULL);
// Leave this line: it helps us with a compiler warning if
// the get_dynamic* method signature changes:
// Leave this line: it helps us with a compiler warning if
// the get_dynamic* method signature changes:
std::vector<DynamicSubRequest*>& siblings = owner->get_dynamic_subrequests();
siblings.push_back(this);
}
@ -52,8 +53,8 @@ DynamicSubRequest::DynamicSubRequest(const DynamicSubRequest& other,
{
assert(owner != NULL);
// Leave this line: it helps us with a compiler warning if
// the get_dynamic* method signature changes:
// Leave this line: it helps us with a compiler warning if
// the get_dynamic* method signature changes:
std::vector<DynamicSubRequest*>& siblings = owner->get_dynamic_subrequests();
siblings.push_back(this);
}
@ -61,11 +62,11 @@ DynamicSubRequest::DynamicSubRequest(const DynamicSubRequest& other,
DynamicSubRequest::~DynamicSubRequest()
{}
bool
DynamicSubRequest::operator==(const SubRequest& op2) const
{
return _static_subrequest == down_cast<const DynamicSubRequest&>(op2)._static_subrequest;
return _static_subrequest ==
down_cast<const DynamicSubRequest&>(op2)._static_subrequest;
}
@ -75,7 +76,6 @@ DynamicSubRequest::get_resource_key() const
return _static_subrequest->get_resource_key();
}
unsigned int
DynamicSubRequest::get_length() const
{
@ -129,6 +129,7 @@ unsigned int
DynamicSubRequest::decrease_remaining_time()
{
assert(_state == Request::state_allocated);
unsigned int temp = get_remaining_time();
if (temp > 0)
_ran_for++;

View File

@ -27,7 +27,8 @@ using Glib::ustring;
// instantiate Parameter template for use outside this DSO
namespace sgpem {
namespace sgpem
{
template class SG_DLLEXPORT PolicyParameters::Parameter<int>;
template class SG_DLLEXPORT PolicyParameters::Parameter<float>;
template class SG_DLLEXPORT PolicyParameters::Parameter<Glib::ustring>;
@ -39,14 +40,23 @@ namespace sgpem {
If there is a parameter with the same name and type it will be overwritten.
*/
void
PolicyParameters::register_int(Glib::ustring name, const int& lower_bound, const int& upper_bound, const bool& required, const int& default_value)
PolicyParameters::register_int(Glib::ustring name,
const int& lower_bound,
const int& upper_bound,
const bool& required,
const int& default_value)
{
//there is a parameter with the same name!!
map<ustring, Parameter<int> >::iterator i = int_map.find(name);
if (i != int_map.end())
int_map.erase(i);
map<ustring, Parameter<int> >::value_type v(name, Parameter<int>(name, default_value, lower_bound, upper_bound, required, default_value));
map<ustring, Parameter<int> >::value_type v(name, Parameter<int>(name,
default_value,
lower_bound,
upper_bound,
required,
default_value));
int_map.insert(v);
}
@ -56,14 +66,24 @@ PolicyParameters::register_int(Glib::ustring name, const int& lower_bound, const
If there is a parameter with the same name and type it will be overwritten.
*/
void
PolicyParameters::register_float(Glib::ustring name, const float& lower_bound, const float& upper_bound, const bool& required, const float& default_value)
PolicyParameters::register_float(Glib::ustring name,
const float& lower_bound,
const float& upper_bound,
const bool& required,
const float& default_value)
{
//there is a parameter with the same name!!
map<ustring, Parameter<float> >::iterator i = float_map.find(name);
if (i != float_map.end())
float_map.erase(i);
map<ustring, Parameter<float> >::value_type v(name, Parameter<float>(name, default_value, lower_bound, upper_bound, required, default_value));
map<ustring, Parameter<float> >::value_type v(name, Parameter<float>(name,
default_value,
lower_bound,
upper_bound,
required,
default_value));
float_map.insert(v);
}
@ -79,7 +99,12 @@ PolicyParameters::register_string(Glib::ustring name, const bool& required, cons
if (i != string_map.end())
string_map.erase(i);
map<ustring, Parameter<Glib::ustring> >::value_type v(name, Parameter<Glib::ustring>(name, default_value, "", "", required, default_value));
map<ustring, Parameter<Glib::ustring> >::value_type v(name, Parameter<Glib::ustring>(name,
default_value,
"",
"",
required,
default_value));
string_map.insert(v);
}
@ -189,7 +214,7 @@ PolicyParameters::set_string(ustring name, const ustring& value)
\throws A PolicyParametersException if the parameter has not been found.
*/
int
PolicyParameters::get_int(ustring name) const
PolicyParameters::get_int(ustring name) const throw(PolicyParametersException)
{
map<ustring, Parameter<int> >::const_iterator i = int_map.find(name);
if (i == int_map.end())
@ -205,7 +230,7 @@ PolicyParameters::get_int(ustring name) const
\throws A PolicyParametersException if the parameter has not been found.
*/
float
PolicyParameters::get_float(ustring name) const
PolicyParameters::get_float(ustring name) const throw(PolicyParametersException)
{
map<ustring, Parameter<float> >::const_iterator i = float_map.find(name);
if (i == float_map.end())
@ -221,7 +246,7 @@ PolicyParameters::get_float(ustring name) const
\throws A PolicyParametersException if the parameter has not been found.
*/
ustring
PolicyParameters::get_string(ustring name) const
PolicyParameters::get_string(ustring name) const throw(PolicyParametersException)
{
map<ustring, Parameter<ustring> >::const_iterator i = string_map.find(name);
if (i == string_map.end())

View File

@ -229,19 +229,19 @@ namespace sgpem
\returns the INTEGER value of the parameter named \e name
\throws PolicyParametersException if the parameter named \e name has not been registered
*/
int get_int(Glib::ustring name) const;
int get_int(Glib::ustring name) const throw(PolicyParametersException);
/** \brief Returns the value of an FLOAT parameter
\returns the FLOAT value of the parameter named \e name
\throws PolicyParametersException if the parameter named \e name has not been registered
*/
float get_float(Glib::ustring name) const;
float get_float(Glib::ustring name) const throw(PolicyParametersException);
/** \brief Returns the value of an STRING parameter
\returns the STRING value of the parameter named \e name
\throws PolicyParametersException if the parameter named \e name has not been registered
*/
Glib::ustring get_string(Glib::ustring name) const;
Glib::ustring get_string(Glib::ustring name) const throw(PolicyParametersException);

View File

@ -1,4 +1,4 @@
// src/backend/process_statistics.hh - Copyright 2005, 2006, University
// src/backend/sgpemv2/process_statistics.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
@ -21,16 +21,16 @@
#ifndef PROCESS_STATISTICS_HH
#define PROCESS_STATISTICS_HH 1
#include <sgpemv2/sgpemv2-visibility.hh>
#include "thread_statistics.hh"
#include <sgpemv2/sgpemv2-visibility.hh>
#include <sgpemv2/schedulable_statistics.hh>
#include <sgpemv2/thread_statistics.hh>
#include <sgpemv2/process.hh>
#include "thread_statistics.hh"
#include <vector>
#include <glibmm/ustring.h>
#include <vector>
namespace sgpem
{
@ -39,19 +39,10 @@ namespace sgpem
public:
~ProcessStatistics();
int get_execution_time() const =0;
int get_execution_progress() const =0;
int get_total_inactivity() const =0;
int get_response_time() const =0;
virtual float get_average_response_time() const =0;
int get_turn_around() const =0;
int get_efficiency() const =0;
int get_resource_usage_time() const =0;
int get_resource_waitings_time() const =0;
virtual float get_average_response_time() const = 0;
virtual const Process* get_core() const = 0;
const Process* get_core() const =0;
virtual std::vector<const ThreadStatistics*> get_threads_statistics() const =0;
virtual std::vector<const ThreadStatistics*> get_threads_statistics() const = 0;
protected:
ProcessStatistics();

View File

@ -1,4 +1,4 @@
// src/backend/resource_policy.hh - Copyright 2005, 2006, University
// src/backend/sgpemv2/resource_policy.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
@ -21,22 +21,25 @@
#ifndef RESOURCE_POLICY_HH
#define RESOURCE_POLICY_HH 1
#include <sgpemv2/sgpemv2-visibility.hh>
namespace sgpem
{
class ResourcePolicy;
}
#include "gettext.h"
#include "glibmm/ustring.h"
#include <sgpemv2/sgpemv2-visibility.hh>
#include <sgpemv2/policy_parameters.hh>
#include <sgpemv2/user_interrupt_exception.hh>
#include <sgpemv2/environment.hh>
#include <sgpemv2/sub_request.hh>
#include <glibmm/ustring.h>
namespace sgpem
{
class ResourcePolicy;
/** \brief It's a Strategy wich stay for a resource allocating algorithm.
/** \brief
It's a Strategy wich stay for a resource allocating algorithm.
It implements the related resource allocation policy.
*/
class SG_DLLEXPORT ResourcePolicy
@ -45,7 +48,7 @@ namespace sgpem
virtual ~ResourcePolicy();
/**
Initialize 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
in concrete derived classes.
@ -53,7 +56,7 @@ namespace sgpem
virtual void configure() throw(UserInterruptException) = 0;
/**
Allocate resources to the threads
\brief Allocate resources to the threads
Because it's a pure virtual method, must be re-implemented
in concrete derived classes.
@ -61,7 +64,7 @@ namespace sgpem
virtual void enforce(Environment& environment, Environment::SubRequestQueue& queue, SubRequest& sr) throw(UserInterruptException) = 0;
/**
Gets a string description of the policy.
\brief Gets a string description of the policy.
Because it's a pure virtual method, must be re-implemented
in concrete derived classes.
@ -76,7 +79,7 @@ namespace sgpem
virtual void deactivate() = 0;
/**
Gets the parameters related with this policy.
\brief Gets the parameters related with this policy.
\return The policy parameters.
*/

View File

@ -1,4 +1,4 @@
// src/backend/serializers_gatekeeper.hh - Copyright 2005, 2006, University
// src/backend/sgpemv2/serializers_gatekeeper.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
@ -24,23 +24,23 @@
namespace sgpem
{
class Serializer;
class SerializersGatekeeper;
}
#include <sgpemv2/sgpemv2-visibility.hh>
#include <sgpemv2/templates/singleton.hh>
#include <vector>
#include <sgpemv2/templates/singleton.hh>
namespace sgpem
{
class SerializersGatekeeper;
/** \brief FIXME document me
/** \brief Manages instances of Serializer subclasses
*
* Normally you will use only the get_registered method, since
* the Serializer base class automatically registers/unregisters
* himself when appropriate.
*/
class SG_DLLEXPORT SerializersGatekeeper : public Singleton<SerializersGatekeeper>
{
friend class Singleton<SerializersGatekeeper>;
@ -48,8 +48,15 @@ namespace sgpem
public:
std::vector<Serializer*> get_registered() const;
/** \brief Registers a serializer
* \param serializer The serializer, cannot be NULL
*/
void register_serializer(Serializer* serializer);
/** \brief Unregisters a serializer
* \param serializer The serializer, cannot be NULL. If the serializer
* wasn't previously registered, this method is a no-op.
*/
void unregister_serializer(Serializer* serializer);
private:

View File

@ -18,11 +18,10 @@
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <sgpemv2/statistics.hh>
#include "concrete_statistics.hh"
// Do not include in header file:
#include "sgpemv2/templates/singleton.tcc"
#include <sgpemv2/statistics.hh>
#include <sgpemv2/templates/singleton.tcc>
using namespace sgpem;