- Audited schedulable.hh
- Removed holt_graph.* since they were unused - Updated makefile accordingly git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1227 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
449d1cadad
commit
b976aaaa34
|
@ -221,7 +221,6 @@ src_backend_libbackend_la_SOURCES = \
|
|||
src/backend/global_preferences.cc \
|
||||
src/backend/history.cc \
|
||||
src/backend/history_observer.cc \
|
||||
src/backend/holt_graph.cc \
|
||||
src/backend/invalid_plugin_exception.cc \
|
||||
src/backend/key_file.cc \
|
||||
src/backend/malformed_policy_exception.cc \
|
||||
|
@ -278,7 +277,6 @@ pkginclude_HEADERS += \
|
|||
src/backend/sgpemv2/global_preferences.hh \
|
||||
src/backend/sgpemv2/history.hh \
|
||||
src/backend/sgpemv2/history_observer.hh \
|
||||
src/backend/sgpemv2/holt_graph.hh \
|
||||
src/backend/sgpemv2/invalid_plugin_exception.hh \
|
||||
src/backend/sgpemv2/key_file.hh \
|
||||
src/backend/sgpemv2/malformed_policy_exception.hh \
|
||||
|
|
|
@ -36,18 +36,31 @@
|
|||
|
||||
namespace sgpem
|
||||
{
|
||||
class PythonCPUPolicy;
|
||||
class PythonCPUPolicyManager;
|
||||
|
||||
/** \brief A specialization of abstract class Policy
|
||||
|
||||
Implements the Policy abstract class specified in the backend component to allow
|
||||
user-written Python policies to run.
|
||||
|
||||
This class represents a policy written in Python. Its methods interact with Python interpreter.
|
||||
See the documentation of class Policy for more detailed informations.
|
||||
*/
|
||||
class PythonCPUPolicy;
|
||||
|
||||
class PythonCPUPolicyManager;
|
||||
|
||||
class SG_DLLEXPORT PythonCPUPolicy : public CPUPolicy
|
||||
{
|
||||
public:
|
||||
|
||||
/// \brief Constructor taking the name of the policy.
|
||||
///
|
||||
/// Constructor taking the name of the policy.
|
||||
///
|
||||
/// \param name the name of the policy
|
||||
PythonCPUPolicy(const char* name) throw(MalformedPolicyException);
|
||||
|
||||
/// \brief Standard virtual destructor
|
||||
///
|
||||
virtual ~PythonCPUPolicy();
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
// src/backend/holt_graph.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 <sgpemv2/holt_graph.hh>
|
||||
|
||||
#include <sgpemv2/history.hh>
|
||||
#include <sgpemv2/process.hh>
|
||||
#include <sgpemv2/thread.hh>
|
||||
|
||||
using namespace sgpem;
|
||||
using namespace std;
|
||||
|
||||
void
|
||||
HoltGraph::update(const History& changed_history)
|
||||
{
|
||||
const Environment& env = changed_history.get_last_environment();
|
||||
const Environment::Processes& processes = env.get_processes();
|
||||
|
||||
_resources.clear();
|
||||
_active_threads.clear();
|
||||
_active_requests.clear();
|
||||
|
||||
for (unsigned int pi = 0; pi < processes.size(); ++pi)
|
||||
{
|
||||
vector<Thread*> threads = processes[pi]->get_threads();
|
||||
|
||||
for (unsigned int ti = 0; ti < threads.size(); ++ti)
|
||||
{
|
||||
vector<Request*> requests = threads[ti]->get_requests();
|
||||
|
||||
for (unsigned int ri = 0; ri < requests.size(); ++ri)
|
||||
{
|
||||
Request& r = *requests[ri];
|
||||
|
||||
if (r.get_state() == Request::state_allocated)
|
||||
{
|
||||
_active_requests.push_back(&r);
|
||||
_active_threads.insert(&r.get_thread());
|
||||
|
||||
vector<SubRequest*> subrequests = r.get_subrequests();
|
||||
|
||||
for (unsigned int sri = 0; sri < subrequests.size(); ++sri)
|
||||
{
|
||||
Environment::resource_key_t key = subrequests[sri]->get_resource_key();
|
||||
|
||||
_resources.insert(env.get_resources().find(key)->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HoltGraph::Resources
|
||||
HoltGraph::get_resources() const
|
||||
{
|
||||
return Resources(_resources.begin(), _resources.end());
|
||||
}
|
||||
|
||||
HoltGraph::Threads
|
||||
HoltGraph::get_active_threads() const
|
||||
{
|
||||
return Threads(_active_threads.begin(), _active_threads.end());
|
||||
}
|
||||
|
||||
HoltGraph::Requests
|
||||
HoltGraph::get_active_requests() const
|
||||
{
|
||||
return _active_requests;
|
||||
}
|
||||
|
|
@ -25,3 +25,13 @@ using namespace sgpem;
|
|||
Schedulable::~Schedulable()
|
||||
{}
|
||||
|
||||
unsigned int Schedulable::get_remaining_time() const
|
||||
{
|
||||
assert(get_total_cpu_time() >= get_elapsed_time());
|
||||
return get_total_cpu_time() - get_elapsed_time();
|
||||
}
|
||||
|
||||
int Schedulable::get_priority_push() const
|
||||
{
|
||||
return get_current_priority() - get_base_priority();
|
||||
}
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
// src/backend/holt_graph.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 HOLT_GRAPH_HH
|
||||
#define HOLT_GRAPH_HH 1
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class Resource;
|
||||
class Thread;
|
||||
class Request;
|
||||
}
|
||||
|
||||
#include <sgpemv2/history_observer.hh>
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class HoltGraph;
|
||||
|
||||
class SG_DLLEXPORT HoltGraph : public HistoryObserver
|
||||
{
|
||||
public:
|
||||
typedef std::vector<const Resource*> Resources;
|
||||
typedef std::vector<const Thread*> Threads;
|
||||
typedef std::vector<const Request*> Requests;
|
||||
|
||||
HoltGraph();
|
||||
|
||||
virtual void update(const History& changed_history);
|
||||
|
||||
Resources get_resources() const;
|
||||
Threads get_active_threads() const;
|
||||
Requests get_active_requests() const;
|
||||
|
||||
private:
|
||||
std::set<const Resource*> _resources;
|
||||
std::set<const Thread*> _active_threads;
|
||||
Requests _active_requests;
|
||||
}
|
||||
; // class HistoryObserver
|
||||
|
||||
}//~ namespace sgpem
|
||||
|
||||
#endif //HOLT_GRAPH_HH
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// src/backend/schedulable.hh - Copyright 2005, 2006, University
|
||||
// src/backend/sgpemv2/schedulable.hh - Copyright 2005, 2006, University
|
||||
// of Padova, dept. of Pure and Applied
|
||||
// Mathematics
|
||||
//
|
||||
|
@ -27,19 +27,28 @@
|
|||
|
||||
namespace sgpem
|
||||
{
|
||||
/// \brief Represents a schedulable entity within the simulated system.
|
||||
///
|
||||
/// Represents a schedulable entity within the simulated system.
|
||||
/// Real world schedulable entities are, for example: batch jobs, processes
|
||||
/// threads, fibers.
|
||||
/// This class factors out some of their features.
|
||||
///
|
||||
/// This is an abstract class. Known subclasses are ::Process, and ::Thread
|
||||
class Schedulable;
|
||||
|
||||
class SerializeVisitor;
|
||||
|
||||
class SG_DLLEXPORT Schedulable
|
||||
{
|
||||
public:
|
||||
/** \brief This flag describes the actual state of the schedulable
|
||||
*
|
||||
* You can think of this flag as the particular stack in the OS where the
|
||||
* process are placed during their lifetime. In the OS there are three
|
||||
* main stacks that are Running processes, Read processes, and Blocked
|
||||
* processes. These are emulated in a single list by this flag.
|
||||
*/
|
||||
|
||||
/// \brief This flag describes the actual state of the schedulable.
|
||||
///
|
||||
/// You can think of this flag as the particular stack in the OS where the
|
||||
/// process are placed during their lifetime. In the OS there are three
|
||||
/// main stacks that are Running processes, Read processes, and Blocked
|
||||
/// processes. These are emulated in a single list by this flag.
|
||||
enum state
|
||||
{
|
||||
state_running = 1 << 0,
|
||||
|
@ -49,30 +58,174 @@ namespace sgpem
|
|||
state_terminated = 1 << 4
|
||||
};
|
||||
|
||||
/// \brief Virtual destructor
|
||||
///
|
||||
/// Abstract virtual destructor
|
||||
virtual ~Schedulable() = 0;
|
||||
|
||||
/// \brief Redefined operator equals (static equality).
|
||||
///
|
||||
/// Redefined operator equals.
|
||||
/// By design, a Schedulable entity equals an other schedulable entity
|
||||
/// when their static (respect to the simulation) properties are equal.
|
||||
/// This means, for example, that the priority push does not count when
|
||||
/// determining equality, nor state, last aquisition and last release
|
||||
/// time and elapsed time do count.
|
||||
/// \param op2 the Schedulable to compare this with.
|
||||
/// \return true if the Schedulable equal, false otherwise.
|
||||
virtual bool operator==(const Schedulable& op2) const = 0;
|
||||
|
||||
|
||||
/// \brief Returns the name of the Schedulable.
|
||||
///
|
||||
/// Returns the name of the Schedulable.
|
||||
/// \return the name of the Schedulable.
|
||||
virtual Glib::ustring get_name() const = 0;
|
||||
|
||||
/// \brief Returns the arrival time of the Schedulable.
|
||||
///
|
||||
/// Returns the arrival time of the Schedulable.
|
||||
/// The arrival time is the instant of the simulation when
|
||||
/// the state of the Schedulable is switched from future to
|
||||
/// ready.
|
||||
///
|
||||
/// The arrival time is a static (respect to the simulation) property.
|
||||
/// \return the arrival time of of the Schedulable.
|
||||
virtual unsigned int get_arrival_time() const = 0;
|
||||
|
||||
/// \brief Returns the elapsed time of the Schedulable.
|
||||
///
|
||||
/// Returns the elapsed time of the Schedulable.
|
||||
/// The elapsed time is the amount of time a Schedulable has been running
|
||||
/// until the current instant.
|
||||
///
|
||||
/// The elapsed time is a dynamic (respect to the simulation) property.
|
||||
/// \return the elapsed time of of the Schedulable.
|
||||
virtual unsigned int get_elapsed_time() const = 0;
|
||||
|
||||
/// \brief Returns the remaining time of the Schedulable.
|
||||
///
|
||||
/// Returns the remaining time of the Schedulable.
|
||||
/// The remaining time is the remaining amount of time a Schedulable
|
||||
/// before its termination.
|
||||
///
|
||||
/// It is defined as the difference between the total required CPU time
|
||||
/// and the current elapsed CPU time.
|
||||
///
|
||||
/// The remaining time is a dynamic (respect to the simulation) property.
|
||||
/// \return the remaining time of of the Schedulable.
|
||||
virtual unsigned int get_remaining_time() const;
|
||||
|
||||
/// \brief Returns the last aquisition instant of the Schedulable.
|
||||
///
|
||||
/// Returns the last aquisition instant of the Schedulable.
|
||||
/// The last aquisition instant of a Schedulable is the last instant at witch
|
||||
/// its state changed from anything but "running" to "running", i.e. when it
|
||||
/// received the cpu.
|
||||
///
|
||||
/// Its dual feature is the last release instant.
|
||||
///
|
||||
/// The last aquisition instant is a dynamic (respect to the simulation) property.
|
||||
/// \return the last aquisition instant of of the Schedulable.
|
||||
virtual int get_last_acquisition() const = 0;
|
||||
|
||||
/// \brief Returns the last release instant of the Schedulable.
|
||||
///
|
||||
/// Returns the last release instant of the Schedulable.
|
||||
/// The last release instant of a Schedulable is the last instant at witch
|
||||
/// its state changed from "running" to anything but "running", i.e. when it
|
||||
/// abandoned the cpu.
|
||||
///
|
||||
/// Its dual feature is the last aquisition instant.
|
||||
///
|
||||
/// The last release instant is a dynamic (respect to the simulation) property.
|
||||
/// \return the last release instant of of the Schedulable.
|
||||
virtual int get_last_release() const = 0;
|
||||
|
||||
/// \brief Returns the base priority of the Schedulable.
|
||||
///
|
||||
/// Returns the base priority of the Schedulable.
|
||||
/// The base priority of a Schedulable is an indicator of the importance of
|
||||
/// the Schedulable. Priority-sensitive policies usually give better services
|
||||
/// to more important Schedulables.
|
||||
///
|
||||
/// Base priority is summed to the priority push to obtain the current priority
|
||||
/// of the schedulable, which is the real parameter policies read.
|
||||
///
|
||||
/// The base priority is a static (respect to the simulation) property.
|
||||
/// \return the base priority of of the Schedulable.
|
||||
virtual int get_base_priority() const = 0;
|
||||
|
||||
/// \brief Returns the total required CPU time of the Schedulable.
|
||||
///
|
||||
/// Returns the total required CPU time of the Schedulable.
|
||||
/// The total required CPU time is the time the Schedulable needs to
|
||||
/// complete its work.
|
||||
///
|
||||
/// When a Schedulable's elapsed CPU time equals the total required CPU time
|
||||
/// its state is set to "terminated".
|
||||
///
|
||||
/// The total required CPU time is a static (respect to the simulation) property.
|
||||
/// \return the total required CPU time of of the Schedulable.
|
||||
virtual unsigned int get_total_cpu_time() const = 0;
|
||||
|
||||
/// \brief Returns the current priority of the Schedulable.
|
||||
///
|
||||
/// Returns the current priority of the Schedulable.
|
||||
/// The current priority of a Schedulable is an indicator of the importance of
|
||||
/// the Schedulable. Priority-sensitive policies usually give better services
|
||||
/// to more important Schedulables.
|
||||
///
|
||||
/// Base priority is summed to the priority push to obtain the current priority
|
||||
/// of the schedulable, which is the real parameter policies read.
|
||||
///
|
||||
/// The current priority is a dynamic (respect to the simulation) property.
|
||||
/// \return the dynamic priority of of the Schedulable.
|
||||
virtual int get_current_priority() const = 0;
|
||||
|
||||
/// \brief Returns the current priority push of the Schedulable.
|
||||
///
|
||||
/// Returns the current priority push of the Schedulable.
|
||||
/// The current priority push of a Schedulable is an indicator of the local
|
||||
/// importance of the Schedulable. Priority-sensitive policies usually give
|
||||
/// better services to more important Schedulables.
|
||||
///
|
||||
/// Base priority is summed to the priority push to obtain the current priority
|
||||
/// of the schedulable, which is the real parameter policies read.
|
||||
///
|
||||
/// The priority push is a dynamic (respect to the simulation) property.
|
||||
/// \return the current priority push of of the Schedulable.
|
||||
virtual int get_priority_push() const;
|
||||
|
||||
/// \brief Sets the priority push of the Schedulable, returning the old one.
|
||||
///
|
||||
/// Sets the current priority push of the Schedulable.
|
||||
/// The current priority push of a Schedulable is an indicator of the local
|
||||
/// importance of the Schedulable. Priority-sensitive policies usually give
|
||||
/// better services to more important Schedulables.
|
||||
///
|
||||
/// Base priority is summed to the priority push to obtain the current priority
|
||||
/// of the schedulable, which is the real parameter policies read.
|
||||
///
|
||||
/// The priority push is a dynamic (respect to the simulation) property.
|
||||
/// \param new_value the new push to be set.
|
||||
/// \return the old priority push of of the Schedulable.
|
||||
virtual int set_priority_push(int new_value = 0) = 0;
|
||||
|
||||
/// \brief Returns the current state of the Schedulable.
|
||||
///
|
||||
/// Returns the current state of the Schedulable.
|
||||
/// The current state of a Schedulable describes the role of the process within
|
||||
/// the system at the current instant. See Schedulable::state for the possible
|
||||
/// states of a schedulable.
|
||||
///
|
||||
/// The current state is a dynamic (respect to the simulation) property.
|
||||
/// \return the current state of of the Schedulable.
|
||||
virtual state get_state() const = 0;
|
||||
|
||||
/// \brief Serializes this entity using a visitor pattern.
|
||||
///
|
||||
/// \param translator the visitor used to serialize this entity.
|
||||
virtual void serialize(SerializeVisitor& translator) const = 0;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue