Documented history.hh, policy.hh, policy_manager.hh, slice.hh - ps
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@419 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
3a38a2d3a6
commit
02e69f9214
|
@ -50,20 +50,50 @@ namespace sgpem
|
||||||
class SG_DLLEXPORT History : public ObservedSubject
|
class SG_DLLEXPORT History : public ObservedSubject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
Gets the \ref Schedulable object running at the specified time.
|
||||||
|
\param time The inquired time instant.
|
||||||
|
\return The Schedulable object running at the given time.
|
||||||
|
*/
|
||||||
|
memory::smart_ptr<sgpem::SchedulableStatus> get_scheduled_at(int time) const;
|
||||||
|
|
||||||
memory::smart_ptr<sgpem::SchedulableStatus> get_scheduled_at(int time) const;
|
/**
|
||||||
memory::smart_ptr<sgpem::SchedulableList> get_simulation_status_at(int time) const;
|
Gets the status of simulation at the specified time.
|
||||||
int get_current_time() const;
|
\param time The inquired time instant.
|
||||||
void enqueue_slice(const sgpem::SchedulableList& status);
|
\return The list of Schedulable status objects at the specified time.
|
||||||
void truncate_at(int instant);
|
*/
|
||||||
|
memory::smart_ptr<sgpem::SchedulableList> get_simulation_status_at(int time) const;
|
||||||
|
|
||||||
static History& get_instance();
|
/**
|
||||||
|
Gets the current time.
|
||||||
|
\return The current history time.
|
||||||
|
*/
|
||||||
|
int get_current_time() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the status of simulation at the current time.
|
||||||
|
\param status The list of \ref Schedulable status objects at the current time.
|
||||||
|
*/
|
||||||
|
void enqueue_slice(const sgpem::SchedulableList& status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Remove all data in History following the specified time.
|
||||||
|
\param instant Desired cutting time.
|
||||||
|
*/
|
||||||
|
void truncate_at(int instant);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the only instance of History.
|
||||||
|
\return The Singleton instance of this object.
|
||||||
|
*/
|
||||||
|
static History& get_instance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
History(int); //private constructor. The parameter is discarded
|
History(int); //private constructor. The parameter is discarded
|
||||||
static History _instance;
|
static History _instance;
|
||||||
int _total_time_elapsed;
|
int _total_time_elapsed;
|
||||||
std::vector<sgpem::Slice> _slices;
|
std::vector<sgpem::Slice> _slices;
|
||||||
};
|
};
|
||||||
|
|
||||||
}//~ namespace sgpem
|
}//~ namespace sgpem
|
||||||
|
|
|
@ -34,28 +34,92 @@ namespace sgpem
|
||||||
|
|
||||||
class Policy;
|
class Policy;
|
||||||
|
|
||||||
/** \brief
|
/** \brief
|
||||||
e' una Strategy che rappresenta un algoritmo di scheduling che implementa una politica
|
It's a Strategy wich stay for a scheduling algorithm.
|
||||||
di scheduling.
|
It implements the related scheduling policy.
|
||||||
*/
|
Its goal is, usually, to keep a list of Schedulable objects
|
||||||
|
mantained in a SchedulableQueue.
|
||||||
|
*/
|
||||||
class SG_DLLEXPORT Policy
|
class SG_DLLEXPORT Policy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~Policy();
|
virtual ~Policy();
|
||||||
|
|
||||||
virtual void configure() = 0;
|
/**
|
||||||
virtual void sort_queue(Scheduler::event) const = 0;
|
Initialize the inner components of the policy.
|
||||||
int get_id() const;
|
|
||||||
virtual Glib::ustring get_description() const = 0;
|
|
||||||
virtual bool is_pre_emptive() const = 0;
|
|
||||||
virtual int get_time_slice() const = 0;
|
|
||||||
virtual void set_time_slice(const int&) = 0;
|
|
||||||
|
|
||||||
PolicyParameters& get_parameters();
|
Because it's a pure virtual method, must be re-implemented
|
||||||
|
in concrete derived classes.
|
||||||
|
*/
|
||||||
|
virtual void configure() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sort the \ref SchedulableQueue object that contain all the Schedulable objects
|
||||||
|
(Processes, Threads) still active managed by the scheduler.
|
||||||
|
|
||||||
|
Because it's a pure virtual method, must be re-implemented
|
||||||
|
in concrete derived classes.
|
||||||
|
\param event Call reason. Needed only by some scheduling policies.
|
||||||
|
*/
|
||||||
|
virtual void sort_queue(Scheduler::event event) const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the unique identifier (id) of this Policy.
|
||||||
|
\return The Policy id.
|
||||||
|
*/
|
||||||
|
int get_id() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Tell if this policy is preemptible.
|
||||||
|
If true, for the \ref Scheduler::SCHEDULABLE_ARRIVAL event, the
|
||||||
|
ready queue will contain also the running \ref Schedulable;
|
||||||
|
else the running Schedulable will not be in the queue.
|
||||||
|
|
||||||
|
Because it's a pure virtual method, must be re-implemented
|
||||||
|
in concrete derived classes.
|
||||||
|
\return True if this policy is preemptible.
|
||||||
|
*/
|
||||||
|
virtual bool is_pre_emptive() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets the time quantum for the policy.
|
||||||
|
|
||||||
|
Because it's a pure virtual method, must be re-implemented
|
||||||
|
in concrete derived classes.
|
||||||
|
\return Time quantum for the policy.
|
||||||
|
*/
|
||||||
|
virtual int get_time_slice() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the time quantum for the policy.
|
||||||
|
|
||||||
|
Because it's a pure virtual method, must be re-implemented
|
||||||
|
in concrete derived classes.
|
||||||
|
\param quantum The desired time quantum for the policy.
|
||||||
|
*/
|
||||||
|
virtual void set_time_slice(const int& quantum) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
PolicyParameters& get_parameters();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PolicyParameters _parameters;
|
PolicyParameters _parameters;
|
||||||
int _id;
|
int _id;
|
||||||
};
|
};
|
||||||
|
|
||||||
}//~ namespace sgpem
|
}//~ namespace sgpem
|
||||||
|
|
|
@ -25,16 +25,29 @@
|
||||||
|
|
||||||
#include "policy.hh"
|
#include "policy.hh"
|
||||||
|
|
||||||
|
|
||||||
namespace sgpem
|
namespace sgpem
|
||||||
{
|
{
|
||||||
class PolicyManager;
|
class PolicyManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
PolicyManager is the Abstract Factory for \ref Policy objects.
|
||||||
|
*/
|
||||||
class SG_DLLEXPORT PolicyManager
|
class SG_DLLEXPORT PolicyManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~PolicyManager() = 0;
|
virtual ~PolicyManager() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets THE policy (the only today) used.
|
||||||
|
Next versions will implement some other kind.
|
||||||
|
\return A reference to the policy.
|
||||||
|
*/
|
||||||
virtual Policy& get_policy() = 0;
|
virtual Policy& get_policy() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Init (or reset if yet initialized) the manager.
|
||||||
|
*/
|
||||||
virtual void init() = 0;
|
virtual void init() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,24 +32,50 @@ namespace sgpem
|
||||||
/** \brief Represents a slice of time during which some characteristic of the state of the simulation are constant
|
/** \brief Represents a slice of time during which some characteristic of the state of the simulation are constant
|
||||||
|
|
||||||
Represents a slice of time during which some characteristic of the state of the simulation are constant.
|
Represents a slice of time during which some characteristic of the state of the simulation are constant.
|
||||||
It holds a SimulationStatus object which can be accesse through getSimulationStatus()
|
It holds a \ref SimulationStatus object which can be accessed through getSimulationStatus()
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SG_DLLEXPORT Slice
|
class SG_DLLEXPORT Slice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
Constructor for Slice.
|
||||||
|
\param start The Slice's starting time.
|
||||||
|
\param duration Time length of Slice.
|
||||||
|
\param status Photoshot of all \ref Schedulable during this Slice.
|
||||||
|
*/
|
||||||
Slice(const int& start, const int& duration, const SchedulableList& status);
|
Slice(const int& start, const int& duration, const SchedulableList& status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets a constant reference to the \ref SchedulableList object for this Slice.
|
||||||
|
\return The reference (constant) to the SchedulableList object for this Slice.
|
||||||
|
*/
|
||||||
const SchedulableList* get_simulation_status() const;
|
const SchedulableList* get_simulation_status() const;
|
||||||
int get_started_at() const;
|
|
||||||
int get_duration() const;
|
|
||||||
void set_duration(const int&);
|
/**
|
||||||
|
Gets starting time of this Slice.
|
||||||
|
\return The starting time.
|
||||||
|
*/
|
||||||
|
int get_started_at() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets duration of this Slice.
|
||||||
|
\return The duration time.
|
||||||
|
*/
|
||||||
|
int get_duration() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets duration of this Slice.
|
||||||
|
\param duration The desired duration time.
|
||||||
|
*/
|
||||||
|
void set_duration(const int& duration);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SchedulableList _ref;
|
SchedulableList _ref;
|
||||||
int _started_at;
|
int _started_at;
|
||||||
int _duration;
|
int _duration;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //~ namespace sgpem
|
} //~ namespace sgpem
|
||||||
|
|
Loading…
Reference in New Issue