2006-02-19 23:25:23 +01:00
|
|
|
%module sgpem
|
|
|
|
%{
|
2006-02-20 20:10:16 +01:00
|
|
|
#include "policy.hh"
|
2006-02-19 23:25:23 +01:00
|
|
|
#include "policy_parameters.hh"
|
2006-06-13 15:55:47 +02:00
|
|
|
#include "static_schedulable.hh"
|
2006-06-03 17:19:13 +02:00
|
|
|
#include "schedulable_queue.hh"
|
2006-06-13 18:37:57 +02:00
|
|
|
#include "dynamic_schedulable.hh"
|
2006-02-21 23:57:14 +01:00
|
|
|
#include "scheduler.hh"
|
2006-02-19 23:25:23 +01:00
|
|
|
%}
|
|
|
|
|
2006-02-21 08:39:39 +01:00
|
|
|
/* NOTE : passing Unicode strings to C++ methods calling them
|
|
|
|
* from Python results in a SIGSEGV. You've been warned!
|
|
|
|
* (Investigate if this can be fixed, else please report it in
|
|
|
|
* the sgpem user manual)
|
|
|
|
*/
|
|
|
|
|
2006-02-23 22:50:43 +01:00
|
|
|
/** Due to the relatively new support for namespaces in SWIG,
|
|
|
|
* make sure to include the full visibility signature when
|
|
|
|
* returning / passing parameters from / to functions with
|
|
|
|
* objects different to the one you're declaring.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace std {
|
|
|
|
class exception {
|
|
|
|
public:
|
|
|
|
virtual const char* what() const throw();
|
|
|
|
private:
|
|
|
|
exception();
|
|
|
|
};
|
|
|
|
|
|
|
|
class runtime_error : public std::exception {
|
|
|
|
public:
|
|
|
|
virtual const char* what() const throw();
|
|
|
|
private:
|
|
|
|
runtime_error();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2006-02-19 23:25:23 +01:00
|
|
|
namespace sgpem {
|
|
|
|
|
2006-06-09 18:51:53 +02:00
|
|
|
/** Don't get worried, order is not important! */
|
|
|
|
enum policy_sorts_type { policy_sorts_threads, policy_sorts_processes };
|
|
|
|
|
2006-02-20 20:10:16 +01:00
|
|
|
class Policy {
|
|
|
|
public:
|
|
|
|
virtual ~Policy() = 0;
|
2006-02-23 22:50:43 +01:00
|
|
|
sgpem::PolicyParameters& get_parameters();
|
2006-02-20 20:10:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
class PolicyParametersException : public std::runtime_error {
|
|
|
|
public:
|
|
|
|
PolicyParametersException(char* msg);
|
2006-02-21 08:39:39 +01:00
|
|
|
%rename (__str__) what;
|
|
|
|
virtual const char* what();
|
2006-02-20 20:10:16 +01:00
|
|
|
}; //~ class PolicyParametersException
|
2006-02-19 23:25:23 +01:00
|
|
|
|
2006-02-20 20:10:16 +01:00
|
|
|
// --------------------------------------------
|
|
|
|
class PolicyParameters
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//methods to CREATE PARAMETERS
|
|
|
|
// (rewrapped correctly for SWIG usage)
|
|
|
|
%ignore register_int(const Glib::ustring&, const int&,
|
|
|
|
const int&, const bool&, const int&);
|
|
|
|
%ignore register_float(const Glib::ustring&, const float&,
|
|
|
|
const float&, const bool&, const float&);
|
|
|
|
%ignore register_string(const Glib::ustring&, const bool&,
|
|
|
|
const char*);
|
|
|
|
|
|
|
|
%extend {
|
|
|
|
void register_int(const char* name,
|
|
|
|
const int& lower_bound,
|
|
|
|
const int& upper_bound,
|
|
|
|
const bool& required,
|
|
|
|
const int& default_value = 0)
|
|
|
|
{
|
2006-02-21 08:39:39 +01:00
|
|
|
self->register_int(name, lower_bound, upper_bound,
|
2006-02-20 20:10:16 +01:00
|
|
|
required, default_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void register_float(const char* name,
|
|
|
|
const float& lower_bound,
|
|
|
|
const float& upper_bound,
|
|
|
|
const bool& required,
|
|
|
|
const float& default_value = 0.0f)
|
|
|
|
{
|
2006-02-21 08:39:39 +01:00
|
|
|
self->register_float(name, lower_bound, upper_bound,
|
2006-02-20 20:10:16 +01:00
|
|
|
required, default_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void register_string(const char* name,
|
|
|
|
const bool& required,
|
|
|
|
const char* default_value = "")
|
|
|
|
{
|
2006-02-21 08:39:39 +01:00
|
|
|
self->register_string(name, required, default_value);
|
2006-02-20 20:10:16 +01:00
|
|
|
}
|
|
|
|
}
|
2006-02-19 23:25:23 +01:00
|
|
|
|
2006-02-20 20:10:16 +01:00
|
|
|
//methods to SET the VALUE of PARAMETERS
|
|
|
|
// (rewrapped correctly for SWIG usage)
|
|
|
|
%ignore set_int(const Glib::ustring&, const int&);
|
|
|
|
%ignore set_float(const Glib::ustring&, const float&);
|
|
|
|
%ignore set_string(const Glib::ustring&, const Glib::ustring&);
|
2006-02-19 23:25:23 +01:00
|
|
|
|
2006-02-20 20:10:16 +01:00
|
|
|
%extend {
|
|
|
|
bool set_int(const char* name, const int& value)
|
2006-02-21 08:39:39 +01:00
|
|
|
{ return self->set_int(name, value); }
|
2006-02-20 20:10:16 +01:00
|
|
|
bool set_float(const char* name, const float& value)
|
2006-02-21 08:39:39 +01:00
|
|
|
{ return self->set_float(name, value); }
|
2006-02-20 20:10:16 +01:00
|
|
|
bool set_string(const char* name, const char* value)
|
2006-02-21 08:39:39 +01:00
|
|
|
{ return self->set_string(name, value); }
|
2006-02-20 20:10:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//methods to GET the VALUE of PARAMETERS
|
|
|
|
// (rewrapped correctly for SWIG usage)
|
|
|
|
%ignore get_int(const Glib::ustring&) const;
|
|
|
|
%ignore get_float(const Glib::ustring&) const;
|
|
|
|
%ignore get_string(const Glib::ustring&) const;
|
2006-02-19 23:25:23 +01:00
|
|
|
|
2006-02-20 20:10:16 +01:00
|
|
|
%extend {
|
|
|
|
int get_int(const char* name) const
|
2006-02-21 08:39:39 +01:00
|
|
|
{ return self->get_int(name); }
|
2006-02-20 20:10:16 +01:00
|
|
|
float get_float(const char* name) const
|
2006-02-21 08:39:39 +01:00
|
|
|
{ return self->get_float(name); }
|
2006-02-20 20:10:16 +01:00
|
|
|
const char* get_string(const char* name) const
|
2006-02-21 08:39:39 +01:00
|
|
|
{ return self->get_string(name).c_str(); }
|
2006-02-20 20:10:16 +01:00
|
|
|
}
|
2006-02-19 23:25:23 +01:00
|
|
|
|
2006-02-20 20:10:16 +01:00
|
|
|
}; //~ class PolicyParameters
|
|
|
|
|
|
|
|
// --------------------------------------------
|
2006-06-23 15:06:39 +02:00
|
|
|
class Schedulable
|
2006-02-20 20:10:16 +01:00
|
|
|
{
|
|
|
|
public:
|
2006-06-23 15:06:39 +02:00
|
|
|
virtual ~Schedulable() = 0;
|
|
|
|
|
|
|
|
enum state
|
|
|
|
{
|
|
|
|
state_running = 1<<0,
|
|
|
|
state_ready = 1<<1,
|
|
|
|
state_blocked = 1<<2,
|
|
|
|
state_future = 1<<3,
|
|
|
|
state_terminated = 1<<4
|
|
|
|
};
|
2006-02-19 23:25:23 +01:00
|
|
|
|
2006-06-23 15:06:39 +02:00
|
|
|
virtual unsigned int get_arrival_time() const = 0;
|
|
|
|
virtual unsigned int get_remaining_time() const = 0;
|
|
|
|
virtual int get_base_priority() const = 0;
|
|
|
|
virtual int get_current_priority() const = 0;
|
|
|
|
virtual unsigned int get_total_cpu_time() const = 0;
|
|
|
|
virtual state get_state() const = 0;
|
|
|
|
|
|
|
|
%ignore Schedulable::get_name() const;
|
|
|
|
%extend {
|
|
|
|
const char* get_name() const
|
2006-02-24 10:02:32 +01:00
|
|
|
{ return self->get_name().c_str(); }
|
2006-06-23 15:06:39 +02:00
|
|
|
}
|
|
|
|
}; //~ class Schedulable
|
2006-02-20 20:10:16 +01:00
|
|
|
|
2006-02-19 23:25:23 +01:00
|
|
|
|
2006-02-20 20:10:16 +01:00
|
|
|
// --------------------------------------------
|
2006-06-03 16:40:19 +02:00
|
|
|
class SchedulableQueue
|
2006-02-20 20:10:16 +01:00
|
|
|
{
|
|
|
|
public:
|
2006-02-23 11:12:27 +01:00
|
|
|
unsigned int size() const;
|
2006-06-23 15:06:39 +02:00
|
|
|
const sgpem::Schedulable* get_item_at(const unsigned int&) const;
|
2006-02-22 22:35:26 +01:00
|
|
|
void swap(unsigned int positionA, unsigned int positionB) throw();
|
2006-02-21 08:39:39 +01:00
|
|
|
|
2006-02-20 20:10:16 +01:00
|
|
|
private:
|
|
|
|
// Avoid instantiation and copy
|
2006-06-03 16:40:19 +02:00
|
|
|
SchedulableQueue();
|
|
|
|
SchedulableQueue(const SchedulableQueue&);
|
|
|
|
SchedulableQueue& operator=(const SchedulableQueue&);
|
|
|
|
~SchedulableQueue();
|
2006-02-20 20:10:16 +01:00
|
|
|
}; //~ class Schedulable
|
2006-02-19 23:25:23 +01:00
|
|
|
|
2006-06-23 15:06:39 +02:00
|
|
|
// ---------------------------------------------
|
|
|
|
class Scheduler {
|
|
|
|
public:
|
|
|
|
sgpem::Policy& get_policy();
|
|
|
|
static sgpem::Scheduler& get_instance();
|
|
|
|
sgpem::SchedulableQueue* get_ready_queue();
|
|
|
|
private:
|
|
|
|
Scheduler();
|
|
|
|
~Scheduler();
|
2006-02-20 20:10:16 +01:00
|
|
|
};
|
2006-02-21 23:57:14 +01:00
|
|
|
|
2006-02-19 23:25:23 +01:00
|
|
|
} //~ namespace sgpem
|