DREAM::Scheduler Class Reference

Basic Scheduler model. More...

#include <Scheduler.h>

Inheritance diagram for DREAM::Scheduler:

DREAM::FixedPriorityScheduler DREAM::NonConcurrentScheduler List of all members.

Public Member Functions

 Scheduler (const std::string &id, DREAM::System *system_ptr, uint CPUs=1)
 Constructor.
virtual ~Scheduler ()
 Destructor.
virtual void add (DREAM::Node *node_ptr, uint priority)
 Puts a Node into the Scheduler pool - thread_map_.
virtual void add_error (DREAM::Task *task_ptr)
 Adds a Task in the error AVL tree - error_avltree_.
virtual void add_thread (DREAM::Thread *thread_ptr)
 Adds a Thread into the Scheduler pool - thread_map_.
virtual uint CPUs () const
 Returns the number of CPUs managed by the Scheduler.
virtual void freeCPU ()
 Frees an available CPU (Resource) of the Scheduler.
virtual DREAM::Threadget_thread (uint priority) const
 Returns a Thread from the list.
virtual bool highestpriority (const DREAM::Node *node_ptr) const
 Generic Schedulers do not have priority lanes.
virtual std::string id () const
 Returns the name of the Scheduler.
virtual bool lowestpriority (const DREAM::Node *node_ptr) const
 Generic Schedulers do not have priority lanes.
virtual double next_event (bool deterministic) const
 Return the time of the next event generated by the thread_map_.
virtual bool nonpreemptive () const
 The generic scheduler does not implement this function.
virtual double power () const
 Returns the power level cooresponding to the current QoS level.
virtual void qos_add (DREAM::QoSLevel *qos_ptr)
 Adds a QoS level to the Scheduler.
virtual void qos_power (const double power, DREAM::QoSLevel *low, DREAM::QoSLevel *high)
 Returns the two QoSLevels closest to the parameter power level, one consuming less, the other consuming more than the parameter.
virtual void qos_speed (const double speed, DREAM::QoSLevel *low, DREAM::QoSLevel *high)
 Returns the two QoSLevels closest to the parameter speed, one being slower the other being faster than the parameter.
virtual void erase (DREAM::Node *node_ptr, uint priority)
 Removes a Node from the Scheduler pool - thread_map_.
virtual void reset ()
 Resets Nodes managed by the scheduler (when restarting the simulation).
virtual void schedule (bool deterministic)
 Generic Schedulers do not schedule.
virtual void simulate (bool verbose, bool deterministic=false)
 Generic Schedulers do not simulate.
virtual double speed () const
 Returns the speed corresponding to the current QoS level.
virtual void stop ()
 Stops the Scheduler.
virtual const DREAM::Systemsystem () const
 Returns the System that owns the Scheduler.
virtual DREAM::Systemsystem ()
 Returns the System that owns the Scheduler.
virtual void take_transitions ()
 Takes transitions in every Thread in the thread_map_.
virtual const DREAM::THREAD_MAPthread_map () const
 Returns the Thread map thread_map_.
virtual uint threadpoolsize () const
 Return the size of the thread pool - thread_map_.
virtual double time () const
 Returns the (global) time of the Scheduler.
virtual void time_step (double time_step)
 Time jump.
virtual void trace (const std::string &output) const
 Function used to output info.
virtual void verbose (bool value)
 Specifies whether simulation messages will be supressed or not.
virtual void visitor_error_avltree (DREAM::TASK_AVLTREE *task_avltree)
 This function builds the error list.
virtual void visitor_if (DREAM::NODE_MAP *task_map, DREAM::NODE_MAP *channel_map, DREAM::NODE_MAP *timer_map, std::ofstream &f_stream)
 This function is part of the IF system description generator.
virtual void visitor_map (DREAM::NODE_MAP *task_map, DREAM::NODE_MAP *channel_map, DREAM::NODE_MAP *timer_map)
 This function fills the IDs (names) of tasks, channels and timers to the parameter lists.
virtual void visitor_task_avltree (DREAM::TASK_AVLTREE *task_avltree)
 This function builds the task list for manipulation.
virtual void visitor_update_task_avltree (DREAM::TASK_AVLTREE *task_avltree)
 This function updates task values in the system.
virtual void visitor_uppaal (DREAM::NODE_MAP *task_map, DREAM::NODE_MAP *channel_map, DREAM::NODE_MAP *timer_map, std::ofstream &f_stream)
 This function is part of the Uppaal system description generator.

Protected Member Functions

virtual void check_executed (const DREAM::NODE_MAP *node_map)
 Puts non-executed nodes in the error AVL tree.

Protected Attributes

bool active_
 Flag to signal end of event loop.
uint availableCPUs_
 The number of available Processors (Resources) which can execute Threads.
uint CPUs_
 The number of Processors (Resources) which can execute Threads.
std::string id_
 The name of the Scheduler.
DREAM::TASK_AVLTREE error_avltree_
 Queue for Tasks that missed the deadline etc.
DREAM::THREAD_MAP thread_map_
 List of all the Threads managed by the Scheduler - the Scheduler thread pool.
double time_
 Clock for the Scheduler.
bool verbose_
 Specifies whether simulation messages will be supressed or not.
QOS_AVLTREE qos_avltree_
 A map that stores the available QoS levels for this Scheduler.
QoSLevelqos_current_
 Pointer to the current QoS-level.
DREAM::Systemsystem_ptr_
 Pointer to the system.

Detailed Description

Basic Scheduler model.

The base class of the Scheduler implementation in the DRE Semantic Domain.

Definition at line 103 of file Scheduler.h.


Constructor & Destructor Documentation

DREAM::Scheduler::Scheduler ( const std::string &  id,
DREAM::System system_ptr,
uint  CPUs = 1 
)

Constructor.

Definition at line 84 of file Scheduler.cpp.

DREAM::Scheduler::~Scheduler (  )  [virtual]

Destructor.

Definition at line 94 of file Scheduler.cpp.

References DREAM::for_each(), and thread_map_.


Member Function Documentation

void DREAM::Scheduler::add ( DREAM::Node node_ptr,
uint  priority 
) [virtual]

Puts a Node into the Scheduler pool - thread_map_.

This function implements the mapping of Nodes to a platform processor in the DRE Semantic Domain. The scheduler will know about this Node and manage its execution.

Parameters:
node_ptr is a pointer to the Node which will be put in the Scheduler pool - thread_map_.
priority specifies the priority of the Thread to which the Node will be added.

Definition at line 99 of file Scheduler.cpp.

void DREAM::Scheduler::add_error ( DREAM::Task task_ptr  )  [virtual]

Adds a Task in the error AVL tree - error_avltree_.

Parameters:
task_ptr is a pointer to the Task which will be put in the error AVL tree - error_avltree_.

Definition at line 120 of file Scheduler.cpp.

References DREAM::Task::deadline(), error_avltree_, DREAM::Node::id(), DREAM::AVLTree< key_type, item_type >::insert(), DREAM::Task::subpriority(), trace(), and DREAM::Task::wcet().

Referenced by DREAM::Thread::add_error(), and check_executed().

void DREAM::Scheduler::add_thread ( DREAM::Thread thread_ptr  )  [virtual]

Adds a Thread into the Scheduler pool - thread_map_.

This function implements the mapping of Threads to a platform processor in the DRE Semantic Domain. The scheduler will know about this Thread and manage its execution.

Parameters:
thread_ptr is a pointer to the Thread which will be put in the Scheduler pool - thread_map_.

Definition at line 127 of file Scheduler.cpp.

References DREAM::Thread::priority().

Referenced by DREAM::Thread::Thread().

uint DREAM::Scheduler::CPUs (  )  const [inline, virtual]

Returns the number of CPUs managed by the Scheduler.

It returns 0 by default because non-concurrent Schedulers do not need a CPU, it is only used in the DREAM implementation.

Reimplemented in DREAM::FixedPriorityScheduler.

Definition at line 161 of file Scheduler.cpp.

void DREAM::Scheduler::freeCPU (  )  [virtual]

Frees an available CPU (Resource) of the Scheduler.

Definition at line 166 of file Scheduler.cpp.

DREAM::Thread * DREAM::Scheduler::get_thread ( uint  priority  )  const [virtual]

Returns a Thread from the list.

Parameters:
priority specifies the priority of the Thread to be returned.
Returns:
pointer to the Thread.

Definition at line 187 of file Scheduler.cpp.

References DREAM::NodeList::find().

bool DREAM::Scheduler::highestpriority ( const DREAM::Node node_ptr  )  const [virtual]

Generic Schedulers do not have priority lanes.

Inherited classes may implement this feature.

Reimplemented in DREAM::FixedPriorityScheduler.

Definition at line 208 of file Scheduler.cpp.

Referenced by DREAM::UppaalInterpreter::highestpriority(), and DREAM::IFInterpreter::highestpriority().

std::string DREAM::Scheduler::id (  )  const [inline, virtual]

Returns the name of the Scheduler.

Returns:
The id_ of the Scheduler.

Definition at line 220 of file Scheduler.cpp.

References id_.

Referenced by DREAM::System::add_scheduler().

bool DREAM::Scheduler::lowestpriority ( const DREAM::Node node_ptr  )  const [virtual]

Generic Schedulers do not have priority lanes.

Inherited classes may implement this feature.

Reimplemented in DREAM::FixedPriorityScheduler.

Definition at line 225 of file Scheduler.cpp.

Referenced by DREAM::UppaalInterpreter::lowestpriority(), and DREAM::IFInterpreter::lowestpriority().

double DREAM::Scheduler::next_event ( bool  deterministic  )  const [inline, virtual]

Return the time of the next event generated by the thread_map_.

Definition at line 241 of file Scheduler.cpp.

bool DREAM::Scheduler::nonpreemptive (  )  const [virtual]

The generic scheduler does not implement this function.

Throws Exception.

Reimplemented in DREAM::FixedPriorityScheduler.

Definition at line 265 of file Scheduler.cpp.

double DREAM::Scheduler::power (  )  const [inline, virtual]

Returns the power level cooresponding to the current QoS level.

Definition at line 278 of file Scheduler.cpp.

References DREAM::QoSLevel::power(), and qos_current_.

void DREAM::Scheduler::qos_add ( DREAM::QoSLevel qos_ptr  )  [virtual]

Adds a QoS level to the Scheduler.

Note that the Scheduler has the ownership of the QoSLevel data structure and it manages its lifecycle.

Parameters:
qos_ptr is the pointer to the QoSLevel data structure.

Definition at line 284 of file Scheduler.cpp.

References DREAM::AVLTree< key_type, item_type >::insert(), qos_avltree_, and DREAM::QoSLevel::speed().

void DREAM::Scheduler::qos_power ( const double  power,
DREAM::QoSLevel low,
DREAM::QoSLevel high 
) [virtual]

Returns the two QoSLevels closest to the parameter power level, one consuming less, the other consuming more than the parameter.

If the parameter power level can be found then both the low and the high values will refer to the optimal QoSLevel object. If not, the two closest mathes are obtained. We build on the assumption that faster QoS levels involve larger power levels. This case is ture in general as power is in a squared relation with speed. Special cases might be implemented later...

Parameters:
power is the parameter power level for which we would like to find the QoSLevel objects.
low is set to the fastest speed that is not faster than the speed parameter.
high is set to the slowest speed that is not slower than the speed parameter.

Definition at line 290 of file Scheduler.cpp.

void DREAM::Scheduler::qos_speed ( const double  speed,
DREAM::QoSLevel low,
DREAM::QoSLevel high 
) [virtual]

Returns the two QoSLevels closest to the parameter speed, one being slower the other being faster than the parameter.

If the parameter speed can be found then both the low and the high values will refer to the optimal QoSLevel object. If not, the two closest mathes are obtained.

Parameters:
speed is the parameter speed for which we would like to find the QoSLevel objects.
low is set to the fastest speed that is not faster than the speed parameter.
high is set to the slowest speed that is not slower than the speed parameter.

Definition at line 317 of file Scheduler.cpp.

void DREAM::Scheduler::erase ( DREAM::Node node_ptr,
uint  priority 
) [virtual]

Removes a Node from the Scheduler pool - thread_map_.

This function is called when redeploying Nodes to different platform processors.

Parameters:
node_ptr is a pointer to the Node which will be removed from the Scheduler pool - thread_map_.
priority specifies the priority of the Thread from which the Node will be deleted.

Definition at line 344 of file Scheduler.cpp.

References DREAM::Node::id().

void DREAM::Scheduler::reset (  )  [virtual]

Resets Nodes managed by the scheduler (when restarting the simulation).

Definition at line 365 of file Scheduler.cpp.

References availableCPUs_, DREAM::AVLTree< key_type, item_type >::clear(), CPUs_, error_avltree_, DREAM::for_each(), thread_map_, and time_.

void DREAM::Scheduler::schedule ( bool  deterministic  )  [virtual]

Generic Schedulers do not schedule.

Inherited classes may implement this feature.

Reimplemented in DREAM::NonConcurrentScheduler, and DREAM::FixedPriorityScheduler.

Definition at line 374 of file Scheduler.cpp.

void DREAM::Scheduler::simulate ( bool  verbose,
bool  deterministic = false 
) [virtual]

Generic Schedulers do not simulate.

Inherited classes may implement this feature.

Reimplemented in DREAM::FixedPriorityScheduler.

Definition at line 386 of file Scheduler.cpp.

double DREAM::Scheduler::speed (  )  const [inline, virtual]

Returns the speed corresponding to the current QoS level.

Definition at line 398 of file Scheduler.cpp.

References qos_current_, and DREAM::QoSLevel::speed().

void DREAM::Scheduler::stop (  )  [virtual]

Stops the Scheduler.

Definition at line 403 of file Scheduler.cpp.

References active_, check_executed(), Option::non_executing_tasks_, and thread_map_.

const DREAM::System * DREAM::Scheduler::system (  )  const [virtual]

Returns the System that owns the Scheduler.

Definition at line 420 of file Scheduler.cpp.

Referenced by DREAM::Task::clock_step(), DREAM::Channel::clock_step(), DREAM::Timer::clock_step(), DREAM::Timer::publish(), DREAM::Node::publish(), and DREAM::FixedPriorityScheduler::schedule().

DREAM::System * DREAM::Scheduler::system (  )  [virtual]

Returns the System that owns the Scheduler.

Definition at line 428 of file Scheduler.cpp.

void DREAM::Scheduler::take_transitions (  )  [inline, virtual]

Takes transitions in every Thread in the thread_map_.

Definition at line 440 of file Scheduler.cpp.

References DREAM::for_each().

const DREAM::THREAD_MAP * DREAM::Scheduler::thread_map (  )  const [virtual]

Returns the Thread map thread_map_.

Definition at line 453 of file Scheduler.cpp.

References thread_map_.

uint DREAM::Scheduler::threadpoolsize (  )  const [virtual]

Return the size of the thread pool - thread_map_.

Definition at line 458 of file Scheduler.cpp.

References thread_map_.

double DREAM::Scheduler::time (  )  const [inline, virtual]

Returns the (global) time of the Scheduler.

Definition at line 467 of file Scheduler.cpp.

void DREAM::Scheduler::time_step ( double  time_step  )  [inline, virtual]

Time jump.

Parameters:
time_step specifies the time step to be made.

Definition at line 477 of file Scheduler.cpp.

void DREAM::Scheduler::trace ( const std::string &  output  )  const [virtual]

Function used to output info.

Parameters:
output is the std::string to be displayed.

Definition at line 493 of file Scheduler.cpp.

References id_, time_, and verbose_.

Referenced by add_error(), and DREAM::Thread::trace().

void DREAM::Scheduler::verbose ( bool  value  )  [inline, virtual]

Specifies whether simulation messages will be supressed or not.

Definition at line 503 of file Scheduler.cpp.

References verbose_.

void DREAM::Scheduler::visitor_error_avltree ( DREAM::TASK_AVLTREE task_avltree  )  [virtual]

This function builds the error list.

The function is used by genetic algorithms.

Parameters:
task_avltree stores the list of Nodes from the Scheduler error list.

Definition at line 508 of file Scheduler.cpp.

References DREAM::AVLTree< key_type, item_type >::insert().

void DREAM::Scheduler::visitor_if ( DREAM::NODE_MAP task_map,
DREAM::NODE_MAP channel_map,
DREAM::NODE_MAP timer_map,
std::ofstream &  f_stream 
) [virtual]

This function is part of the IF system description generator.

Parameters:
task_map stores the Task pointers.
channel_map stores the Channel pointers.
timer_map stores the Timer pointers.
f_stream is the output stream to be written to.

Definition at line 521 of file Scheduler.cpp.

void DREAM::Scheduler::visitor_map ( DREAM::NODE_MAP task_map,
DREAM::NODE_MAP channel_map,
DREAM::NODE_MAP timer_map 
) [virtual]

This function fills the IDs (names) of tasks, channels and timers to the parameter lists.

The function is used to generate output for model checkers.

Parameters:
task_map stores the Task pointers.
channel_map stores the Channel pointers.
timer_map stores the Timer pointers.

Definition at line 534 of file Scheduler.cpp.

void DREAM::Scheduler::visitor_task_avltree ( DREAM::TASK_AVLTREE task_avltree  )  [virtual]

This function builds the task list for manipulation.

The function is used by genetic algorithms.

Parameters:
task_avltree stores the Task pointers.

Definition at line 547 of file Scheduler.cpp.

void DREAM::Scheduler::visitor_update_task_avltree ( DREAM::TASK_AVLTREE task_avltree  )  [virtual]

This function updates task values in the system.

The function is used by genetic algorithms.

Parameters:
task_avltree stores the Task pointers.

Definition at line 560 of file Scheduler.cpp.

void DREAM::Scheduler::visitor_uppaal ( DREAM::NODE_MAP task_map,
DREAM::NODE_MAP channel_map,
DREAM::NODE_MAP timer_map,
std::ofstream &  f_stream 
) [virtual]

This function is part of the Uppaal system description generator.

Parameters:
task_map stores the Task pointers.
channel_map stores the Channel pointers.
timer_map stores the Timer pointers.
f_stream is the output stream to be written to.

Definition at line 573 of file Scheduler.cpp.

void DREAM::Scheduler::check_executed ( const DREAM::NODE_MAP node_map  )  [protected, virtual]

Puts non-executed nodes in the error AVL tree.

Parameters:
node_map specifies the map which is checked for non-executed Nodes.

Definition at line 148 of file Scheduler.cpp.

References add_error().

Referenced by stop().


Member Data Documentation

bool DREAM::Scheduler::active_ [protected]

Flag to signal end of event loop.

Definition at line 401 of file Scheduler.h.

Referenced by stop().

uint DREAM::Scheduler::availableCPUs_ [protected]

The number of available Processors (Resources) which can execute Threads.

Definition at line 404 of file Scheduler.h.

Referenced by reset().

uint DREAM::Scheduler::CPUs_ [protected]

The number of Processors (Resources) which can execute Threads.

Definition at line 407 of file Scheduler.h.

Referenced by DREAM::FixedPriorityScheduler::CPUs(), and reset().

std::string DREAM::Scheduler::id_ [protected]

The name of the Scheduler.

Definition at line 410 of file Scheduler.h.

Referenced by id(), and trace().

DREAM::TASK_AVLTREE DREAM::Scheduler::error_avltree_ [protected]

Queue for Tasks that missed the deadline etc.

Definition at line 413 of file Scheduler.h.

Referenced by add_error(), and reset().

DREAM::THREAD_MAP DREAM::Scheduler::thread_map_ [protected]

List of all the Threads managed by the Scheduler - the Scheduler thread pool.

Definition at line 416 of file Scheduler.h.

Referenced by reset(), stop(), thread_map(), threadpoolsize(), and ~Scheduler().

double DREAM::Scheduler::time_ [protected]

Clock for the Scheduler.

Definition at line 419 of file Scheduler.h.

Referenced by reset(), and trace().

bool DREAM::Scheduler::verbose_ [protected]

Specifies whether simulation messages will be supressed or not.

Definition at line 422 of file Scheduler.h.

Referenced by trace(), and verbose().

QOS_AVLTREE DREAM::Scheduler::qos_avltree_ [protected]

A map that stores the available QoS levels for this Scheduler.

Definition at line 425 of file Scheduler.h.

Referenced by qos_add().

QoSLevel* DREAM::Scheduler::qos_current_ [protected]

Pointer to the current QoS-level.

Definition at line 428 of file Scheduler.h.

Referenced by power(), and speed().

DREAM::System* DREAM::Scheduler::system_ptr_ [protected]

Pointer to the system.

Used by tasks to figure out their next branching points.

Definition at line 433 of file Scheduler.h.


The documentation for this class was generated from the following files:
Generated on Fri Jul 27 18:30:04 2007 for DREAM by  doxygen 1.5.1