- Added NullPolicyException to scheduler
- Started code for printing the state of the scheduling - Fixed a bug in the copy constructor of DynamicThread git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@794 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
f26b80f76b
commit
6a88e3d85e
13 changed files with 167 additions and 23 deletions
|
@ -33,7 +33,7 @@ using namespace memory;
|
|||
using Glib::usleep;
|
||||
|
||||
ConcreteSimulation::ConcreteSimulation() :
|
||||
_state(state_paused), _mode(true), _timer_interval(1000), _policy(NULL)
|
||||
_state(state_stopped), _mode(true), _timer_interval(1000), _policy(NULL)
|
||||
{}
|
||||
|
||||
void
|
||||
|
@ -73,7 +73,7 @@ ConcreteSimulation::stop()
|
|||
}
|
||||
|
||||
void
|
||||
ConcreteSimulation::run() throw(UserInterruptException)
|
||||
ConcreteSimulation::run() throw(UserInterruptException, NullPolicyException)
|
||||
{
|
||||
switch(_state)
|
||||
{
|
||||
|
@ -117,7 +117,12 @@ ConcreteSimulation::run() throw(UserInterruptException)
|
|||
|
||||
try
|
||||
{
|
||||
assert(get_policy() != NULL);
|
||||
if(get_policy() == NULL)
|
||||
{
|
||||
stop();
|
||||
throw NullPolicyException("no policy selected");
|
||||
}
|
||||
|
||||
//step forward
|
||||
Scheduler::get_instance().step_forward(_history, *get_policy());
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace sgpem
|
|||
public:
|
||||
ConcreteSimulation();
|
||||
|
||||
void run() throw(UserInterruptException);
|
||||
void run() throw(UserInterruptException, NullPolicyException);
|
||||
|
||||
void pause();
|
||||
|
||||
|
|
|
@ -49,8 +49,9 @@ DynamicThread::DynamicThread(StaticThread* core, DynamicProcess* parent)
|
|||
|
||||
DynamicThread::DynamicThread(const DynamicThread &other, DynamicProcess* parent) :
|
||||
Schedulable(), DynamicSchedulable(other), Thread(),
|
||||
_state(other._state), _parent(parent), _ran_for(other._ran_for),
|
||||
_last_acquisition(other._last_acquisition), _last_release(other._last_release)
|
||||
_core(other._core), _state(other._state), _parent(parent),
|
||||
_ran_for(other._ran_for), _last_acquisition(other._last_acquisition),
|
||||
_last_release(other._last_release)
|
||||
{
|
||||
typedef vector<DynamicRequest*>::const_iterator ReqIt;
|
||||
|
||||
|
|
32
src/backend/null_policy_exception.cc
Normal file
32
src/backend/null_policy_exception.cc
Normal file
|
@ -0,0 +1,32 @@
|
|||
// src/backend/null_policy_exception.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
|
||||
|
||||
// Warning! This exception will be thrown across different libraries.
|
||||
// It could be necessary to do dynamic type-checking when
|
||||
// catching it (with typeinfo).
|
||||
|
||||
#include "null_policy_exception.hh"
|
||||
using namespace sgpem;
|
||||
|
||||
NullPolicyException::NullPolicyException(const char* msg)
|
||||
: std::runtime_error(msg)
|
||||
{}
|
||||
|
||||
NullPolicyException::~NullPolicyException() throw() {}
|
46
src/backend/null_policy_exception.hh
Normal file
46
src/backend/null_policy_exception.hh
Normal file
|
@ -0,0 +1,46 @@
|
|||
// src/backend/null_policy_exception.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
|
||||
|
||||
// Warning! This exception will be thrown across different libraries.
|
||||
// It could be necessary to do dynamic type-checking when
|
||||
// catching it (with typeinfo).
|
||||
|
||||
#ifndef NULL_POLICY_EXCEPTION
|
||||
#define NULL_POLICY_EXCEPTION 1
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace sgpem
|
||||
{
|
||||
class NullPolicyException;
|
||||
|
||||
class SG_DLLEXPORT NullPolicyException : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
NullPolicyException(const char* msg = "");
|
||||
virtual ~NullPolicyException() throw ();
|
||||
|
||||
private:
|
||||
};
|
||||
} //~ namespace sgpem
|
||||
|
||||
#endif
|
|
@ -57,6 +57,13 @@ ReadyQueue::get_item_at(position index)
|
|||
return *_scheds.at(index);
|
||||
}
|
||||
|
||||
const sgpem::Thread&
|
||||
ReadyQueue::get_item_at(position index) const
|
||||
throw (std::out_of_range)
|
||||
{
|
||||
// Checks index access
|
||||
return *_scheds.at(index);
|
||||
}
|
||||
|
||||
void
|
||||
ReadyQueue::append(Thread& thread)
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace sgpem
|
|||
void swap(position a, position b) throw (std::out_of_range);
|
||||
size_t size() const;
|
||||
Thread& get_item_at(position index) throw (std::out_of_range);
|
||||
const Thread& get_item_at(position index) const throw (std::out_of_range);
|
||||
void append(Thread& schedulable);
|
||||
|
||||
private:
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace sgpem
|
|||
|
||||
#include "singleton.hh"
|
||||
#include "user_interrupt_exception.hh"
|
||||
#include "null_policy_exception.hh"
|
||||
#include <vector>
|
||||
|
||||
namespace sgpem
|
||||
|
@ -76,7 +77,7 @@ namespace sgpem
|
|||
Advances the simulation by one or more steps, depending on the
|
||||
actual state and on the value set with set_mode().
|
||||
*/
|
||||
virtual void run() throw(UserInterruptException) = 0;
|
||||
virtual void run() throw(UserInterruptException, NullPolicyException) = 0;
|
||||
|
||||
/**
|
||||
\brief Pauses a running simulation.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue