100 lines
3.2 KiB
C++
100 lines
3.2 KiB
C++
// src/backend/scheduler.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 SCHEDULER_HH
|
|
#define SCHEDULER_HH 1
|
|
namespace sgpem
|
|
{
|
|
class Scheduler;
|
|
class PolicyManager;
|
|
class Policy;
|
|
}
|
|
|
|
#include "config.h"
|
|
|
|
#include "history.hh"
|
|
#include "policy.hh"
|
|
#include "ready_queue.hh"
|
|
#include "user_interrupt_exception.hh"
|
|
|
|
// Do not include full template definition here
|
|
#include "singleton.hh"
|
|
|
|
namespace sgpem
|
|
{
|
|
class Scheduler;
|
|
|
|
|
|
/** \brief Manages the DynamicSchedulable objects, implementing a given policy.
|
|
|
|
Class Scheduler manages the schedulable entities which are ready to run,
|
|
ordering them in a queue; it also checks that the current scheduling policy
|
|
is well-defined and does not disrupt the application inner mechanism.
|
|
It is also responsible for the creation and the destruction of some of
|
|
the DynamicSchedulable objects (for further details about this, check
|
|
class DynamicSchedulable).
|
|
|
|
*/
|
|
|
|
class SG_DLLEXPORT Scheduler : public Singleton<Scheduler>
|
|
{
|
|
friend class Singleton<Scheduler>;
|
|
public:
|
|
/**
|
|
Returns a pointer to the queue containing all the ready
|
|
schedulable objects (for the policy to sort it).
|
|
\return a pointer to the queue containing all the ready
|
|
schedulable objects (for the policy to sort it).
|
|
*/
|
|
ReadyQueue* get_ready_queue();
|
|
/**
|
|
Resets the simulation to the initial state.
|
|
*/
|
|
void reset_status();
|
|
/**
|
|
Generates a new ReadyQueue representing the status of the processes
|
|
at the simulation instant next to the current one, and extends the History by
|
|
one instant with it.
|
|
*/
|
|
void step_forward(History& history, Policy& cpu_policy) throw(UserInterruptException);
|
|
/**
|
|
Sets the policy that will be used to generate the simulation at the next instant.
|
|
\param policy the policy that will be used to generate the simulation at the next instant.
|
|
*/
|
|
/* DISABLED until we don't have PolicyManager::set_policy()
|
|
void set_policy(Policy* policy);
|
|
*/
|
|
/**
|
|
Returns the policy that will be used to generate the simulation at the next instant.
|
|
\return the policy that will be used to generate the simulation at the next instant.
|
|
*/
|
|
Policy* get_policy();
|
|
|
|
private:
|
|
Scheduler(); //private constructor.
|
|
|
|
ReadyQueue* _ready_queue;
|
|
Policy* _policy;
|
|
};
|
|
|
|
}//~ namespace sgpem
|
|
|
|
#endif //SCHEDULER_HH
|