00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00032
00033 class WeightedPolicyImpl : public virtual POA_BrokerPolicies::WeightedPolicy
00034 {
00035
00036 public:
00037
00038
00039
00040
00041
00042
00043
00044 WeightedPolicyImpl(const char *name);
00045
00046
00047
00048
00049 virtual ~WeightedPolicyImpl();
00050
00051
00052 virtual char *Name(void)
00053 throw (CORBA::SystemException);
00054
00055
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
00063 virtual void RemoveTask(Broker::Task_ptr added_task)
00064 throw (CORBA::SystemException);
00065
00066
00067 virtual Broker::TaskList *GetTaskList(void)
00068 throw (CORBA::SystemException);
00069
00070
00071 virtual void Activate(const Broker::TaskList &tasks)
00072 throw (CORBA::SystemException);
00073
00074 virtual void Deactivate(void)
00075 throw (CORBA::SystemException);
00076
00077
00078 virtual Broker::CPUReserve ChangeTaskCPU(Broker::RealTimeTask_ptr task,
00079 const Broker::CPUReserve &advice)
00080 throw (CORBA::SystemException, Broker::InvalidState);
00081
00082
00083 virtual CORBA::Float GetMaxCPUAllocation(void)
00084 throw (CORBA::SystemException);
00085
00086 virtual void SetMaxCPUAllocation(CORBA::Float amount)
00087 throw (CORBA::SystemException);
00088
00089
00090 virtual void SetTaskWeight(Broker::Task_ptr task, CORBA::UShort weight)
00091 throw (CORBA::SystemException);
00092
00093
00094 virtual CORBA::UShort GetTaskWeight(Broker::Task_ptr task)
00095 throw (CORBA::SystemException);
00096
00097
00098
00099
00100 const static float DEFAULT_MAX_USED_CPU = 0.75;
00101
00102
00103
00104
00105 const static float DEFAULT_MIN_TASK_CPU = 0.02;
00106
00107 private:
00108
00109 struct TaskData;
00110
00111
00112
00113
00114 struct ChangeNode {
00115 struct lnMinNode cn_Link;
00116 struct TaskData *cn_Parent;
00117 CORBA::ULong cn_NewTime;
00118 };
00119
00120
00121
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
00136
00137 void RepairTaskList(void);
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 struct TaskData *FindTaskData(Broker::RealTimeTask_ptr task);
00148
00149
00150
00151
00152 void RedistributeCPU(void);
00153
00154
00155 CORBA::String_var wp_Name;
00156
00157
00158 float wp_MaxUsedCPU;
00159
00160
00161 float wp_MinTaskCPU;
00162
00163
00164 struct lnList wp_List;
00165
00166
00167 CORBA::ULong wp_MaxDeadline;
00168
00169
00170 unsigned long long wp_TotalWeightedComputeTime;
00171
00172 };
00173
00174 #endif