Task.h

Go to the documentation of this file.
00001 /** @file Task.h
00002 * @author Gabor Madl
00003 * @date Created 02/2005
00004 * @brief Specifies basic elements in the DRE Semantic Domain.
00005 *
00006 *
00007 * =================================================================
00008 * DREAM License v2.0
00009 * 
00010 * DREAM - Distributed Real-time Embedded Analysis Method
00011 * http://dre.sourceforge.net.
00012 * Copyright (c) 2005-2007 Gabor Madl, All Rights Reserved.
00013 * 
00014 * This file is part of DREAM.
00015 * 
00016 * DREAM is free software; you can redistribute it and/or modify it
00017 * under the terms of the GNU General Public License version 2 as
00018 * published by the Free Software Foundation. No future versions of
00019 * the GPL license may be automatically applied to DREAM. It is in
00020 * the sole discretion of the copyright holder to determine whether
00021 * DREAM may be released under a different license or terms. There
00022 * are no restrictions on the use of DREAM for any purpose.
00023 * 
00024 * DREAM is distributed in the hope that it will be useful,
00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00027 * GNU General Public License for more details.
00028 * 
00029 * You should have received a copy of the GNU General Public License
00030 * along with this program; if not, write to the Free Software
00031 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00032 * MA 02110-1301, USA.
00033 * 
00034 * By submitting comments, suggestions, code, code snippets,
00035 * techniques (including that of usage), and algorithms, submitters
00036 * acknowledge that they have the right to do so, that any such
00037 * submissions are given freely and unreservedly, and that they
00038 * waive any claims to copyright or ownership. In addition,
00039 * submitters acknowledge that any such submission might become
00040 * part of the copyright maintained on the overall body of code,
00041 * which comprises DREAM. By making a submission, submitter agrees
00042 * to these terms. Furthermore, submitters acknowledge that the
00043 * incorporation or modification of such submissions is entirely
00044 * at the discretion of the moderators of the DREAM project.
00045 * 
00046 * DREAM links to the Libxml2 third party library. Please see 
00047 * COPYING-libxml for the copyright information of Libxml2.
00048 * =================================================================
00049 */
00050 
00051 #ifndef DREAM_TASK
00052 #define DREAM_TASK
00053 
00054 /** Namespace used in the DREAM core */
00055 namespace DREAM
00056 {
00057         class Node;
00058         class Task;
00059 }
00060 
00061 #include <iostream>
00062 #include <fstream>
00063 #include "Thread.h"
00064 #include "Scheduler.h"
00065 #include "Exception.h"
00066 
00067 namespace DREAM
00068 {
00069 /** State of the Task as specified by the DRE Semantic Domain. */
00070 typedef enum task_state {idle, enabled, preempted, executing, error} State;
00071 
00072 /** Generic Node class used to build the dependency graph.
00073 *This class is the base class for every element in the DRE Semantic Domain.
00074 */
00075 class Node
00076 {
00077 public:
00078 
00079         /** Constructor.
00080         * @param id specifies the name of the Node.
00081         * @param thread_ptr defines the mapping of the Node to a platform processor.
00082         * @param executed is used to check unexecuted tasks in a frame.
00083         */
00084         Node (const std::string& id, DREAM::Thread* thread_ptr, bool executed);
00085 
00086         /** Copy constructor for Nodes.
00087         * @param node is the pointer to the Node to be copied.
00088         */
00089         Node (const DREAM::Node& node);
00090 
00091         /** Destructor. */
00092         virtual ~Node ();
00093 
00094         /** Adds a dependent Node to the current Node.
00095         * @param node_ptr is a pointer to the dependent Node to be added.
00096         */
00097         virtual void add_dependent (DREAM::Node* node_ptr);
00098 
00099         /** Generic nodes do not have best case execution times.
00100         * Inherited classes may implement this feature.
00101         */
00102         virtual uint bcet () const
00103 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00104                 throw (DREAM::Exception)
00105 #endif
00106         ;
00107 
00108         /** Generic nodes do not have best case execution times.
00109         * Inherited classes may implement this feature.
00110         */
00111         virtual void bcet (uint bcet)
00112 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00113                 throw (DREAM::Exception)
00114 #endif
00115         ;
00116 
00117 #ifdef DREAM_BRANCHING
00118         /** Generic nodes do not have branching points.
00119         * Inherited classes may implement this feature.
00120         */
00121         virtual void branching_point ()
00122 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00123                 throw (DREAM::Exception)
00124 #endif
00125         ;
00126 #endif
00127 
00128         /** Generic nodes do not have context.
00129         * Inherited classes may implement this feature.
00130         */
00131         virtual DREAM::Context context () const
00132 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00133                 throw (DREAM::Exception)
00134 #endif
00135         ;
00136 
00137         /** Generic nodes do not have context.
00138         * Inherited classes may implement this feature.
00139         */
00140         virtual void context (DREAM::Context context)
00141 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00142                 throw (DREAM::Exception)
00143 #endif
00144         ;
00145 
00146         /** Generic nodes do not have deadline clocks.
00147         * Inherited classes may implement this feature.
00148         */
00149         virtual double clock_dl () const
00150 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00151                 throw (DREAM::Exception)
00152 #endif
00153         ;
00154 
00155         /** Generic nodes do not have deadline clocks.
00156         * Inherited classes may implement this feature.
00157         */
00158         virtual double clock_dl_reset () const
00159 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00160                 throw (DREAM::Exception)
00161 #endif
00162         ;
00163 
00164         /** Measures time spent executing.
00165         * @return The value of clock_exec_.
00166         */
00167         virtual double clock_exec () const;
00168 
00169         /** Reset execution clock value - clock_exec_. */
00170         virtual void clock_exec_reset ();
00171 
00172         /** Models the passing of time.
00173         * Increments local clock clock_exec_.
00174         * @param clock_step specifies by how much do we have to increment the time.
00175         */
00176         virtual void clock_step (double clock_step);
00177 
00178         /** Generic nodes do not consume events.
00179         * Inherited classes may implement this feature.
00180         */
00181         virtual void consume ()
00182 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00183                 throw (DREAM::Exception)
00184 #endif
00185         ;
00186 
00187         /** Generic nodes do not have deadlines.
00188         * Inherited classes may implement this feature.
00189         */
00190         virtual uint deadline () const
00191 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00192                 throw (DREAM::Exception)
00193 #endif
00194         ;
00195 
00196         /** Generic nodes do not have deadlines.
00197         * Inherited classes may implement this feature.
00198         */
00199         virtual void deadline (uint deadline)
00200 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00201                 throw (DREAM::Exception)
00202 #endif
00203         ;
00204 
00205         /** Deploys a Node to a Thread.
00206         * This function updates the thread_ptr in the Node.
00207         * @param thread_ptr is the Thread where the Node will be deployed.
00208         */
00209         virtual void deploy (DREAM::Thread* thread_ptr);
00210 
00211         /** Generic Nodes do not execute.
00212         * No Exception is thrown.
00213         */
00214         virtual void execute ()
00215 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00216                 throw (DREAM::Exception)
00217 #endif
00218         {};
00219 
00220         /** Checks whether the Node has already been executed.
00221         * @return The executed_ flag.
00222         */
00223         virtual bool executed () const;
00224 
00225         /** Sets the Node to be executed.
00226         * @param executed sets the executed_ flag.
00227         */
00228         virtual void executed (bool executed);
00229 
00230         /** Returns a dependent from the list.
00231         * @param id specifies which dependent are we looking for.
00232         * @return the dependent Node.
00233         */
00234         virtual DREAM::Node* get_dependent (const std::string& id) const;
00235 
00236         /** Returns the whole map for manipulation.
00237         * @return The dependent_map_.
00238         */
00239         virtual const DREAM::NODE_MAP* get_dependent_map () const;
00240 
00241         /** Returns a pointer to the source Node. 
00242         * @param task_map contains the Tasks in the model.
00243         * @param channel_map contains the Channels in the model.
00244         * @param timer_map contains the Timers in the model.
00245         */
00246         virtual const DREAM::Node* get_source (DREAM::NODE_MAP* task_map, DREAM::NODE_MAP* channel_map, 
00247                 DREAM::NODE_MAP* timer_map) const
00248                         throw (DREAM::Exception);
00249 
00250         /** Returns the name of the Node.
00251         * @return The id_ of the Node.
00252         */
00253         virtual std::string id () const;
00254 
00255         /** Generic nodes do not have deadlines.
00256         * Inherited classes may implement this feature.
00257         */
00258         virtual bool isidle () const
00259 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00260                 throw (DREAM::Exception)
00261 #endif
00262         ;
00263 
00264         /** Generic nodes do not generate events.
00265         * No Exception is thrown.
00266         */
00267         virtual double next_event ();
00268 
00269 #ifdef DREAM_BRANCHING
00270         /** Generic nodes do not have clocks.
00271         * Inherited classes may implement this feature.
00272         */
00273         virtual void next_et (double next_et)
00274 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00275                 throw (DREAM::Exception)
00276 #endif
00277         ;
00278 #endif
00279 
00280         /** Publishes an event to dependent tasks.
00281         * This virtual function models synchronous event propagation.
00282         * The derived classes call the consume () function of all the dependent Nodes.
00283         */
00284         virtual void publish ();
00285 
00286         /** Generic nodes cannot be preempted.
00287         * Inherited classes may implement this feature.
00288         */
00289         virtual void preempt ()
00290 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00291                 throw (DREAM::Exception)
00292 #endif
00293         ;
00294 
00295         /** Generic nodes do not have priorities.
00296         * Inherited classes may implement this feature.
00297         */
00298         virtual uint priority () const
00299 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00300                 throw (DREAM::Exception)
00301 #endif
00302         ;
00303 
00304         /** Generic nodes do not have priorities.
00305         * Inherited classes may implement this feature.
00306         */
00307         virtual void priority (uint priority)
00308 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00309                 throw (DREAM::Exception)
00310 #endif
00311         ;
00312 
00313         /** Returns the remote_dep_ flag of the Node. */
00314         virtual bool remote_dep () const;
00315 
00316         /** Sets the remote_dep_ flag of the Node. */
00317         virtual void remote_dep (bool flag);
00318 
00319         /** Removes a dependent from the list.
00320         * @param id specifies the dependent to be removed.
00321         */
00322         virtual void remove_dependent (const std::string& id);
00323 
00324         /** Resets node (when restarting the simulation). */
00325         virtual void reset ();
00326 
00327         /** Returns a pointer to the Scheduler.
00328         * Used in output generation
00329         */
00330         virtual DREAM::Scheduler* scheduler () const;
00331 
00332         /** Generic nodes do not have subpriorities.
00333         * Inherited classes may implement this feature.
00334         */
00335         virtual uint subpriority () const
00336 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00337                 throw (DREAM::Exception)
00338 #endif
00339         ;
00340 
00341         /** Generic nodes do not have subpriorities.
00342         * Inherited classes may implement this feature.
00343         */
00344         virtual void subpriority (uint subpriority)
00345 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00346                 throw (DREAM::Exception)
00347 #endif
00348         ;
00349 
00350         /** Generic nodes do not take transitions.
00351         * Inherited classes may implement this feature.
00352         */
00353         virtual void take_transitions ()
00354 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00355                 throw (DREAM::Exception)
00356 #endif
00357         ;
00358 
00359         /** This function is part of the IF system description generator.
00360         * @param task_map stores the Task pointers.
00361         * @param channel_map stores the Channel pointers.
00362         * @param timer_map stores the Timer pointers.
00363         * @param f_stream is the output stream to be written to.
00364         */
00365         virtual void visitor_if (DREAM::NODE_MAP* task_map, DREAM::NODE_MAP* channel_map, DREAM::NODE_MAP* timer_map, std::ofstream& f_stream)
00366 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00367                 throw (DREAM::Exception) 
00368 #endif
00369         {};
00370 
00371         /** This function does not work for generic nodes.
00372         * Inherited classes may implement this feature.
00373         * @param task_map stores the Task pointers.
00374         * @param channel_map stores the Channel pointers.
00375         * @param timer_map stores the Timer pointers.
00376         */
00377         virtual void visitor_map (DREAM::NODE_MAP* task_map, DREAM::NODE_MAP* channel_map, 
00378                 DREAM::NODE_MAP* timer_map)
00379 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00380                         throw (DREAM::Exception)
00381 #endif
00382         {};
00383 
00384         /** This function does not work for generic nodes.
00385         * Inherited classes may implement this feature.
00386         * @param task_avltree stores the Task pointers.
00387         */
00388         virtual void visitor_task_avltree (DREAM::TASK_AVLTREE* task_avltree)
00389 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00390                 throw (DREAM::Exception)
00391 #endif
00392         {};
00393 
00394         /** This function does not work for generic nodes.
00395         * Inherited classes may implement this feature.
00396         * @param task_avltree stores the Task pointers.
00397         */
00398         virtual void visitor_update_task_avltree (DREAM::TASK_AVLTREE* task_avltree)
00399 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00400                 throw (DREAM::Exception)
00401 #endif
00402         {};
00403 
00404         /** This function does not work for generic nodes.
00405         * Inherited classes may implement this feature.
00406         * @param task_map stores the Task pointers.
00407         * @param channel_map stores the Channel pointers.
00408         * @param timer_map stores the Timer pointers.
00409         * @param f_stream is the output stream to be written to.
00410         */
00411         virtual void visitor_uppaal (DREAM::NODE_MAP* task_map, DREAM::NODE_MAP* channel_map, 
00412                 DREAM::NODE_MAP* timer_map, std::ofstream& f_stream)
00413 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00414                         throw (DREAM::Exception)
00415 #endif
00416         {};
00417 
00418         /** Generic nodes do not have worst case execution times.
00419         * Inherited classes may implement this feature.
00420         */
00421         virtual uint wcet () const
00422 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00423                 throw (DREAM::Exception)
00424 #endif
00425         ;
00426 
00427         /** Generic nodes do not have worst case execution times.
00428         * Inherited classes may implement this feature.
00429         */
00430         virtual void wcet (uint wcet)
00431 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00432                 throw (DREAM::Exception)
00433 #endif
00434         ;
00435 
00436 protected:
00437 
00438         /** Execution clock. */
00439         double clock_exec_;
00440 
00441         /** Dependent tasks. */
00442         DREAM::NodeList* dependent_map_;
00443 
00444         /** Executed flag is used to check unreachable tasks. */
00445         bool executed_;
00446 
00447         /** ID. */
00448         std::string id_;
00449 
00450         /** Pointer to the Thread. */
00451         DREAM::Thread* thread_ptr_;
00452 
00453         /** If this flag is true, the Node has dependents on remote CPUs and has to check branching points during the trace-based verification. */
00454         bool remote_dep_;
00455 };
00456 
00457 /** Timer model.
00458 * This class is the implementation of the Timer in the DRE Semantic Domain.
00459 */
00460 class Timer : public DREAM::Node
00461 {
00462 public:
00463         /** Constructor.
00464         * @param id specifies the name of the Timer.
00465         * @param thread_ptr defines the mapping of the Timer to a platform processor.
00466         * @param period specifies the period of the Timer.
00467         */
00468         Timer (const std::string& id, DREAM::Thread* thread_ptr, uint period);
00469         
00470         /** Constructor.
00471         * @param id specifies the name of the Timer.
00472         * @param thread_ptr defines the mapping of the Timer to a platform processor.
00473         * @param period specifies the worst case period of the Timer.
00474         * @param bcperiod specifies the best case period of the Timer.
00475         */
00476         Timer (const std::string& id, DREAM::Thread* thread_ptr, uint period, uint bcperiod);
00477         
00478         /** Copy constructor for Channels. */
00479         Timer (const DREAM::Timer& timer);
00480 
00481         /** Destructor. */
00482         virtual ~Timer ();
00483         
00484         /** Returns the best case period.
00485         * bcet () name is used to provide a unique interface for DREAM::Node inherited classes.
00486         * @return the best case period bcperiod_.
00487         */
00488         virtual uint bcet () const
00489 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00490                 throw (DREAM::Exception)
00491 #endif
00492         ;
00493 
00494 #ifdef DREAM_BRANCHING
00495         /** Sets the new execution time if branching points were found. */
00496         virtual void branching_point ()
00497 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00498                 throw (DREAM::Exception)
00499 #endif
00500         ;
00501 #endif
00502 
00503         /** Returns whether the Timer uses the best case or worst case period for the simulation.
00504         * @return the context of the Timer.
00505         */
00506         virtual DREAM::Context context () const
00507 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00508                 throw (DREAM::Exception)
00509 #endif
00510         ;
00511 
00512         /** Sets the Timer to use the specified context (e.g. in the simulation).
00513         * @param context is the context assumed.
00514         */
00515         virtual void context (DREAM::Context context)
00516 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00517                 throw (DREAM::Exception)
00518 #endif
00519         ;
00520 
00521         /** Reset execution clock value - clock_exec_.*/
00522         virtual void clock_exec_reset ();
00523         
00524         /** Models the passing of time - increments local clock clock_exec_.
00525         * @param clock_step specifies by how much do we have to increment the time.
00526         */
00527         virtual void clock_step (double clock_step);
00528         
00529         /** Tells when the Timer will generate the next event.
00530         * @return Time remaining till the next event generation (when clock_exec_ == period_).
00531         */
00532         virtual double next_event ();
00533 
00534 #ifdef DREAM_BRANCHING
00535         /** Sets the next execution time when the context is branchingpoint. */
00536         virtual void next_et (double next_et)
00537 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00538                 throw (DREAM::Exception)
00539 #endif
00540         ;
00541 #endif
00542 
00543         /** Returns the priority of the Timer.
00544         * The Timer's priority is the priority of its highest priority dependent Task. The function is used by the Uppaal
00545         * interpreter.
00546         * @return priority_ of the Thread which owns the Timer.
00547         */
00548         virtual uint priority () const
00549 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00550                 throw (DREAM::Exception)
00551 #endif
00552         ;
00553 
00554         /** Publishes an event to dependent tasks.
00555         * This function models synchronous event propagation by calling
00556         * the consume () functions of all the dependent Nodes.
00557         */
00558         virtual void publish ();
00559         
00560         /** Takes state transitions.
00561         * This function implements the state transitions of a Timer as specified by the DRE Semantic Domain.
00562         * Transitions are triggered when clock_exec_ reaches the period.
00563         */
00564         virtual void take_transitions ()
00565 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00566                 throw (DREAM::Exception)
00567 #endif
00568         ;
00569 
00570         /** This function is part of the IF system description generator.
00571         * @param task_map stores the Task pointers.
00572         * @param channel_map stores the Channel pointers.
00573         * @param timer_map stores the Timer pointers.
00574         * @param f_stream is the output stream to be written to.
00575         */
00576         virtual void visitor_if (DREAM::NODE_MAP* task_map, DREAM::NODE_MAP* channel_map, DREAM::NODE_MAP* timer_map, std::ofstream& f_stream)
00577 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00578                 throw (DREAM::Exception)
00579 #endif
00580         ;
00581 
00582         /** This function fills the IDs (names) of tasks, channels and timers to the parameter lists.
00583         * The function is used to generate output for model checkers.
00584         * @param task_map stores the Task pointers.
00585         * @param channel_map stores the Channel pointers.
00586         * @param timer_map stores the Timer pointers.
00587         */
00588         virtual void visitor_map (DREAM::NODE_MAP* task_map, DREAM::NODE_MAP* channel_map, 
00589                 DREAM::NODE_MAP* timer_map)
00590 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00591                         throw (DREAM::Exception)
00592 #endif
00593         ;
00594 
00595         /** This function is part of the Uppaal system description generator.
00596         * @param task_map stores the Task pointers.
00597         * @param channel_map stores the Channel pointers.
00598         * @param timer_map stores the Timer pointers.
00599         * @param f_stream is the output stream to be written.
00600         */
00601         virtual void visitor_uppaal (DREAM::NODE_MAP* task_map, DREAM::NODE_MAP* channel_map, 
00602                 DREAM::NODE_MAP* timer_map, std::ofstream& f_stream)
00603 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00604                         throw (DREAM::Exception)
00605 #endif
00606         ;
00607 
00608         /** Returns the period of the Timer.
00609         * wcet () name is used to provide a unique interface for DREAM::Node inherited classes.
00610         * @return the period of the Timer period_.
00611         */
00612         virtual uint wcet () const
00613 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00614                 throw (DREAM::Exception)
00615 #endif
00616         ;
00617 
00618 private:
00619         /** Best case period.
00620         * This construct can be used to model event generators which publish events in a certain interval.
00621         */
00622         uint bcperiod_;
00623 
00624         /** Specifies whether best case, worst case, or a random value is used for the execution time during the simulation. */
00625         DREAM::Context context_;
00626 
00627         /** The execution time. 
00628         * This value is from the interval [bcet, wcet] and is set according to the context.
00629         */
00630         double et_;
00631 
00632 #ifdef DREAM_BRANCHING
00633         /** The next execution time when the context is branchingpoint. 
00634         * This value is from the interval [bcet, wcet].
00635         */
00636         double next_et_;
00637 #endif
00638 
00639         /** Period of the Timer. */
00640         uint period_;
00641 };
00642 
00643 /** Real-time event Channel .
00644 * This class is the implementation of the Channel in the DRE Semantic Domain.
00645 */
00646 class Channel : public DREAM::Node
00647 {
00648 public:
00649         /** Constructor.
00650         * @param id specifies the name of the event channel.
00651         * @param thread_ptr defines the mapping of the Channel to a platform processor.
00652         * @param delay is the delay of the event channel.
00653         * @param buffersize specifies the size of the event channel buffer. Use '0' for no limit.
00654         */
00655         Channel (const std::string& id, DREAM::Thread* thread_ptr, uint delay, uint buffersize);
00656 
00657         /** Constructor.
00658         * @param id specifies the name of the event channel.
00659         * @param thread_ptr defines the mapping of the Channel to a platform processor.
00660         * @param delay is the worst case delay of the event channel.
00661         * @param bcdelay is the best case delay of the event channel.
00662         * @param buffersize specifies the size of the event channel buffer. Use '0' for no limit.
00663         */
00664         Channel (const std::string& id, DREAM::Thread* thread_ptr, uint delay, uint bcdelay, uint buffersize);
00665 
00666         /** Copy constructor for Channels.
00667         * @param channel is a pointer to the channel to be copied.
00668         */
00669         Channel (const DREAM::Channel& channel);
00670 
00671         /** Destructor */
00672         virtual ~Channel ();
00673 
00674         /** Adds a dependent Node to the current Channel.
00675         * This function also ensures that Channels cannot have more than 1 dependents.
00676         * @param node_ptr is the pointer to the dependent Node to be added.
00677         */
00678         virtual void add_dependent (DREAM::Node* node_ptr)
00679                 throw (DREAM::Exception);
00680 
00681         /** Returns the best case delay.
00682         * bcet () name is used to provide a unique interface for DREAM::Node inherited classes.
00683         */
00684         virtual uint bcet () const
00685 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00686                 throw (DREAM::Exception)
00687 #endif
00688         ;
00689 
00690 #ifdef DREAM_BRANCHING
00691         /** Sets the new execution time if branching points were found. */
00692         virtual void branching_point ()
00693 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00694                 throw (DREAM::Exception)
00695 #endif
00696         ;
00697 #endif
00698 
00699         /** Returns whether the Channel uses the best case or worst case delay for the simulation.
00700         * @return the context of the Channel.
00701         */
00702         virtual DREAM::Context context () const
00703 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00704                 throw (DREAM::Exception)
00705 #endif
00706         ;
00707 
00708         /** Sets the Channel to use the specified context (e.g. in the simulation).
00709         * @param context is the context assumed.
00710         */
00711         virtual void context (DREAM::Context context)
00712 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00713                 throw (DREAM::Exception)
00714 #endif
00715         ;
00716 
00717         /** Reset execution clock value - clock_exec_. */
00718         virtual void clock_exec_reset ();
00719         
00720         /** Models the passing of time.
00721         * Increments local clock clock_exec_.
00722         * @param clock_step specifies by how much do we have to increment the time.
00723         */
00724         virtual void clock_step (double clock_step);
00725         
00726         /** Consumes an event received from an event source.
00727         * This function is called by the publish () function of the event source and triggers state transitions.
00728         * The take_transitions () function will take the enabled transitions.
00729         */
00730         virtual void consume ()
00731 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00732                 throw (DREAM::Exception)
00733 #endif
00734         ;
00735 
00736         /** Returns true if all the dependents are idle. */
00737         virtual bool idle_dependents () const
00738 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00739                 throw (DREAM::Exception)
00740 #endif
00741         ;
00742 
00743         /** Tells when the Channel will generate the next event.
00744         * @return Time remaining till the next event generation (when clock_exec_ == delay_ and buffer_ != 0).
00745         */
00746         virtual double next_event ();
00747         
00748 #ifdef DREAM_BRANCHING
00749         /** Sets the next execution time when the context is branchingpoint. */
00750         virtual void next_et (double next_et)
00751 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00752                 throw (DREAM::Exception)
00753 #endif
00754         ;
00755 #endif
00756 
00757         /** Publishes an event to dependent tasks.
00758         * This function models synchronous event propagation by calling
00759         * the consume () functions of all the dependent Nodes.
00760         */
00761         virtual void publish ()
00762 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00763                 throw (DREAM::Exception)
00764 #endif
00765         ;
00766         
00767         /** Resets Timer (when restarting the simulation). */
00768         virtual void reset ();
00769 
00770         /** Takes state transitions.
00771         * This function implements the state transitions of a Channel as specified by the DRE Semantic Domain.
00772         * Transitions can be triggered by events coming from other Tasks, Timers or Schedulers.
00773         */
00774         virtual void take_transitions ()
00775 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00776                 throw (DREAM::Exception)
00777 #endif
00778         ;
00779 
00780         /** This function fills the IDs (names) of tasks, channels and timers to the parameter lists.
00781         * The function is used to generate output for model checkers.
00782         * @param task_map stores the Task pointers.
00783         * @param channel_map stores the Channel pointers.
00784         * @param timer_map stores the Timer pointers.
00785         */
00786         virtual void visitor_map (DREAM::NODE_MAP* task_map, DREAM::NODE_MAP* channel_map, DREAM::NODE_MAP* timer_map)
00787 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00788                 throw (DREAM::Exception)
00789 #endif
00790         ;
00791 
00792         /** This function is part of the Uppaal system description generator.
00793         * @param task_map stores the Task pointers.
00794         * @param channel_map stores the Channel pointers.
00795         * @param timer_map stores the Timer pointers.
00796         * @param f_stream is the output stream to be written to.
00797         */
00798         virtual void visitor_uppaal (DREAM::NODE_MAP* task_map, DREAM::NODE_MAP* channel_map, 
00799                 DREAM::NODE_MAP* timer_map, std::ofstream& f_stream)
00800 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00801                         throw (DREAM::Exception)
00802 #endif
00803         ;
00804 
00805         /** Returns delay_.
00806         * wcet () name is used to provide a unique interface for DREAM::Node inherited classes.
00807         */
00808         virtual uint wcet () const
00809 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00810                 throw (DREAM::Exception)
00811 #endif
00812         ;
00813 
00814 private:
00815         /** Best case delay.
00816         * This construct can be used to model event channels which have delays within a given interval.
00817         */
00818         uint bcdelay_;
00819 
00820         /** Specifies whether best case, worst case, or a random value is used for the execution time during the simulation. */
00821         DREAM::Context context_;
00822 
00823         /** Buffer of the event channel storing events. */
00824         uint buffer_;
00825 
00826         /** Specifies the size of the buffer.
00827         * If the buffer is full new events get lost.
00828         */
00829         uint buffersize_;
00830 
00831         /** Worst case delay of the event channel. */
00832         uint delay_;
00833 
00834         /** The execution time. 
00835         * This value is from the interval [bcet, wcet] and is set according to the context.
00836         */
00837         double et_;
00838 
00839 #ifdef DREAM_BRANCHING
00840         /** The next execution time when the context is branchingpoint. 
00841         * This value is from the interval [bcet, wcet].
00842         */
00843         double next_et_;
00844 #endif
00845 
00846         /** Reference to the event source. */
00847         DREAM::Node* source_ptr_;
00848 
00849         /** State of the Channel as specified by the DRE Semantic Domain. */
00850         enum State {idle, wait} state_;
00851 };
00852 
00853 /** Real-time Task.
00854 * This class is the implementation of the Task in the DRE Semantic Domain.
00855 */
00856 class Task : public DREAM::Node
00857 {
00858 public:
00859         /** Constructor.
00860         * @param id specifies the name of the Task.
00861         * @param thread_ptr defines the mapping of the Task to a platform processor.
00862         * @param wcet is the worst case execution time parameter of the Task.
00863         * @param deadline is the deadline of the task - deadlines are counted from the time when the task becomes enabled.
00864         */
00865         Task (const std::string& id, DREAM::Thread* thread_ptr, uint wcet, uint deadline);
00866 
00867         /** Constructor.
00868         * @param id specifies the name of the Task.
00869         * @param thread_ptr defines the mapping of the Task to a platform processor.
00870         * @param wcet is the worst case execution time parameter of the Task.
00871         * @param deadline is the deadline of the task - deadlines are counted from the time when the task becomes enabled.
00872         * @param subpriority is the subpriority of the task. Subpriorities can be used to model the queueing policies (FIFO, MUF etc.)
00873         */
00874         Task (const std::string& id, DREAM::Thread* thread_ptr, uint wcet, uint deadline, uint subpriority);
00875 
00876         /** Constructor.
00877         * @param id specifies the name of the Task.
00878         * @param thread_ptr defines the mapping of the Task to a platform processor.
00879         * @param bcet is the best case execution time parameter of the Task.
00880         * @param wcet is the worst case execution time parameter of the Task.
00881         * @param deadline is the deadline of the task - deadlines are counted from the time when the task becomes enabled.
00882         * @param subpriority is the subpriority of the task. Subpriorities can be used to model the queueing policies (FIFO, MUF etc.)
00883         */
00884         Task (const std::string& id, DREAM::Thread* thread_ptr, uint wcet, uint bcet, uint deadline, uint subpriority);
00885 
00886         /** Copy constructor for Tasks. 
00887         * Used in genetic algorithms.
00888         */
00889         Task (const DREAM::Task& task);
00890 
00891         /** Destructor. */
00892         virtual ~Task ();
00893 
00894         /** Operator overloading.
00895         * The Task will be copied except for the thread_ptr_.
00896         * @param task is the Task to be copied.
00897         */
00898         virtual void operator= (const DREAM::Task& task);
00899 
00900         /** Operator overloading.
00901         * @param task is the Task to be compared with this class.
00902         */
00903         virtual bool operator== (const DREAM::Task& task);
00904 
00905         /** Returns the best case execution time of the task.
00906         * @return the best case execution time bcet_. */
00907         virtual uint bcet () const
00908 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00909                 throw (DREAM::Exception)
00910 #endif
00911         ;
00912 
00913         /** Sets the best case execution time of the task .
00914         * @param bcet is the best case execution time parameter of the Task.
00915         */
00916         virtual void bcet (uint bcet)
00917 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00918                 throw (DREAM::Exception)
00919 #endif
00920         ;
00921 
00922 #ifdef DREAM_BRANCHING
00923         /** Sets the new execution time if branching points were found. */
00924         virtual void branching_point ()
00925 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00926                 throw (DREAM::Exception)
00927 #endif
00928         ;
00929 #endif
00930 
00931         /** Returns whether the Task uses the best case or worst case time for the simulation.
00932         * @return the context of the Timer.
00933         */
00934         virtual DREAM::Context context () const
00935 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00936                 throw (DREAM::Exception)
00937 #endif
00938         ;
00939 
00940         /** Sets the Task to use the specified context (e.g. in the simulation).
00941         * @param context is the context assumed.
00942         */
00943         virtual void context (DREAM::Context context)
00944 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00945                 throw (DREAM::Exception)
00946 #endif
00947         ;
00948 
00949         /** Returns the value of the deadline clock - clock_dl_. */
00950         virtual double clock_dl () const
00951 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00952                 throw (DREAM::Exception)
00953 #endif
00954         ;
00955 
00956         /** Resets deadline clock value - clock_dl_. */
00957         virtual void clock_dl_reset ();
00958 
00959         /** Resets execution clock value - clock_exec_. */
00960         virtual void clock_exec_reset ();
00961 
00962         /** Models the passing of time - increments local clock.
00963         * @param clock_step specifies by how much do we have to increment the time.
00964         */
00965         virtual void clock_step (double clock_step);
00966 
00967         /** Consumes an event received from an event source.
00968         * This function is called by the publish () function of the event source and triggers state transitions.
00969         * The take_transitions () function will take the enabled transitions.
00970         */
00971         virtual void consume ()
00972 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00973         throw (DREAM::Exception)
00974 #endif
00975         ;
00976 
00977         /** Returns the deadline of the task.
00978         * @return deadline of the clock deadline_. */
00979         virtual uint deadline () const
00980 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00981                 throw (DREAM::Exception)
00982 #endif
00983         ;
00984 
00985         /** Sets the deadline of the task.
00986         * Deadlines are counted from the time when the task becomes enabled.
00987         * @param deadline is the deadline of the task.
00988         */
00989         virtual void deadline (uint deadline)
00990 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
00991                 throw (DREAM::Exception)
00992 #endif
00993         ;
00994 
00995         /** Schedules the Task for execution.
00996         * This function will schedule the Task for execution.
00997         */
00998         virtual void execute ()
00999 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01000                 throw (DREAM::Exception)
01001 #endif
01002         ;
01003 
01004         /** Returns true if the Task is idle (used by Channels). */
01005         virtual bool isidle () const
01006 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01007                 throw (DREAM::Exception)
01008 #endif
01009         ;
01010 
01011         /** Tells when the Task will generate the next event.
01012         * @return Time remaining till the next event generation.
01013         */
01014         virtual double next_event ();
01015 
01016 #ifdef DREAM_BRANCHING
01017         /** Sets the next execution time when the context is branchingpoint. */
01018         virtual void next_et (double next_et)
01019 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01020                 throw (DREAM::Exception)
01021 #endif
01022         ;
01023 #endif
01024 
01025         /** Models the preemption of the task.
01026         * This function will take the state transition to the preempted state as specified by the DRE Semantic Domain.
01027         * It does not require calling the take_transition () function.
01028         */
01029         virtual void preempt ()
01030 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01031                 throw (DREAM::Exception)
01032 #endif
01033         ;
01034 
01035         /** Returns the priority of the Task - the priority of the Thread which executes it. */
01036         virtual uint priority () const
01037 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01038         throw (DREAM::Exception)
01039 #endif
01040         ;
01041 
01042         /** Sets the priority of the Task.
01043         * This function looks up whether there is a Thread with the requested priority on the actual CPU. If yes,
01044         * it redeploys the Task to that Thread. If not, returns with an Exception. This function is used by the
01045         * genetic algorithm when assigning priorities.
01046         * @param priority is the priority of the task.
01047         */
01048         virtual void priority (uint priority)
01049 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01050                 throw (DREAM::Exception)
01051 #endif
01052         ;
01053         
01054         /** Publishes an event to dependent tasks.
01055         * This function models synchronous event propagation by calling
01056         * the consume () functions of all the dependent Nodes.
01057         */
01058         virtual void publish ()
01059 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01060                 throw (DREAM::Exception)
01061 #endif
01062         ;
01063 
01064         /** Resets task (after a frame overrun or when restarting the simulation). */
01065         virtual void reset ();
01066 
01067         /** Returns the sub-priority of the Task - subpriority_. */
01068         virtual uint subpriority () const
01069 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01070                 throw (DREAM::Exception)
01071 #endif
01072         ;
01073 
01074         /** Sets the subpriority of the Task.
01075         * @param subpriority is the subpriority of the task. Subpriorities can be used to model the queueing policies (FixedPriority, FIFO, MUF etc.)
01076         */
01077         virtual void subpriority (uint subpriority)
01078 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01079                 throw (DREAM::Exception)
01080 #endif
01081         ;
01082 
01083         /** Takes state transitions.
01084         * This function implements the state transitions of a Task as specified by the DRE Semantic Domain.
01085         * Transitions can be triggered by events coming from other Tasks, Timers, event Channels or Schedulers.
01086         */
01087         virtual void take_transitions ()
01088 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01089                 throw (DREAM::Exception)
01090 #endif
01091         ;
01092 
01093         /** This function is part of the IF system description generator.
01094         * @param task_map stores the Task pointers.
01095         * @param channel_map stores the Channel pointers.
01096         * @param timer_map stores the Timer pointers.
01097         * @param f_stream is the output stream to be written to.
01098         */
01099         virtual void visitor_if (DREAM::NODE_MAP* task_map, DREAM::NODE_MAP* channel_map, DREAM::NODE_MAP* timer_map, std::ofstream& f_stream)
01100 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01101                 throw (DREAM::Exception)
01102 #endif
01103         ;
01104 
01105         /** This function fills the IDs (names) of tasks, channels and timers to the parameter lists.
01106         * The function is used to generate output for model checkers.
01107         * @param task_map stores the Task pointers.
01108         * @param channel_map stores the Channel pointers.
01109         * @param timer_map stores the Timer pointers.
01110         */
01111         virtual void visitor_map (DREAM::NODE_MAP* task_map, DREAM::NODE_MAP* channel_map, DREAM::NODE_MAP* timer_map)
01112 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01113                 throw (DREAM::Exception)
01114 #endif
01115         ;
01116 
01117         /** This function builds the task list for manipulation.
01118         * The function is used by genetic algorithms.
01119         * @param task_avltree stores the Task pointers.
01120         */
01121         virtual void visitor_task_avltree (DREAM::TASK_AVLTREE* task_avltree)
01122 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01123                 throw (DREAM::Exception)
01124 #endif
01125         ;
01126 
01127         /** This function updates task values in the system.
01128         * The function is used by genetic algorithms.
01129         * @param task_avltree stores the Task pointers.
01130         */
01131         virtual void visitor_update_task_avltree (DREAM::TASK_AVLTREE* task_avltree)
01132 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01133                 throw (DREAM::Exception)
01134 #endif
01135         ;
01136 
01137         /** This function is part of the Uppaal system description generator.
01138         * @param task_map stores the Task pointers.
01139         * @param channel_map stores the Channel pointers.
01140         * @param timer_map stores the Timer pointers.
01141         * @param f_stream is the output stream to be written to.
01142         */
01143         virtual void visitor_uppaal (DREAM::NODE_MAP* task_map, DREAM::NODE_MAP* channel_map, DREAM::NODE_MAP* timer_map, std::ofstream& f_stream)
01144 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01145                 throw (DREAM::Exception)
01146 #endif
01147         ;
01148 
01149         /** Returns the worst case execution time of the task.
01150         * @return the worst case execution time wcet_.
01151         */
01152         virtual uint wcet () const
01153 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01154                 throw (DREAM::Exception)
01155 #endif
01156         ;
01157 
01158         /** Sets the worst case execution time of the task.
01159         * @param wcet is the worst case execution time parameter of the Task.
01160         */
01161         virtual void wcet (uint wcet)
01162 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01163                 throw (DREAM::Exception)
01164 #endif
01165         ;
01166 
01167 #ifndef DREAM_RACE_CONDITION_ZERO
01168         /** Returns true if all of the sources of the task are zero-delay channels */
01169         virtual bool zero_delay_race_condition (DREAM::System* system_ptr)
01170 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01171                 throw (DREAM::Exception)
01172 #endif
01173         ;
01174 #endif
01175 
01176 protected:
01177 
01178         /** Constructor.
01179         * This contructor is only to be used by the copy constructors of derived classes.
01180         * @param id specifies the name of the Task.
01181         * @param thread_ptr defines the mapping of the Task to a platform processor.
01182         * @param bcet is the best case execution time parameter of the Task.
01183         * @param wcet is the worst case execution time parameter of the Task.
01184         * @param deadline is the deadline of the task - deadlines are counted from the time when the task becomes enabled.
01185         * @param subpriority is the subpriority of the task. Subpriorities can be used to model the queueing policies (FIFO, MUF etc.)
01186         * @param context specifies the context of the Task.
01187         * @param et specifies the actual execution time of the Task.
01188         * @param state specifies the state of the Task.
01189         * @param clock_dl specifies the deadline clock of the Task.
01190         */
01191         Task (const std::string& id, DREAM::Thread* thread_ptr, uint wcet, uint bcet, uint deadline, uint subpriority,
01192                         DREAM::Context context, double et, DREAM::State state, double clock_dl);
01193 
01194         /** Best case execution time. */
01195         uint bcet_;
01196 
01197         /** Specifies whether best case, worst case, or a random value is used for the execution time during the simulation. */
01198         DREAM::Context context_;
01199 
01200         /** Deadline clock. */
01201         double clock_dl_;
01202 
01203         /** Deadline. */
01204         uint deadline_;
01205 
01206         /** The execution time. 
01207         * This value is from the interval [bcet, wcet] and is set according to the context.
01208         */
01209         double et_;
01210 
01211 #ifdef DREAM_BRANCHING
01212         /** The next execution time when the context is branchingpoint. 
01213         * This value is from the interval [bcet, wcet].
01214         */
01215         double next_et_;
01216 #endif
01217 
01218         /** State of the Task as specified by the DRE Semantic Domain. */
01219         DREAM::State state_;
01220 
01221         /** Sub-priority.
01222         * Subpriorities can be used to model the queueing policies (FIFO, MUF etc.)
01223         */
01224         uint subpriority_;
01225 
01226         /** Worst case execution time. */
01227         uint wcet_;
01228 
01229 #ifndef DREAM_RACE_CONDITION_ZERO
01230         /** This variable is used to speed up the search whether all sources are zero-delay */
01231         uint zero_delay_race_condition_;
01232 #endif
01233 };
01234 
01235 /** Power Aware Real-time Task.
01236 * This class extends real-time tasks with variable speed to express voltage scaling as well as power consumption.
01237 *
01238 class PowerAwareTask : public DREAM::Task
01239 {
01240 public:
01241         /** Constructor.
01242         * @param id specifies the name of the PowerAwareTask.
01243         * @param thread_ptr defines the mapping of the PowerAwareTask to a platform processor.
01244         * @param wcet is the worst case execution time parameter of the PowerAwareTask.
01245         * @param deadline is the deadline of the task - deadlines are counted from the time when the task becomes enabled.
01246         *
01247         PowerAwareTask (const std::string& id, DREAM::Thread* thread_ptr, uint wcet, uint deadline);
01248 
01249         /** Constructor.
01250         * @param id specifies the name of the PowerAwareTask.
01251         * @param thread_ptr defines the mapping of the PowerAwareTask to a platform processor.
01252         * @param wcet is the worst case execution time parameter of the PowerAwareTask.
01253         * @param deadline is the deadline of the task - deadlines are counted from the time when the task becomes enabled.
01254         * @param subpriority is the subpriority of the task. Subpriorities can be used to model the queueing policies (FIFO, MUF etc.)
01255         *
01256         PowerAwareTask (const std::string& id, DREAM::Thread* thread_ptr, uint wcet, uint deadline, uint subpriority);
01257 
01258         /** Constructor.
01259         * @param id specifies the name of the PowerAwareTask.
01260         * @param thread_ptr defines the mapping of the PowerAwareTask to a platform processor.
01261         * @param bcet is the best case execution time parameter of the PowerAwareTask.
01262         * @param wcet is the worst case execution time parameter of the PowerAwareTask.
01263         * @param deadline is the deadline of the task - deadlines are counted from the time when the task becomes enabled.
01264         * @param subpriority is the subpriority of the task. Subpriorities can be used to model the queueing policies (FIFO, MUF etc.)
01265         *
01266         PowerAwareTask (const std::string& id, DREAM::Thread* thread_ptr, uint wcet, uint bcet, uint deadline, uint subpriority);
01267 
01268         /** Copy constructor for Tasks. 
01269         * Used in genetic algorithms.
01270         *
01271         PowerAwareTask (const DREAM::PowerAwareTask& powerawaretask);
01272 
01273         /** Destructor. *
01274         virtual ~PowerAwareTask ();
01275 
01276         /** Operator overloading.
01277         * The Task will be copied except for the thread_ptr_.
01278         * @param powerawaretask is the Task to be copied.
01279         *
01280         virtual void operator= (const DREAM::PowerAwareTask& powerawaretask);
01281 
01282         /** Operator overloading.
01283         * @param powerawaretask is the Task to be compared with this class.
01284         *
01285         virtual bool operator== (const DREAM::PowerAwareTask& powerawaretask);
01286 
01287         /** Models the passing of time - increments local clock.
01288         * The speed of the scheduler influences this function. If slower QoSLevels are used the execution clock is incremented at 
01289         * a slower rate than the deadline clock which simply measures the time elapsed.
01290         * @param clock_step specifies by how much do we have to increment the time.
01291         *
01292         virtual void clock_step (double clock_step);
01293 
01294         /** Tells when the PowerAwareTask will generate the next event.
01295         * The PowerAwareTask will only generate an event if it is executing, otherwise it returns 0. The speed of the scheduler influences this function.
01296         * If slower QoSLevels are used events will be generated later proportionally. Note that the speed can change during execution.
01297         * @return Time remaining till the next event generation.
01298         *
01299         virtual double next_event ();
01300 
01301 };*/
01302 
01303 #ifdef DREAM_RACE_CONDITION
01304 /** 
01305 * This data structure is used by the model checker to introduce priority inversions into the model. 
01306 * The priority inversions are used to check for race conditions. This class implements a DREAM::AVLTree (AVL-tree)
01307 * within a LinkedList and iterator data structures to achieve better verification performance.
01308 */
01309 class PriorityInversionList
01310 {
01311 public:
01312         /** Constructor. */
01313         PriorityInversionList (DREAM::System* system_ptr);
01314 
01315         /** Destructor. */
01316         ~PriorityInversionList ();
01317 
01318         /** This function first checks whether the task_avltree parameter is already in the list, if not it inserts it in the data structure. */
01319         void add (const DREAM::TASK_AVLTREE* task_avltree_ptr, DREAM::Task* task_ptr)
01320 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01321                 throw (DREAM::Exception)
01322 #endif
01323         ;
01324 
01325         /** Clears the AVLTree, and frees up memory. */
01326         void destroy ();
01327 
01328         /** This function returns which Task to execute given the parameter AVLTree. */
01329         DREAM::Task* find_current (const DREAM::TASK_AVLTREE* task_avltree_ptr, DREAM::Task* task_ptr)
01330 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01331                 throw (DREAM::Exception)
01332 #endif
01333         ;
01334 
01335         /** This function increments the task_id_list_iter value if there are more elements in the AVL tree corresponding to
01336         * task_avltree_list_iter, otherwise it calls itself recursively for the next tree.
01337         */
01338         bool increment (TASK_AVLTREE_LIST::iterator task_avltree_list_iter,
01339                 TASK_ID_LIST::iterator task_id_list_iter);
01340 
01341         /** This function introduces a single priority inversion in the task_avltree_list_.
01342         * The function returns false if all permutations of priority inversions have been checked.
01343         */
01344         bool inversion ();
01345 
01346 private:
01347         /** The function returns true if the parameter task_avltree can be found in the data structure. */
01348         DREAM::Task* find (const DREAM::TASK_AVLTREE* task_avltree_ptr, DREAM::Task* task_ptr)
01349 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING
01350                 throw (DREAM::Exception)
01351 #endif
01352         ;
01353 
01354         /** task_avltree_list_ stores priority inversions introduced at simulation time. */
01355         TASK_AVLTREE_LIST task_avltree_list_;
01356 
01357         /** task_id_ list, used in the inversion () function. */
01358         TASK_ID_LIST task_id_list_;
01359 
01360         /** Pointer to the system.
01361         * Used by the find () method to check for race conditions.
01362         */
01363         DREAM::System* system_ptr_;
01364 };
01365 #endif
01366 
01367 }
01368 
01369 #endif

Generated on Fri Jul 27 18:30:03 2007 for DREAM by  doxygen 1.5.1