- Added StaticThread and DynamicProcess classes

- Added Process interface
- Classes are still incomplete

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@632 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-06-14 23:31:31 +00:00
parent a1662de194
commit 9642918dd8
8 changed files with 330 additions and 1 deletions

View File

@ -142,6 +142,7 @@ src_backend_libbackend_la_LDFLAGS = \
# Please keep this in sorted order: # Please keep this in sorted order:
src_backend_libbackend_la_SOURCES = \ src_backend_libbackend_la_SOURCES = \
src/backend/dynamic_process.cc \
src/backend/dynamic_schedulable.cc \ src/backend/dynamic_schedulable.cc \
src/backend/global_preferences.cc \ src/backend/global_preferences.cc \
src/backend/history.cc \ src/backend/history.cc \
@ -150,17 +151,20 @@ src_backend_libbackend_la_SOURCES = \
src/backend/policy.cc \ src/backend/policy.cc \
src/backend/policy_manager.cc \ src/backend/policy_manager.cc \
src/backend/policy_parameters.cc \ src/backend/policy_parameters.cc \
src/backend/process.cc \
src/backend/schedulable.cc \ src/backend/schedulable.cc \
src/backend/schedulable_queue.cc \ src/backend/schedulable_queue.cc \
src/backend/scheduler.cc \ src/backend/scheduler.cc \
src/backend/slice.cc \ src/backend/slice.cc \
src/backend/static_process.cc \ src/backend/static_process.cc \
src/backend/static_schedulable.cc \ src/backend/static_schedulable.cc \
src/backend/static_thread.cc \
src/backend/string_utils.cc \ src/backend/string_utils.cc \
src/backend/user_interrupt_exception.cc src/backend/user_interrupt_exception.cc
pkginclude_HEADERS = \ pkginclude_HEADERS = \
config.h \ config.h \
src/backend/dynamic_process.hh \
src/backend/dynamic_schedulable.hh \ src/backend/dynamic_schedulable.hh \
src/backend/global_preferences.hh \ src/backend/global_preferences.hh \
src/backend/history.hh \ src/backend/history.hh \
@ -170,12 +174,14 @@ pkginclude_HEADERS = \
src/backend/policy.hh \ src/backend/policy.hh \
src/backend/policy_manager.hh \ src/backend/policy_manager.hh \
src/backend/policy_parameters.hh \ src/backend/policy_parameters.hh \
src/backend/process.hh \
src/backend/schedulable.hh \ src/backend/schedulable.hh \
src/backend/schedulable_queue.hh \ src/backend/schedulable_queue.hh \
src/backend/scheduler.hh \ src/backend/scheduler.hh \
src/backend/slice.hh \ src/backend/slice.hh \
src/backend/static_process.hh \ src/backend/static_process.hh \
src/backend/static_schedulable.hh \ src/backend/static_schedulable.hh \
src/backend/static_thread.hh \
src/backend/string_utils.hh \ src/backend/string_utils.hh \
src/backend/user_interrupt_exception.hh src/backend/user_interrupt_exception.hh

View File

@ -0,0 +1,67 @@
// src/backend/dynamic_process.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_process.hh"
#include "static_process.hh"
using namespace sgpem;
using std::vector;
DynamicProcess::DynamicProcess(StaticProcess& core) :
DynamicSchedulable(core)
{
}
DynamicProcess::DynamicProcess(const DynamicProcess &other) :
Schedulable(), DynamicSchedulable(other), Process()
{
typedef vector<DynamicThread*>::iterator ThreadIt;
const vector<DynamicThread*>& other_threads = other._dynamic_threads;
// FIXME uncomment when DynamicThread is complete
// for(ThreadIt it = other_threads.begin(); it != other_threads.end(); ++it)
// _dynamic_threads.push_back(new DynamicThread(*(*it)));
}
std::vector<Thread*> DynamicProcess::get_threads()
{
//FIXME uncomment when DynamicThread is complete
//return vector<Thread*>(_dynamic_threads.begin(), _dynamic_threads.end());
return vector<Thread*>();
}
//FIXME already implemented in DynamicSchedulable
//state get_state() const
//{
// //TODO complicated code here! leave me some time to figure
// // out what I need to do inside this method
//}
std::vector<DynamicThread*> DynamicProcess::get_dynamic_threads()
{
return _dynamic_threads;
}
void DynamicProcess::serialize(SerializeVisitor& translator)
{
//FIXME write this code. I'm predictable, I know
}

View File

@ -0,0 +1,61 @@
// src/backend/dynamic_process.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_PROCESS_HH
#define DYNAMIC_PROCESS_HH 1
#include "config.h"
#include "gettext.h"
#include "glibmm/ustring.h"
#include <vector>
#include "process.hh"
#include "dynamic_schedulable.hh"
namespace sgpem
{
class StaticProcess;
class DynamicProcess;
class DynamicThread;
class Thread;
class SG_DLLEXPORT DynamicProcess : public DynamicSchedulable, public Process
{
public:
DynamicProcess(StaticProcess& core);
DynamicProcess(const DynamicProcess &other);
std::vector<Thread*> get_threads();
//FIXME already implemented in DynamicSchedulable
//state get_state() const;
std::vector<DynamicThread*> get_dynamic_threads();
void serialize(SerializeVisitor& translator);
private:
std::vector<DynamicThread*> _dynamic_threads;
};
}
#endif

View File

@ -38,7 +38,7 @@ namespace sgpem
* Objects of type DynamicSchedulable are created by the Scheduler and are * Objects of type DynamicSchedulable are created by the Scheduler and are
* destroyed by SimulationStatus if they are linked to it or by the Scheduler. * destroyed by SimulationStatus if they are linked to it or by the Scheduler.
*/ */
class SG_DLLEXPORT DynamicSchedulable : public Schedulable class SG_DLLEXPORT DynamicSchedulable : public virtual Schedulable
{ {
public: public:
/** \brief Object constructor */ /** \brief Object constructor */

28
src/backend/process.cc Normal file
View File

@ -0,0 +1,28 @@
// src/backend/process.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 "process.hh"
using namespace sgpem;
Process::~Process()
{
}

51
src/backend/process.hh Normal file
View File

@ -0,0 +1,51 @@
// src/backend/process.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 PROCESS_HH
#define PROCESS_HH 1
#include "config.h"
#include "gettext.h"
#include "glibmm/ustring.h"
#include <vector>
#include "schedulable.hh"
namespace sgpem
{
class Process;
class Thread;
class SG_DLLEXPORT Process : public virtual Schedulable
{
public:
virtual ~Process();
virtual std::vector<Thread*> get_threads() = 0;
virtual void add_thread(const Glib::ustring& name,
unsigned int cpu_time,
unsigned int arrival_time = 0,
int base_priority = 0) = 0;
virtual void remove_thread(Thread *thread) = 0;
};
}
#endif

View File

@ -0,0 +1,54 @@
// src/backend/static_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 "static_thread.hh"
using namespace sgpem;
StaticThread::StaticThread(const Glib::ustring& name,
StaticProcess& process,
unsigned int arrival_time,
int base_priority) :
StaticSchedulable(name, arrival_time, 0, base_priority),
_start_time_delta(arrival_time), _required_cpu_time(0),
_process(&process)
{
}
// FIXME unmcomment when StaticSchedulable complies to the design
// unsigned int StaticThread::get_total_cpu_time() const
// {
// 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()
{
return *_process;
}

View File

@ -0,0 +1,62 @@
// src/backend/static_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 STATIC_THREAD_HH
#define STATIC_THREAD_HH 1
#include "config.h"
#include "gettext.h"
#include "glibmm/ustring.h"
#include "static_schedulable.hh"
namespace sgpem
{
class StaticThread;
class StaticProcess;
class SG_DLLEXPORT StaticThread : public StaticSchedulable
{
public:
StaticThread(const Glib::ustring& name,
StaticProcess& process,
unsigned int arrival_time = 0,
int base_priority = 0);
// FIXME already implemented in StaticSchedulable where they should
// only be declared abstract...
// unsigned int get_total_cpu_time() const;
//
// unsigned int get_arrival_time() const;
//
// void set_arrival_time(unsigned int time);
StaticProcess& get_process();
private:
unsigned int _start_time_delta;
unsigned int _required_cpu_time;
StaticProcess* _process;
};
}
#endif