sgpemv2/src/backend/dynamic_schedulable.cc
tchernobog 7d62f4b937 - Mega-update. Take it while it's hot... but my brain's frying!
- Fixed all Dynamic and Static entities lacking proper destructors:
Dynamic entities need to delete Dynamic children, Static entities
need only to delete them from the list of their siblings
- Added methods to get Static "core" from Dynamic*.
- Now get_core() is a pure virtual function into DynamicSchedulable.
A quite nice solution(?), really, if I can say that myself... ;-)
- ConcreteHistory is half-implemented. It's the other half that 
worries me.
- TODO: finish off ConcreteHistory, and check that things get destroyed
properly (no leaks allowed, use valgrind).
- TODO: rework Simulation
- TODO: Scheduler rewrite
- *A side note*: this code is becoming a mess. I prefer references over
pointers, but someone other prefer pointers over references, and what
happens is that you've to continously pass from one to another when
invoking other methods... this is bad.


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@694 3ecf2c5c-341e-0410-92b4-d18e462d057c
2006-07-02 22:20:03 +00:00

123 lines
2.5 KiB
C++

// src/backend/dynamic_schedulable.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_schedulable.hh"
#include "smartp.tcc"
#include <cassert>
using namespace sgpem;
using namespace std;
DynamicSchedulable::DynamicSchedulable()
: _ran_for(0), _last_acquisition(-1),
_last_release(-1), _priority_push(0)
{}
bool
DynamicSchedulable::operator==(const Schedulable& op2) const
{
assert(dynamic_cast<const DynamicSchedulable*>(&op2) != NULL);
return &get_core() == &(dynamic_cast<const DynamicSchedulable&>(op2).get_core());
}
Glib::ustring
DynamicSchedulable::get_name() const
{
return get_core().get_name();
}
unsigned int
DynamicSchedulable::get_arrival_time() const
{
return get_core().get_arrival_time();
}
int
DynamicSchedulable::get_base_priority() const
{
return get_core().get_priority();
}
unsigned int
DynamicSchedulable::get_total_cpu_time() const
{
return get_core().get_total_cpu_time();
}
int
DynamicSchedulable::get_priority_push() const
{
return _priority_push;
}
int
DynamicSchedulable::set_priority_push(int new_value)
{
int temp = _priority_push;
_priority_push = new_value;
return temp;
}
int
DynamicSchedulable::get_current_priority() const
{
return get_base_priority() + get_priority_push();
}
unsigned int
DynamicSchedulable::get_remaining_time() const
{
return get_total_cpu_time() - _ran_for;
}
void
DynamicSchedulable::decrease_remaining_time()
{
_ran_for++;
}
int
DynamicSchedulable::get_last_acquisition() const
{
return _last_acquisition;
}
void
DynamicSchedulable::set_last_acquisition(int instant)
{
_last_acquisition = instant;
}
int
DynamicSchedulable::get_last_release() const
{
return _last_release;
}
void
DynamicSchedulable::set_last_release(int instant)
{
_last_release = instant;
}