81 lines
1.9 KiB
C++
81 lines
1.9 KiB
C++
// src/backend/schedulable_status.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 "schedulable_status.hh"
|
|
using namespace sgpem;
|
|
using namespace std;
|
|
|
|
SchedulableStatus::SchedulableStatus(const Schedulable& obj)
|
|
: _ref(&obj), _last(-1), _time_left(obj.get_total_cpu_time()), _my_state(state_future)
|
|
{
|
|
}
|
|
|
|
int
|
|
SchedulableStatus::get_cpu_time_left() const
|
|
{
|
|
return _time_left;
|
|
}
|
|
|
|
void
|
|
SchedulableStatus::give_cpu_time(const int& time)
|
|
{
|
|
_time_left -= time;
|
|
if (_time_left < 0)
|
|
_time_left = 0;
|
|
}
|
|
|
|
void
|
|
SchedulableStatus::set_last_scheduled(const int& time)
|
|
{
|
|
_last = time;
|
|
}
|
|
|
|
int
|
|
SchedulableStatus::get_last_scheduled() const
|
|
{
|
|
return _last;
|
|
}
|
|
|
|
SchedulableStatus::state
|
|
SchedulableStatus::get_state() const
|
|
{
|
|
return _my_state;
|
|
}
|
|
|
|
void
|
|
SchedulableStatus::set_state(state s)
|
|
{
|
|
_my_state = s;
|
|
}
|
|
|
|
const Schedulable*
|
|
SchedulableStatus::get_schedulable() const
|
|
{
|
|
return _ref;
|
|
}
|
|
|
|
bool
|
|
SchedulableStatus::operator==(const SchedulableStatus& dx) const
|
|
{
|
|
return (_ref==dx._ref)&&(_last==dx._last)&&(_time_left==dx._time_left)&&(_my_state==dx._my_state);
|
|
}
|
|
|
|
|