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

WeightedPolicyImpl.hh

Go to the documentation of this file.
00001 /*
00002  * WeightedPolicyImpl.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 WeightedPolicyImpl.hh
00014  *
00015  * Header file for the WeightedPolicyImpl class.
00016  */
00017 
00018 #ifndef _weighted_policy_impl_hh
00019 #define _weighted_policy_impl_hh
00020 
00021 #include "BrokerC.h"
00022 #include "BrokerS.h"
00023 
00024 #include "StrictPolicyS.h"
00025 
00026 #include "RealTimeSchedule.hh"
00027 
00028 #include "listNode.h"
00029 
00030 /**
00031  * An implementation of the WeightedPolicy interface.
00032  */
00033 class WeightedPolicyImpl : public virtual POA_BrokerPolicies::WeightedPolicy
00034 {
00035     
00036 public:
00037 
00038     /**
00039      * Construct a WeightedPolicyImpl object with the given values.
00040      *
00041      * @param name The name of this object as registered with the
00042      *             NamingService.
00043      */
00044     WeightedPolicyImpl(const char *name);
00045 
00046     /**
00047      * Deconstruct the policy.
00048      */
00049     virtual ~WeightedPolicyImpl();
00050 
00051     /** @copydoc Broker::Policy::Name */
00052     virtual char *Name(void)
00053         throw (CORBA::SystemException);
00054     
00055     /** @copydoc Broker::Policy::AddTask */
00056     virtual void AddTask(Broker::Task_ptr new_task,
00057                          const Broker::ScheduleParameters &sp)
00058         throw (CORBA::SystemException,
00059                Broker::DuplicateScheduleParameter,
00060                Broker::InvalidScheduleParameter,
00061                Broker::MissingScheduleParameter);
00062     /** @copydoc Broker::Policy::RemoveTask */
00063     virtual void RemoveTask(Broker::Task_ptr added_task)
00064         throw (CORBA::SystemException);
00065     
00066     /** @copydoc Broker::Policy::GetTaskList */
00067     virtual Broker::TaskList *GetTaskList(void)
00068         throw (CORBA::SystemException);
00069 
00070     /** @copydoc Broker::Policy::Activate */
00071     virtual void Activate(const Broker::TaskList &tasks)
00072         throw (CORBA::SystemException);
00073     /** @copydoc Broker::Policy::Deactivate */
00074     virtual void Deactivate(void)
00075         throw (CORBA::SystemException);
00076     
00077     /** @copydoc Broker::Policy::ChangeTaskCPU */
00078     virtual Broker::CPUReserve ChangeTaskCPU(Broker::RealTimeTask_ptr task,
00079                                              const Broker::CPUReserve &advice)
00080         throw (CORBA::SystemException, Broker::InvalidState);
00081 
00082     /** @copydoc Broker::Policy::GetMaxCPUAllocation */
00083     virtual CORBA::Float GetMaxCPUAllocation(void)
00084         throw (CORBA::SystemException);
00085     /** @copydoc Broker::Policy::SetMaxCPUAllocation */
00086     virtual void SetMaxCPUAllocation(CORBA::Float amount)
00087         throw (CORBA::SystemException);
00088 
00089     /** @copydoc BrokerPolicies::WeightedPolicy::SetTaskWeight */
00090     virtual void SetTaskWeight(Broker::Task_ptr task, CORBA::UShort weight)
00091         throw (CORBA::SystemException);
00092 
00093     /** @copydoc BrokerPolicies::WeightedPolicy::GetTaskWeight */
00094     virtual CORBA::UShort GetTaskWeight(Broker::Task_ptr task)
00095         throw (CORBA::SystemException);
00096 
00097     /**
00098      * Maximum percentage of CPU to allocate to tasks.
00099      */
00100     const static float DEFAULT_MAX_USED_CPU = 0.75;
00101 
00102     /**
00103      * Minimum percentage of CPU to allocate to a single task.
00104      */
00105     const static float DEFAULT_MIN_TASK_CPU = 0.02;
00106 
00107 private:
00108 
00109     struct TaskData;
00110 
00111     /**
00112      * List node used to track changes to be made in the low-level scheduler.
00113      */
00114     struct ChangeNode {
00115         struct lnMinNode cn_Link;
00116         struct TaskData *cn_Parent;
00117         CORBA::ULong cn_NewTime;
00118     };
00119 
00120     /**
00121      * List node used to track tasks that this policy is managing.
00122      */
00123     struct TaskData {
00124         struct lnMinNode td_Link;
00125         RealTimeSchedule td_Schedule;
00126         CORBA::UShort td_Weight;
00127         CORBA::ULong td_ComputeTime;
00128         CORBA::ULong td_RequestedTime;
00129         rts_schedulable_t td_Schedulable;
00130         Broker::RealTimeTask_var td_Task;
00131         struct ChangeNode td_ChangeLink;
00132     };
00133 
00134     /**
00135      * Repair the task list by removing any dead/unreachable objects.
00136      */
00137     void RepairTaskList(void);
00138 
00139     /**
00140      * Find the TaskData node that corresponds to the given task.
00141      *
00142      * @param task The Broker::RealTimeTask object to look up.
00143      * @return The TaskData list node that has the given task object.
00144      * @exception Broker::Internal If no TaskData node exists for the given
00145      * task.
00146      */
00147     struct TaskData *FindTaskData(Broker::RealTimeTask_ptr task);
00148 
00149     /**
00150      * Redistribute CPU to any tasks managed by this policy.
00151      */
00152     void RedistributeCPU(void);
00153     
00154     /** The name of this object as registered with the NamingService. */
00155     CORBA::String_var wp_Name;
00156 
00157     /** The maximum percentage of CPU time that we are allowed to allocate. */
00158     float wp_MaxUsedCPU;
00159 
00160     /** The minimum percentage of CPU time that a task must have. */
00161     float wp_MinTaskCPU;
00162 
00163     /** A list of TaskData objects */
00164     struct lnList wp_List;
00165     
00166     /** The largest deadline of the tasks managed by this policy. */
00167     CORBA::ULong wp_MaxDeadline;
00168 
00169     /** Cached value for the weighted compute time of all the tasks. */
00170     unsigned long long wp_TotalWeightedComputeTime;
00171     
00172 };
00173 
00174 #endif

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