92 lines
2.3 KiB
C++
92 lines
2.3 KiB
C++
// 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"
|
|
#include "static_request.hh"
|
|
|
|
#include <algorithm>
|
|
#include <cassert>
|
|
|
|
using namespace sgpem;
|
|
using namespace std;
|
|
|
|
StaticThread::StaticThread(const Glib::ustring& name,
|
|
StaticProcess& process,
|
|
unsigned int cpu_time,
|
|
unsigned int arrival_time,
|
|
int base_priority) :
|
|
StaticSchedulable(name, base_priority),
|
|
_start_time_delta(arrival_time),
|
|
_required_cpu_time(cpu_time),
|
|
_process(&process)
|
|
{
|
|
process.get_threads().push_back(this);
|
|
}
|
|
|
|
|
|
StaticThread::~StaticThread()
|
|
{
|
|
typedef std::vector<StaticThread*> Threads;
|
|
Threads& siblings = _process->get_threads();
|
|
siblings.erase(find(siblings.begin(), siblings.end(), this));
|
|
}
|
|
|
|
|
|
unsigned int
|
|
StaticThread::get_total_cpu_time() const
|
|
{
|
|
return _required_cpu_time;
|
|
}
|
|
|
|
unsigned int
|
|
StaticThread::set_total_cpu_time(unsigned int cpu_time)
|
|
{
|
|
unsigned int old_required_cpu_time = _required_cpu_time;
|
|
_required_cpu_time = cpu_time;
|
|
return old_required_cpu_time;
|
|
}
|
|
|
|
unsigned int
|
|
StaticThread::get_arrival_time() const
|
|
{
|
|
return _start_time_delta;
|
|
}
|
|
|
|
unsigned int
|
|
StaticThread::set_arrival_time(unsigned int arrival_time)
|
|
{
|
|
unsigned int old_start_time_delta = _start_time_delta;
|
|
_start_time_delta = arrival_time;
|
|
return old_start_time_delta;
|
|
}
|
|
|
|
|
|
StaticProcess&
|
|
StaticThread::get_process()
|
|
{
|
|
return *_process;
|
|
}
|
|
|
|
std::vector<StaticRequest*>&
|
|
StaticThread::get_requests()
|
|
{
|
|
return _static_requests;
|
|
}
|