- Added DynamicThread class
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@649 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
0a2f37345f
commit
e95d915e3a
|
@ -146,6 +146,7 @@ src_backend_libbackend_la_LDFLAGS = \
|
||||||
src_backend_libbackend_la_SOURCES = \
|
src_backend_libbackend_la_SOURCES = \
|
||||||
src/backend/dynamic_process.cc \
|
src/backend/dynamic_process.cc \
|
||||||
src/backend/dynamic_schedulable.cc \
|
src/backend/dynamic_schedulable.cc \
|
||||||
|
src/backend/dynamic_thread.cc \
|
||||||
src/backend/global_preferences.cc \
|
src/backend/global_preferences.cc \
|
||||||
src/backend/history.cc \
|
src/backend/history.cc \
|
||||||
src/backend/observed_subject.cc \
|
src/backend/observed_subject.cc \
|
||||||
|
@ -169,6 +170,7 @@ pkginclude_HEADERS += \
|
||||||
config.h \
|
config.h \
|
||||||
src/backend/dynamic_process.hh \
|
src/backend/dynamic_process.hh \
|
||||||
src/backend/dynamic_schedulable.hh \
|
src/backend/dynamic_schedulable.hh \
|
||||||
|
src/backend/dynamic_thread.hh \
|
||||||
src/backend/global_preferences.hh \
|
src/backend/global_preferences.hh \
|
||||||
src/backend/history.hh \
|
src/backend/history.hh \
|
||||||
src/backend/observed_subject.hh \
|
src/backend/observed_subject.hh \
|
||||||
|
|
|
@ -0,0 +1,109 @@
|
||||||
|
// src/backend/dynamic_thread.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 "dynamic_thread.hh"
|
||||||
|
#include "static_thread.hh"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
using namespace sgpem;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
|
||||||
|
DynamicThread::DynamicThread(StaticThread* core, DynamicProcess* parent) :
|
||||||
|
DynamicSchedulable(*core), _state(state_future), _parent(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicThread::DynamicThread(const DynamicThread &other) :
|
||||||
|
Schedulable(), DynamicSchedulable(other), Thread()
|
||||||
|
{
|
||||||
|
typedef vector<DynamicRequest*>::iterator ReqIt;
|
||||||
|
|
||||||
|
const vector<DynamicRequest*>& other_req = other._dynamic_requests;
|
||||||
|
|
||||||
|
_state = other._state;
|
||||||
|
_parent = other._parent;
|
||||||
|
|
||||||
|
// FIXME uncomment me once requests are ready
|
||||||
|
// for(ReqIt it = other_req.begin(); it != other_req.end(); ++it)
|
||||||
|
// _dynamic_requests.push_back(new DynamicRequest(*(*it)));
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicProcess&
|
||||||
|
DynamicThread::get_process()
|
||||||
|
{
|
||||||
|
return *_parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
Schedulable::state
|
||||||
|
DynamicThread::get_state() const
|
||||||
|
{
|
||||||
|
return _state;
|
||||||
|
}
|
||||||
|
|
||||||
|
Schedulable::state
|
||||||
|
DynamicThread::set_state(state new_state)
|
||||||
|
{
|
||||||
|
state old_state = _state;
|
||||||
|
_state = new_state;
|
||||||
|
|
||||||
|
return old_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<Request*>
|
||||||
|
DynamicThread::get_requests()
|
||||||
|
{
|
||||||
|
// FIXME uncomment once requests are compelted
|
||||||
|
//return vector<Request*>(_dynamic_requests.begin(), _dynamic_requests.end());
|
||||||
|
return vector<Request*>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DynamicThread::remove_request(Request* request)
|
||||||
|
{
|
||||||
|
assert(request != NULL);
|
||||||
|
|
||||||
|
vector<DynamicRequest*>::iterator it;
|
||||||
|
|
||||||
|
// FIXME uncomment once requests are compelted
|
||||||
|
//it = std::find(_dynamic_requests.begin(), _dynamic_requests.end(), request);
|
||||||
|
|
||||||
|
//if(it != _dynamic_requests.end())
|
||||||
|
//{
|
||||||
|
// _dynamic_requests.erase(it);
|
||||||
|
// delete *it;
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DynamicThread::add_request(DynamicRequest* request)
|
||||||
|
{
|
||||||
|
assert(request != NULL);
|
||||||
|
|
||||||
|
_dynamic_requests.push_back(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DynamicThread::serialize(SerializeVisitor& translator) const
|
||||||
|
{
|
||||||
|
// TODO fill-in appropriate code
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
// src/backend/dynamic_thread.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 DYNAMIC_THREAD_HH
|
||||||
|
#define DYNAMIC_THREAD_HH 1
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "gettext.h"
|
||||||
|
#include "glibmm/ustring.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "thread.hh"
|
||||||
|
#include "dynamic_process.hh"
|
||||||
|
#include "../templates/smartp.hh"
|
||||||
|
#include "dynamic_schedulable.hh"
|
||||||
|
|
||||||
|
namespace sgpem
|
||||||
|
{
|
||||||
|
class DynamicThread;
|
||||||
|
class DynamicProcess;
|
||||||
|
class StaticThread;
|
||||||
|
class Request;
|
||||||
|
class DynamicRequest;
|
||||||
|
|
||||||
|
class SG_DLLEXPORT DynamicThread : public DynamicSchedulable, public Thread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DynamicThread(StaticThread* core, DynamicProcess* parent);
|
||||||
|
DynamicThread(const DynamicThread &other);
|
||||||
|
|
||||||
|
DynamicProcess& get_process();
|
||||||
|
|
||||||
|
state get_state() const;
|
||||||
|
|
||||||
|
state set_state(state new_state);
|
||||||
|
|
||||||
|
std::vector<Request*> get_requests();
|
||||||
|
|
||||||
|
void remove_request(Request* request);
|
||||||
|
|
||||||
|
void add_request(DynamicRequest* request);
|
||||||
|
|
||||||
|
void serialize(SerializeVisitor& translator) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
state _state;
|
||||||
|
std::vector<DynamicRequest*> _dynamic_requests;
|
||||||
|
DynamicProcess* _parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -19,7 +19,9 @@
|
||||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
#include "static_thread.hh"
|
#include "static_thread.hh"
|
||||||
|
|
||||||
using namespace sgpem;
|
using namespace sgpem;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
StaticThread::StaticThread(const Glib::ustring& name,
|
StaticThread::StaticThread(const Glib::ustring& name,
|
||||||
StaticProcess& process,
|
StaticProcess& process,
|
||||||
|
@ -31,24 +33,46 @@ StaticThread::StaticThread(const Glib::ustring& name,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME unmcomment when StaticSchedulable complies to the design
|
unsigned int
|
||||||
// unsigned int StaticThread::get_total_cpu_time() const
|
StaticThread::get_total_cpu_time() const
|
||||||
// {
|
{
|
||||||
// return _required_cpu_time;
|
return _required_cpu_time;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// unsigned int StaticThread::get_arrival_time() const
|
|
||||||
// {
|
|
||||||
// return _start_time_delta;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void StaticThread::set_arrival_time(unsigned int time)
|
|
||||||
// {
|
|
||||||
// _start_time_delta = time;
|
|
||||||
// }
|
|
||||||
|
|
||||||
StaticProcess& StaticThread::get_process()
|
unsigned int
|
||||||
|
StaticThread::get_arrival_time() const
|
||||||
|
{
|
||||||
|
return _start_time_delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
StaticProcess&
|
||||||
|
StaticThread::get_process()
|
||||||
{
|
{
|
||||||
return *_process;
|
return *_process;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
StaticThread::remove_request(StaticRequest* request)
|
||||||
|
{
|
||||||
|
assert(request != NULL);
|
||||||
|
|
||||||
|
vector<StaticRequest*>::iterator it;
|
||||||
|
|
||||||
|
// FIXME uncomment once requests are compelted
|
||||||
|
//it = std::find(_static_requests.begin(), _static_requests.end(), request);
|
||||||
|
|
||||||
|
//if(it != _static_requests.end())
|
||||||
|
//{
|
||||||
|
// _static_requests.erase(it);
|
||||||
|
// delete *it;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
StaticThread::add_request(StaticRequest* request)
|
||||||
|
{
|
||||||
|
assert(request != NULL);
|
||||||
|
|
||||||
|
_static_requests.push_back(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "glibmm/ustring.h"
|
#include "glibmm/ustring.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "static_schedulable.hh"
|
#include "static_schedulable.hh"
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ namespace sgpem
|
||||||
{
|
{
|
||||||
class StaticThread;
|
class StaticThread;
|
||||||
class StaticProcess;
|
class StaticProcess;
|
||||||
|
class StaticRequest;
|
||||||
|
|
||||||
class SG_DLLEXPORT StaticThread : public StaticSchedulable
|
class SG_DLLEXPORT StaticThread : public StaticSchedulable
|
||||||
{
|
{
|
||||||
|
@ -40,20 +42,23 @@ namespace sgpem
|
||||||
unsigned int arrival_time = 0,
|
unsigned int arrival_time = 0,
|
||||||
int base_priority = 0);
|
int base_priority = 0);
|
||||||
|
|
||||||
// FIXME already implemented in StaticSchedulable where they should
|
unsigned int get_total_cpu_time() const;
|
||||||
// only be declared abstract...
|
|
||||||
// unsigned int get_total_cpu_time() const;
|
unsigned int get_arrival_time() const;
|
||||||
//
|
|
||||||
// unsigned int get_arrival_time() const;
|
|
||||||
//
|
|
||||||
// void set_arrival_time(unsigned int time);
|
|
||||||
|
|
||||||
StaticProcess& get_process();
|
StaticProcess& get_process();
|
||||||
|
|
||||||
|
void remove_request(StaticRequest* request);
|
||||||
|
|
||||||
|
void add_request(StaticRequest* request);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
StaticThread(const StaticThread&);
|
||||||
|
|
||||||
unsigned int _start_time_delta;
|
unsigned int _start_time_delta;
|
||||||
unsigned int _required_cpu_time;
|
unsigned int _required_cpu_time;
|
||||||
StaticProcess* _process;
|
StaticProcess* _process;
|
||||||
|
std::vector<StaticRequest*> _static_requests;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue