- Add initial layout for further builtin policies (needs
to be expanded / fixed) git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@363 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
b788ebab4b
commit
7d58c965ff
|
@ -296,8 +296,8 @@ noinst_HEADERS += \
|
|||
# ############################################################
|
||||
|
||||
# built-in policies
|
||||
pyc_PYTHON = # fcfs.py rr.py rr-p.py ...
|
||||
|
||||
pyc_PYTHON = \
|
||||
src/builtin-policies/fcfs.py
|
||||
|
||||
# ############################################################
|
||||
#
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
from sgpem import SchedulableList, PolicyParameters
|
||||
import sgpem
|
||||
from Abstract import *
|
||||
|
||||
class Policy:
|
||||
class Policy(sgpem.Policy):
|
||||
## @var Avoid instantiation of an abstract class
|
||||
__metaclass__ = Metaclass
|
||||
|
||||
|
@ -10,4 +10,3 @@ class Policy:
|
|||
sort_queue = AbstractMethod('sort_queue')
|
||||
is_preemptive = AbstractMethod('is_preemptive')
|
||||
is_time_sliced = AbstractMethod('is_time_sliced')
|
||||
get_parameters = AbstractMethod('get_parameters')
|
||||
|
|
|
@ -31,33 +31,28 @@
|
|||
|
||||
namespace sgpem
|
||||
{
|
||||
class SchedulableList;
|
||||
|
||||
class SchedulableList;
|
||||
class SG_DLLEXPORT SchedulableList
|
||||
{
|
||||
public:
|
||||
SchedulableList();
|
||||
bool operator==(const SchedulableList&) const;
|
||||
bool has_same_objects(const SchedulableList& dx) const;
|
||||
|
||||
|
||||
|
||||
class SG_DLLEXPORT SchedulableList
|
||||
{
|
||||
public:
|
||||
SchedulableList();
|
||||
bool operator==(const SchedulableList&) const;
|
||||
bool has_same_objects(const SchedulableList& dx) const;
|
||||
|
||||
sgpem::SchedulableStatus* top();
|
||||
sgpem::SchedulableStatus* bottom();
|
||||
void add_at_bottom(const sgpem::SchedulableStatus&);
|
||||
void add_at_top(const sgpem::SchedulableStatus&);
|
||||
memory::smart_ptr<sgpem::SchedulableStatus> remove(const uint& position);
|
||||
bool insert_at(const uint&, const uint&);
|
||||
uint size() const;
|
||||
SchedulableStatus* get_item_at(const uint&);
|
||||
const SchedulableStatus* get_item_at(const uint&) const;
|
||||
void clear();
|
||||
|
||||
private:
|
||||
|
||||
std::list<sgpem::SchedulableStatus> _list;
|
||||
};
|
||||
sgpem::SchedulableStatus* top();
|
||||
sgpem::SchedulableStatus* bottom();
|
||||
void add_at_bottom(const sgpem::SchedulableStatus&);
|
||||
void add_at_top(const sgpem::SchedulableStatus&);
|
||||
memory::smart_ptr<sgpem::SchedulableStatus> remove(const uint& position);
|
||||
bool insert_at(const uint&, const uint&);
|
||||
uint size() const;
|
||||
SchedulableStatus* get_item_at(const uint&);
|
||||
const SchedulableStatus* get_item_at(const uint&) const;
|
||||
void clear();
|
||||
private:
|
||||
std::list<SchedulableStatus> _list;
|
||||
};
|
||||
|
||||
}//~ namespace sgpem
|
||||
|
||||
|
|
|
@ -39,14 +39,14 @@ namespace sgpem
|
|||
class SG_DLLEXPORT SchedulableStatus
|
||||
{
|
||||
public:
|
||||
enum state
|
||||
{
|
||||
state_running,
|
||||
state_ready,
|
||||
state_blocked,
|
||||
state_future,
|
||||
state_terminated
|
||||
};
|
||||
enum state
|
||||
{
|
||||
state_running = 1<<0,
|
||||
state_ready = 1<<1,
|
||||
state_blocked = 1<<2,
|
||||
state_future = 1<<3,
|
||||
state_terminated = 1<<4
|
||||
};
|
||||
|
||||
|
||||
SchedulableStatus(const Schedulable& obj);
|
||||
|
|
|
@ -7,6 +7,12 @@
|
|||
#include "schedulable_status.hh"
|
||||
%}
|
||||
|
||||
/* 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)
|
||||
*/
|
||||
|
||||
namespace sgpem {
|
||||
|
||||
class Policy {
|
||||
|
@ -19,7 +25,8 @@ namespace sgpem {
|
|||
class PolicyParametersException : public std::runtime_error {
|
||||
public:
|
||||
PolicyParametersException(char* msg);
|
||||
%rename (__str__) what();
|
||||
%rename (__str__) what;
|
||||
virtual const char* what();
|
||||
}; //~ class PolicyParametersException
|
||||
|
||||
// --------------------------------------------
|
||||
|
@ -42,8 +49,7 @@ namespace sgpem {
|
|||
const bool& required,
|
||||
const int& default_value = 0)
|
||||
{
|
||||
self->register_int(Glib::ustring(name),
|
||||
lower_bound, upper_bound,
|
||||
self->register_int(name, lower_bound, upper_bound,
|
||||
required, default_value);
|
||||
}
|
||||
|
||||
|
@ -53,8 +59,7 @@ namespace sgpem {
|
|||
const bool& required,
|
||||
const float& default_value = 0.0f)
|
||||
{
|
||||
self->register_float(Glib::ustring(name),
|
||||
lower_bound, upper_bound,
|
||||
self->register_float(name, lower_bound, upper_bound,
|
||||
required, default_value);
|
||||
}
|
||||
|
||||
|
@ -62,9 +67,7 @@ namespace sgpem {
|
|||
const bool& required,
|
||||
const char* default_value = "")
|
||||
{
|
||||
self->register_string(Glib::ustring(name),
|
||||
required,
|
||||
Glib::ustring(default_value));
|
||||
self->register_string(name, required, default_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,11 +79,11 @@ namespace sgpem {
|
|||
|
||||
%extend {
|
||||
bool set_int(const char* name, const int& value)
|
||||
{ return self->set_int(Glib::ustring(name), value); }
|
||||
{ return self->set_int(name, value); }
|
||||
bool set_float(const char* name, const float& value)
|
||||
{ return self->set_float(Glib::ustring(name), value); }
|
||||
{ return self->set_float(name, value); }
|
||||
bool set_string(const char* name, const char* value)
|
||||
{ return self->set_string(Glib::ustring(name), value); }
|
||||
{ return self->set_string(name, value); }
|
||||
}
|
||||
|
||||
//methods to GET the VALUE of PARAMETERS
|
||||
|
@ -91,11 +94,11 @@ namespace sgpem {
|
|||
|
||||
%extend {
|
||||
int get_int(const char* name) const
|
||||
{ return self->get_int(Glib::ustring(name)); }
|
||||
{ return self->get_int(name); }
|
||||
float get_float(const char* name) const
|
||||
{ return self->get_float(Glib::ustring(name)); }
|
||||
{ return self->get_float(name); }
|
||||
const char* get_string(const char* name) const
|
||||
{ return self->get_string(Glib::ustring(name)).c_str(); }
|
||||
{ return self->get_string(name).c_str(); }
|
||||
}
|
||||
|
||||
}; //~ class PolicyParameters
|
||||
|
@ -132,21 +135,21 @@ namespace sgpem {
|
|||
private:
|
||||
// Avoid instantiation and copy
|
||||
SchedulableList();
|
||||
SchedulableList(const SchedulableList& );
|
||||
SchedulableList(const SchedulableList&);
|
||||
SchedulableList& operator=(const SchedulableList&);
|
||||
}; //~ class Schedulable
|
||||
|
||||
|
||||
// ---------------------------------------------
|
||||
class SchedulableStatus
|
||||
{
|
||||
public:
|
||||
enum state
|
||||
{
|
||||
state_running,
|
||||
state_ready,
|
||||
state_blocked,
|
||||
state_future,
|
||||
state_terminated
|
||||
state_running = 1<<0,
|
||||
state_ready = 1<<1,
|
||||
state_blocked = 1<<2,
|
||||
state_future = 1<<3,
|
||||
state_terminated = 1<<4
|
||||
};
|
||||
|
||||
SchedulableStatus(const SchedulableStatus& obj);
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
from Policy import Policy
|
||||
|
||||
##### Typical session : #######
|
||||
###############################
|
||||
# cd [...]/share/sgpemv2/policies
|
||||
# python
|
||||
# >>> import sys
|
||||
# >>> sys.path[:0] = [ '../modules' ]
|
||||
# >>> import fcfs
|
||||
# >>> p = fcfs.fcfs_policy()
|
||||
# >>> par = p.get_parameters()
|
||||
# Segmentation fault
|
||||
# (this makes sense...)
|
||||
###############################
|
||||
|
||||
class fcfs_policy(Policy) :
|
||||
def __init__(self):
|
||||
pass;
|
||||
|
||||
def configure(self):
|
||||
pass;
|
||||
|
||||
def is_preemptive(self):
|
||||
return False
|
||||
|
||||
def is_time_sliced(self):
|
||||
return False
|
||||
|
||||
def sort_queue(self, event, queue):
|
||||
# How am I supposed to sort that mess??
|
||||
# FIXME
|
||||
return queue
|
Loading…
Reference in New Issue