00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "config.h"
00019
00020 #include "MaxDecayTaskAdvocate.hh"
00021
00022
00023
00024
00025
00026 #define DECAY_AFTER 5
00027
00028 MaxDecayTaskAdvocate::MaxDecayTaskAdvocate(void)
00029 {
00030 this->md_LastAdvice = 0;
00031 this->md_Decay = DECAY_AFTER;
00032 }
00033
00034 MaxDecayTaskAdvocate::~MaxDecayTaskAdvocate(void)
00035 {
00036 }
00037
00038 void MaxDecayTaskAdvocate::ReportCPU(Broker::RealTimeTask_ptr rtt,
00039 CORBA::ULong status,
00040 CORBA::ULong advice)
00041 throw (CORBA::SystemException)
00042 {
00043 if( CORBA::is_nil(this->dm_RemoteObject) )
00044 {
00045 throw CORBA::BAD_INV_ORDER();
00046 }
00047
00048 if( advice >= this->md_LastAdvice )
00049 {
00050 this->md_Decay = DECAY_AFTER;
00051 this->md_SubMax = 0;
00052 advice += (CORBA::ULong)(0.01 * advice);
00053 }
00054 else if( this->md_Decay > 0 )
00055 {
00056 this->md_SubMax = max(this->md_SubMax, advice);
00057 this->md_Decay -= 1;
00058 advice = this->md_LastAdvice;
00059 }
00060 else if( this->md_Decay == 0 )
00061 {
00062 advice = (CORBA::ULong)(this->md_SubMax + (0.05 * this->md_SubMax));
00063 this->md_SubMax = 0;
00064 this->md_Decay = DECAY_AFTER;
00065 }
00066 this->md_LastAdvice = advice;
00067 this->RealTimeTaskDelegateImpl::ReportCPU(rtt, status, advice);
00068 }