Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

BasicDelegate.hh

Go to the documentation of this file.
00001 /*
00002  * BasicDelegate.hh
00003  *
00004  * Copyright (c) 2003, 2004 The University of Utah and the Flux Group.
00005  * All rights reserved.
00006  *
00007  * This file is licensed under the terms of the GNU Public License.  
00008  * See the file "license.terms" for restrictions on redistribution 
00009  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00010  */
00011 
00012 /**
00013  * @file BasicDelegate.hh
00014  *
00015  * Header file for a delegate that makes basic reports to a
00016  * Broker::RealTimeAdvocate.
00017  */
00018 
00019 #ifndef _basic_delegate_hh
00020 #define _basic_delegate_hh
00021 
00022 #include <sys/types.h>
00023 #include <sys/time.h>
00024 #include <sys/resource.h>
00025 
00026 #include <rk.h>
00027 #include <rk_stub.h>
00028 
00029 #include <time_util.h>
00030 
00031 #include <BrokerC.h>
00032 
00033 #include "FakeDelegate.hh"
00034 
00035 /**
00036  * A simple delegate that computes the number of deadlines missed and passes
00037  * the value to Broker::RealTimeAdvocate::ReportCPU.
00038  */
00039 class BasicDelegate : public FakeDelegate
00040 {
00041     
00042 public:
00043 
00044     /**
00045      * Construct a BasicDelegate with the given values.  This includes:
00046      *
00047      * @li Creating the process with rk_stub_mk_pid.
00048      * @li Initializing the bd_TaskDescription and bd_CPUSchedule parameter
00049      *     lists.
00050      * @li and initializing internal state.
00051      *
00052      * @param name The name of the process.  This will be passed on to
00053      *             rk_stub_mk_pid.
00054      * @param period The period of the process in microseconds.
00055      * @param deadline The deadline of the process in microseconds and relative
00056      *                 to the start of the period.
00057      */
00058     BasicDelegate(const char *name,
00059                   unsigned long period,
00060                   unsigned long deadline);
00061 
00062     /**
00063      * Deconstruct a BasicDelegate.
00064      */
00065     virtual ~BasicDelegate();
00066 
00067     /**
00068      * Premethod callback that just records the current time.
00069      *
00070      * @return RKSP_OK if the process is on schedule or RKSP_DROP if it is
00071      * running late and needs to drop data in order to catch up.
00072      */
00073     virtual rk_stub_precall_retval_t precall(void);
00074 
00075     /**
00076      * Postmethod callback that computes how many deadlines have been missed
00077      * and reports the results to bd_Advocate.
00078      */
00079     virtual void postcall(void);
00080 
00081     /**
00082      * TaskParameters constructed by the object that can be passed on to
00083      * Broker::TaskFactory::CreateTask.
00084      */
00085     Broker::TaskParameters bd_TaskDescription;
00086 
00087     /**
00088      * ScheduleParameters constructed by the object that can be passed on to
00089      * Broker::Task::BeginScheduling.
00090      */
00091     Broker::ScheduleParameters bd_CPUSchedule;
00092 
00093     /**
00094      * The process' advocate, this must be set by the code using the object.
00095      * The user must also call Broker::Task::BeginCPUScheduling and
00096      * Broker::Task::EndCPUScheduling.
00097      */
00098     Broker::RealTimeTask_var bd_Advocate;
00099 
00100     /**
00101      * The keyed parameters to pass through to ReportCPU.
00102      */
00103     Broker::KeyedReportParameters bd_KeyedReportParameters;
00104 
00105 protected:
00106 
00107     /**
00108      * The period of the process in microseconds.
00109      */
00110     unsigned long bd_Period;
00111     
00112     /**
00113      * The deadline of the process in microseconds and relative to the start of
00114      * the period.
00115      */
00116     unsigned long bd_Deadline;
00117 
00118     /**
00119      * The number of data segments to drop in order to get back on schedule.
00120      * This will be set by postcall() when it detects how many deadlines have
00121      * been missed.
00122      */
00123     int bd_AdviseDrop;
00124 
00125     /**
00126      * The simulated process ID.
00127      */
00128     pid_t bd_PID;
00129 
00130     /**
00131      * The "method" starting time as recorded by precall().
00132      */
00133     struct timespec bd_Start;
00134 
00135     /**
00136      * The resource usage at the "method" starting time.
00137      */
00138     struct rusage bd_RUStart;
00139     
00140 };
00141 
00142 #endif

Generated on Fri Oct 22 07:50:24 2004 for CPU Broker by  doxygen 1.3.9.1