00001 /* 00002 * MaxDecayTaskAdvocate.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 MaxDecayTaskAdvocate.hh 00014 * 00015 * Header file for the MaxDecayTaskAdvocate class. 00016 */ 00017 00018 #ifndef _max_decay_task_advocate_hh 00019 #define _max_decay_task_advocate_hh 00020 00021 #include <RealTimeTaskDelegateImpl.hh> 00022 00023 /** 00024 * An advocate that reacts quickly to increases in CPU usage, but slow to react 00025 * to decreases in usage, making it an ideal generic advocate. 00026 * 00027 * The actual implementation works by sending an advice that reflects the 00028 * highest usage seen in the last N periods, where N can be set using the 00029 * #SetDelegateAttribute method. 00030 */ 00031 class MaxDecayTaskAdvocate : public virtual RealTimeTaskDelegateImpl 00032 { 00033 00034 public: 00035 00036 /** Default constructor. */ 00037 MaxDecayTaskAdvocate(void); 00038 00039 /** Destructor. */ 00040 virtual ~MaxDecayTaskAdvocate(void); 00041 00042 /** 00043 * @copydoc BrokerDelegates::Delegate::SetDelegateAttribute 00044 * 00045 * Currently supported 'id' values are: 00046 * 00047 * @li @e decay-after The number of periods to wait before dropping the CPU 00048 * usage. 00049 */ 00050 virtual void SetDelegateAttribute(const char *id, 00051 const CORBA::Any &value) 00052 throw (CORBA::SystemException); 00053 00054 /** 00055 * @copydoc BrokerDelegates::Delegate::GetDelegateAttribute 00056 * 00057 * Currently supported 'id' values are: 00058 * 00059 * @li @e decay-after The number of periods to wait before dropping the CPU 00060 * usage. 00061 * @li @e last-advice The last advice given by the advocate. 00062 */ 00063 virtual CORBA::Any *GetDelegateAttribute(const char *id) 00064 throw (CORBA::SystemException); 00065 00066 /** @copydoc Broker::RealTimeTask::PassCPU */ 00067 virtual Broker::CPUReserve PassCPU(Broker::RealTimeTask_ptr rtt, 00068 const Broker::CPUReserve &status, 00069 const Broker::CPUReserve &advice, 00070 const Broker::KeyedReportParameters &krp) 00071 throw (CORBA::SystemException); 00072 00073 private: 00074 00075 /** 00076 * The last advice reported by this advocate. 00077 */ 00078 CORBA::ULong md_LastAdvice; 00079 00080 /** 00081 * The maximum observed usage that is still below the last advice given. 00082 */ 00083 CORBA::ULong md_SubMax; 00084 00085 /** 00086 * The number of periods left before the reservation will be dropped to the 00087 * value of md_SubMax. 00088 */ 00089 unsigned int md_Decay; 00090 00091 /** 00092 * The number of periods after which the advice should decay. 00093 */ 00094 CORBA::ULong md_DecayAfter; 00095 00096 }; 00097 00098 #endif