#include <Thread.h>
Inheritance diagram for DREAM::Thread:
Public Member Functions | |
Thread (DREAM::Scheduler *scheduler_ptr, uint priority=0, uint threads=1) | |
Constructor. | |
virtual | ~Thread () |
Destructor. | |
virtual void | add_error (DREAM::Task *task_ptr) |
Adds a Task in the error AVL tree - error_avltree_. | |
virtual uint | availablethreads () const |
Returns the number of available Threads. | |
virtual void | deploy (DREAM::Scheduler *scheduler_ptr) throw (DREAM::Exception) |
Deploys a Thread to a Scheduler. | |
virtual void | dequeue (DREAM::Node *node_ptr) |
Removes an idle Node from the execution queue - exec_map_. | |
virtual void | enqueue (DREAM::Channel *channel_ptr) |
Puts an enabled Channel in the execution queue - exec_map_ - and reschedules if necessary. | |
virtual void | enqueue (DREAM::Task *task_ptr) |
Puts an enabled Task in the execution queue - exec_map_ -, and the recent queue - recent_map_ - and reschedules if necessary. | |
virtual void | freethread () |
Frees an available Thread from the lane. | |
virtual DREAM::NODE_MAP * | get_exec_map () |
Returns the whole exec_map_ for manipulation. | |
virtual const DREAM::TASK_AVLTREE * | get_recent_avltree () const |
Returns whether a Task has been recently enabled. | |
virtual double | next_event () const |
Return the time of the next event generated by the Thread. | |
virtual uint | priority () const |
Returns the priority of the Thread. | |
virtual bool | recent (DREAM::Task *task_ptr) const |
Returns whether a Task has been recently enabled together with other tasks. | |
void | reset () |
Resets Nodes in the map. | |
virtual bool | schedulable () const |
Checks whether the Thread is schedulable. | |
virtual const DREAM::Scheduler * | scheduler () const |
Returns a pointer to the Scheduler. | |
virtual DREAM::Scheduler * | scheduler () |
Returns a pointer to the Scheduler. | |
virtual uint | threads () const |
Returns the number of the Threads. | |
virtual void | time_step (double time_step) |
Time jump. | |
virtual void | trace (const std::string &output) const |
Function used to output info. | |
virtual void | usethread () |
Takes an available Thread from the lane. | |
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. | |
Private Attributes | |
uint | availablethreads_ |
Specifies the number of available threads in the lane. | |
DREAM::NODE_MAP | exec_map_ |
Map to store Nodes. | |
DREAM::TASK_AVLTREE | recent_avltree_ |
AVL tree that stores Nodes that have just become enabled. | |
uint | priority_ |
Priority of the Thread. | |
DREAM::Scheduler * | scheduler_ptr_ |
Pointer to the Scheduler which manages the NodeList/Thread. | |
uint | threads_ |
Specifies the number of threads in the lane. |
The Scheduler manages the execution of Threads based on their priority and the scheduling policiy.
Definition at line 158 of file Thread.h.
DREAM::Thread::Thread | ( | DREAM::Scheduler * | scheduler_ptr, | |
uint | priority = 0 , |
|||
uint | threads = 1 | |||
) |
DREAM::Thread::~Thread | ( | ) | [virtual] |
Destructor.
Definition at line 160 of file Thread.cpp.
References DREAM::for_each(), and DREAM::NodeList::node_map_.
void DREAM::Thread::add_error | ( | DREAM::Task * | task_ptr | ) | [inline, virtual] |
Adds a Task in the error AVL tree - error_avltree_.
task_ptr | is a pointer to the Task which will be put in the error AVL tree - error_avltree_. |
Definition at line 165 of file Thread.cpp.
References DREAM::Scheduler::add_error(), and scheduler_ptr_.
uint DREAM::Thread::availablethreads | ( | ) | const [inline, virtual] |
Returns the number of available Threads.
Definition at line 170 of file Thread.cpp.
References availablethreads_.
Referenced by DREAM::FixedPriorityScheduler::schedule().
void DREAM::Thread::deploy | ( | DREAM::Scheduler * | scheduler_ptr | ) | throw (DREAM::Exception) [virtual] |
void DREAM::Thread::dequeue | ( | DREAM::Node * | node_ptr | ) | [inline, virtual] |
Removes an idle Node from the execution queue - exec_map_.
node_ptr | is a pointer to the Node which will be removed from the execution queue - exec_map_. |
Reimplemented from DREAM::NodeList.
Definition at line 189 of file Thread.cpp.
References DREAM::Node::id(), and Option::verbose1_.
void DREAM::Thread::enqueue | ( | DREAM::Channel * | channel_ptr | ) | [inline, virtual] |
Puts an enabled Channel in the execution queue - exec_map_ - and reschedules if necessary.
channel_ptr | is a pointer to the Channel which will be put in the execution queue - exec_map_. |
Definition at line 215 of file Thread.cpp.
References exec_map_, DREAM::Node::id(), trace(), and Option::verbose1_.
void DREAM::Thread::enqueue | ( | DREAM::Task * | task_ptr | ) | [inline, virtual] |
Puts an enabled Task in the execution queue - exec_map_ -, and the recent queue - recent_map_ - and reschedules if necessary.
task_ptr | is a pointer to the Task which will be put in the queues. |
Definition at line 228 of file Thread.cpp.
References exec_map_, DREAM::Node::id(), DREAM::AVLTree< key_type, item_type >::insert(), recent_avltree_, trace(), and Option::verbose1_.
void DREAM::Thread::freethread | ( | ) | [virtual] |
DREAM::NODE_MAP * DREAM::Thread::get_exec_map | ( | ) | [inline, virtual] |
Returns the whole exec_map_ for manipulation.
Definition at line 280 of file Thread.cpp.
Referenced by DREAM::FixedPriorityScheduler::schedule().
const DREAM::TASK_AVLTREE * DREAM::Thread::get_recent_avltree | ( | ) | const [inline, virtual] |
Returns whether a Task has been recently enabled.
Definition at line 287 of file Thread.cpp.
References recent_avltree_.
Referenced by DREAM::FixedPriorityScheduler::schedule().
double DREAM::Thread::next_event | ( | ) | const [inline, virtual] |
Return the time of the next event generated by the Thread.
Definition at line 297 of file Thread.cpp.
uint DREAM::Thread::priority | ( | ) | const [inline, virtual] |
Returns the priority of the Thread.
Definition at line 323 of file Thread.cpp.
References priority_.
Referenced by DREAM::Scheduler::add_thread().
bool DREAM::Thread::recent | ( | DREAM::Task * | task_ptr | ) | const [virtual] |
Returns whether a Task has been recently enabled together with other tasks.
task_ptr | is a pointer to the Task to be checked. |
Definition at line 329 of file Thread.cpp.
References DREAM::AVLTree< key_type, item_type >::begin(), DREAM::AVLTree< key_type, item_type >::end(), recent_avltree_, and DREAM::AVLTree< key_type, item_type >::size().
Referenced by DREAM::FixedPriorityScheduler::schedule().
void DREAM::Thread::reset | ( | ) |
bool DREAM::Thread::schedulable | ( | ) | const [inline, virtual] |
Checks whether the Thread is schedulable.
Definition at line 363 of file Thread.cpp.
References availablethreads_, and exec_map_.
const DREAM::Scheduler * DREAM::Thread::scheduler | ( | ) | const [inline, virtual] |
Returns a pointer to the Scheduler.
Used in output generation.
Definition at line 372 of file Thread.cpp.
Referenced by DREAM::Task::clock_step(), DREAM::Channel::clock_step(), DREAM::Timer::clock_step(), DREAM::Timer::publish(), DREAM::Node::publish(), DREAM::FixedPriorityScheduler::schedule(), and DREAM::Node::scheduler().
DREAM::Scheduler * DREAM::Thread::scheduler | ( | ) | [inline, virtual] |
Returns a pointer to the Scheduler.
Used in output generation.
Definition at line 382 of file Thread.cpp.
uint DREAM::Thread::threads | ( | ) | const [inline, virtual] |
void DREAM::Thread::time_step | ( | double | time_step | ) | [inline, virtual] |
Time jump.
time_step | specifies the time step to be made. |
Definition at line 397 of file Thread.cpp.
void DREAM::Thread::trace | ( | const std::string & | output | ) | const [inline, virtual] |
Function used to output info.
output | is the std::string to be displayed. |
Definition at line 416 of file Thread.cpp.
References scheduler_ptr_, and DREAM::Scheduler::trace().
Referenced by DREAM::Task::clock_step(), DREAM::Channel::clock_step(), DREAM::Timer::clock_step(), enqueue(), DREAM::Timer::publish(), DREAM::Node::publish(), and DREAM::FixedPriorityScheduler::schedule().
void DREAM::Thread::usethread | ( | ) | [virtual] |
Takes an available Thread from the lane.
Definition at line 421 of file Thread.cpp.
Referenced by DREAM::FixedPriorityScheduler::schedule().
void DREAM::Thread::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.
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 438 of file Thread.cpp.
void DREAM::Thread::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.
task_map | stores the Task pointers. | |
channel_map | stores the Channel pointers. | |
timer_map | stores the Timer pointers. |
Definition at line 451 of file Thread.cpp.
void DREAM::Thread::visitor_task_avltree | ( | DREAM::TASK_AVLTREE * | task_avltree | ) | [virtual] |
This function builds the task list for manipulation.
The function is used by genetic algorithms.
task_avltree | stores the Task pointers. |
Definition at line 464 of file Thread.cpp.
void DREAM::Thread::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.
task_avltree | stores the Task pointers. |
Definition at line 478 of file Thread.cpp.
void DREAM::Thread::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.
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 492 of file Thread.cpp.
uint DREAM::Thread::availablethreads_ [private] |
Specifies the number of available threads in the lane.
Definition at line 363 of file Thread.h.
Referenced by availablethreads(), and schedulable().
DREAM::NODE_MAP DREAM::Thread::exec_map_ [private] |
Map to store Nodes.
Definition at line 366 of file Thread.h.
Referenced by enqueue(), and schedulable().
AVL tree that stores Nodes that have just become enabled.
This AVL tree is used by the model checker to check for race conditions.
Definition at line 372 of file Thread.h.
Referenced by enqueue(), get_recent_avltree(), and recent().
uint DREAM::Thread::priority_ [private] |
DREAM::Scheduler* DREAM::Thread::scheduler_ptr_ [private] |
Pointer to the Scheduler which manages the NodeList/Thread.
Definition at line 379 of file Thread.h.
Referenced by add_error(), and trace().
uint DREAM::Thread::threads_ [private] |