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

MaxDecayTaskAdvocate.cc

Go to the documentation of this file.
00001 /*
00002  * MaxDecayTaskAdvocate.cc
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 MaxDecayTaskAdvocate.cc
00014  *
00015  * Implementation of the MaxDecayTaskAdvocate class.
00016  */
00017 
00018 #include "config.h"
00019 
00020 #include "MaxDecayTaskAdvocate.hh"
00021 
00022 /**
00023  * The default number of periods to wait before dropping the reservation to the
00024  * currently observed minimum.
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 }

Generated on Mon Dec 1 16:29:06 2003 for CPU Broker by doxygen 1.3.4