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

StrictPolicyImpl.hh

Go to the documentation of this file.
00001 /*
00002  * StrictPolicyImpl.hh
00003  *
00004  * Copyright (c) 2003 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 
00030 /**
00031  * An implementation of the StrictPolicy interface.
00032  */
00033 class StrictPolicyImpl : public virtual POA_StrictPolicy
00034 {
00035     
00036 public:
00037 
00038     /**
00039      * Construct a StrictPolicyImpl object with the given values.
00040      *
00041      * @param name The name of this object as registered with the
00042      *             NamingService.
00043      */
00044     StrictPolicyImpl(const char *name);
00045 
00046     /**
00047      * Deconstruct the policy.
00048      */
00049     virtual ~StrictPolicyImpl();
00050 
00051     /** @copydoc Broker::Policy::Name */
00052     char *Name(void)
00053         throw (CORBA::SystemException);
00054     
00055     /** @copydoc Broker::Policy::AddTask */
00056     void AddTask(Broker::Task_ptr task)
00057         throw (CORBA::SystemException);
00058     /** @copydoc Broker::Policy::RemoveTask */
00059     void RemoveTask(Broker::Task_ptr task)
00060         throw (CORBA::SystemException);
00061     
00062     /** @copydoc Broker::Policy::Activate */
00063     void Activate(const Broker::TaskList &tl)
00064         throw (CORBA::SystemException);
00065     /** @copydoc Broker::Policy::Deactivate */
00066     void Deactivate(void)
00067         throw (CORBA::SystemException);
00068     
00069     /** @copydoc Broker::Policy::ChangeTaskCPU */
00070     void ChangeTaskCPU(Broker::RealTimeTask_ptr task,
00071                        CORBA::ULong ct,
00072                        CORBA::ULong status,
00073                        CORBA::ULong advice)
00074         throw (CORBA::SystemException, Broker::InvalidState);
00075 
00076     /** @copydoc StrictPolicy::GetTaskPriority */
00077     Broker::TaskList *GetTaskList(void)
00078         throw (CORBA::SystemException);
00079 
00080     /** @copydoc StrictPolicy::SetTaskPriority */
00081     void SetTaskPriority(Broker::Task_ptr task, CORBA::Short priority)
00082         throw (CORBA::SystemException);
00083 
00084     /** @copydoc StrictPolicy::GetTaskPriority */
00085     CORBA::Short GetTaskPriority(Broker::Task_ptr task)
00086         throw (CORBA::SystemException);
00087 
00088     /**
00089      * Maximum percentage of CPU to allocate to tasks.
00090      */
00091     const static float MAX_USED_CPU = 0.75;
00092 
00093     /**
00094      * Minimum percentage of CPU to allocate to a single task.
00095      */
00096     const static float MIN_TASK_CPU = 0.05;
00097 
00098 private:
00099 
00100     /**
00101      * List node used to track tasks that this policy is managing.
00102      */
00103     struct TaskPriority {
00104         struct lnNode tp_Link;
00105         struct TaskPriority *tp_SubLink;
00106         RealTimeSchedule tp_Schedule;
00107         CORBA::ULong tp_SubTime;
00108         Broker::RealTimeTask_var tp_Task;
00109     };
00110 
00111     /**
00112      * Find the TaskPriority node that corresponds to the given task.
00113      *
00114      * @param task The Broker::RealTimeTask object to look up.
00115      * @return The TaskPriority list node that has the given task object.
00116      * @exception Broker::Internal If no TaskPriority node exists for the given
00117      *            task.
00118      */
00119     struct TaskPriority *FindTaskPriority(Broker::RealTimeTask_ptr task);
00120 
00121     /**
00122      * Construct a list, ordered from lowest to highest priority, of the tasks
00123      * whose schedule intersects with the given one.
00124      *
00125      * @param rts The schedule to match.
00126      * @param ignore The TaskPriority node to ignore when building the list or
00127      *               NULL if no nodes should be ignored.
00128      * @return The list of nodes, linked by tp_SubLink, that match the given
00129      *         schedule.
00130      */
00131     struct TaskPriority *SubList(const RealTimeSchedule &rts,
00132                                  struct TaskPriority *ignore);
00133 
00134     /**
00135      * Take CPU time from other tasks to give to another.
00136      *
00137      * @param sub_list The list of tasks to take CPU time from, typically built
00138      *                 with the SubList() method.
00139      * @param amount The amount of CPU time to take away.
00140      * @param for_tp The node that will be given the CPU time.
00141      * @return The actual amount of CPU time that can be given to the task.
00142      */
00143     CORBA::ULong TakeCPU(struct TaskPriority *sub_list,
00144                          CORBA::ULong amount,
00145                          struct TaskPriority *for_tp);
00146 
00147     /**
00148      * Give CPU time back to the other tasks.
00149      *
00150      * @param sub_list The list of tasks to give CPU time to, typically  built
00151      *                 with the SubList() method.
00152      * @param amount The amount of CPU time to give out.
00153      * @param for_tp The donating task.
00154      * @return XXX ...
00155      */
00156     CORBA::ULong GiveCPU(struct TaskPriority *sub_list,
00157                          CORBA::ULong amount,
00158                          struct TaskPriority *for_tp);
00159 
00160     /** The name of this object as registered with the NamingService*/
00161     CORBA::String_var sp_Name;
00162     /** The maximum percentage of CPU time that we are allowed to allocate. */
00163     float sp_MaxUsedCPU;
00164     /** The minimum percentage of CPU time that a task must have. */
00165     float sp_MinTaskCPU;
00166     /** A list of TaskPriority objects */
00167     struct lnList sp_List;
00168     
00169 };
00170 
00171 #endif

Generated on Mon Dec 1 16:21:56 2003 for CPUBroker by doxygen 1.3.4