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

StrictPolicyImpl.hh

Go to the documentation of this file.
00001 /*
00002  * StrictPolicyImpl.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 StrictPolicyImpl.hh
00014  *
00015  * Header file for the StrictPolicyImpl class.
00016  */
00017 
00018 #ifndef _strict_policy_impl_hh
00019 #define _strict_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 #include "rt_scheduler.h"
00030 
00031 /**
00032  * An implementation of the StrictPolicy interface.
00033  */
00034 class StrictPolicyImpl : public virtual POA_BrokerPolicies::StrictPolicy
00035 {
00036     
00037 public:
00038 
00039     /**
00040      * Construct a StrictPolicyImpl object with the given values.
00041      *
00042      * @param name The name of this object as registered with the
00043      *             NamingService.
00044      */
00045     StrictPolicyImpl(const char *name);
00046 
00047     /**
00048      * Deconstruct the policy.
00049      */
00050     virtual ~StrictPolicyImpl();
00051 
00052     /** @copydoc Broker::Policy::Name */
00053     virtual char *Name(void)
00054         throw (CORBA::SystemException);
00055     
00056     /** @copydoc Broker::Policy::AddTask */
00057     virtual void AddTask(Broker::Task_ptr new_task,
00058                          const Broker::ScheduleParameters &sp)
00059         throw (CORBA::SystemException,
00060                Broker::DuplicateScheduleParameter,
00061                Broker::InvalidScheduleParameter,
00062                Broker::MissingScheduleParameter);
00063     /** @copydoc Broker::Policy::RemoveTask */
00064     virtual void RemoveTask(Broker::Task_ptr added_task)
00065         throw (CORBA::SystemException);
00066     
00067     /** @copydoc Broker::Policy::GetTaskList */
00068     virtual Broker::TaskList *GetTaskList(void)
00069         throw (CORBA::SystemException);
00070 
00071     /** @copydoc Broker::Policy::Activate */
00072     virtual void Activate(const Broker::TaskList &tasks)
00073         throw (CORBA::SystemException);
00074     /** @copydoc Broker::Policy::Deactivate */
00075     virtual void Deactivate(void)
00076         throw (CORBA::SystemException);
00077     
00078     /** @copydoc Broker::Policy::ChangeTaskCPU */
00079     virtual Broker::CPUReserve ChangeTaskCPU(Broker::RealTimeTask_ptr task,
00080                                              const Broker::CPUReserve &advice)
00081         throw (CORBA::SystemException, Broker::InvalidState);
00082 
00083     /** @copydoc BrokerPolicies::StrictPolicy::GetMaxCPUAllocation */
00084     virtual CORBA::Float GetMaxCPUAllocation(void)
00085         throw (CORBA::SystemException);
00086     /** @copydoc BrokerPolicies::StrictPolicy::SetMaxCPUAllocation */
00087     virtual void SetMaxCPUAllocation(CORBA::Float amount)
00088         throw (CORBA::SystemException);
00089 
00090     /** @copydoc BrokerPolicies::StrictPolicy::SetTaskPriority */
00091     virtual void SetTaskPriority(Broker::Task_ptr task, CORBA::Short priority)
00092         throw (CORBA::SystemException);
00093 
00094     /** @copydoc BrokerPolicies::StrictPolicy::GetTaskPriority */
00095     virtual CORBA::Short GetTaskPriority(Broker::Task_ptr task)
00096         throw (CORBA::SystemException);
00097 
00098     /**
00099      * Maximum percentage of CPU to allocate to tasks.
00100      */
00101     const static float DEFAULT_MAX_USED_CPU = 0.75;
00102 
00103     /**
00104      * Minimum percentage of CPU to allocate to a single task.
00105      */
00106     const static float DEFAULT_MIN_TASK_CPU = 0.02;
00107 
00108 private:
00109 
00110     struct TaskPriority;
00111 
00112     /**
00113      * List node used to track changes to be made in the low-level scheduler.
00114      */
00115     struct ChangeNode {
00116         struct lnMinNode cn_Link;
00117         struct TaskPriority *cn_Parent;
00118         CORBA::ULong cn_NewTime;
00119     };
00120 
00121     /**
00122      * List node used to track tasks that this policy is managing.
00123      */
00124     struct TaskPriority {
00125         struct lnNode tp_Link;
00126         RealTimeSchedule tp_Schedule;
00127         CORBA::ULong tp_ComputeTime;
00128         CORBA::ULong tp_RequestedTime;
00129         rts_schedulable_t tp_Schedulable;
00130         Broker::RealTimeTask_var tp_Task;
00131         struct ChangeNode tp_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 TaskPriority node that corresponds to the given task.
00141      *
00142      * @param task The Broker::RealTimeTask object to look up.
00143      * @return The TaskPriority list node that has the given task object.
00144      * @exception Broker::Internal If no TaskPriority node exists for the given
00145      *            task.
00146      */
00147     struct TaskPriority *FindTaskPriority(Broker::RealTimeTask_ptr task);
00148 
00149     /**
00150      * Detect changes in the amount of requested/available compute time or
00151      * priorities, and map them onto the OS scheduler.
00152      */
00153     void RedistributeCPU(void);
00154     
00155     /** The name of this object as registered with the NamingService. */
00156     CORBA::String_var sp_Name;
00157 
00158     /** The maximum percentage of CPU time that we are allowed to allocate. */
00159     float sp_MaxUsedCPU;
00160 
00161     /** The minimum percentage of CPU time that a task must have. */
00162     float sp_MinTaskCPU;
00163 
00164     /** A list of TaskPriority objects */
00165     struct lnList sp_List;
00166     
00167     /** The largest deadline of the tasks managed by this policy. */
00168     CORBA::ULong sp_MaxDeadline;
00169 
00170 };
00171 
00172 #endif

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