#include <Multi_Priority_Mapping.h>
Inheritance diagram for TAO_Multi_Priority_Mapping:
Public Member Functions | |
TAO_Multi_Priority_Mapping (int base_native_priority, int base_corba_priority, int priority_spacing=1, int priorities_contiguous=1, int policy=ACE_SCHED_FIFO) | |
Default constructor. | |
virtual | ~TAO_Multi_Priority_Mapping (void) |
The destructor. | |
virtual CORBA::Boolean | to_native (RTCORBA::Priority corba_priority, RTCORBA::NativePriority &native_priority) |
virtual CORBA::Boolean | to_CORBA (RTCORBA::NativePriority native_priority, RTCORBA::Priority &corba_priority) |
Private Attributes | |
int | base_native_priority_ |
The base settings. | |
int | base_corba_priority_ |
const int | priority_spacing_ |
const int | priorities_contiguous_ |
int | policy_ |
The scheduling policy. | |
int const | min_ |
The range. | |
int const | max_ |
This implementation uses a custom mapping between the range of priorities for a given scheduling class (ACE_SCHED_OTHER, ACE_SCHED_FIFO, ACE_SCHED_RR) and the valid range of CORBA priorities (0...32767)
Definition at line 44 of file Multi_Priority_Mapping.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Multi_Priority_Mapping::TAO_Multi_Priority_Mapping | ( | int | base_native_priority, | |
int | base_corba_priority, | |||
int | priority_spacing = 1 , |
|||
int | priorities_contiguous = 1 , |
|||
int | policy = ACE_SCHED_FIFO | |||
) |
Default constructor.
base_native_priority | The native priority to use for the highest priority endpoint. | |
base_corba_priority | The corba priority to use for the highest priority endpoint | |
priority_spacing | The priority increment to use between endpoints | |
priorities_contiguous | Some platforms do use contiguous priorities | |
policy | The scheduling policy to use. |
Definition at line 18 of file Multi_Priority_Mapping.cpp.
References ACE_DEBUG, LM_DEBUG, and TAO_debug_level.
00024 : base_native_priority_ (base_native_priority) 00025 , base_corba_priority_ (base_corba_priority) 00026 , priority_spacing_ (priority_spacing) 00027 , priorities_contiguous_(priorities_contiguous) 00028 , policy_ (policy) 00029 , min_ (ACE_Sched_Params::priority_min (this->policy_)) 00030 , max_ (ACE_Sched_Params::priority_max (this->policy_)) 00031 { 00032 if ( this->min_ < this->max_ ) 00033 { 00034 if (base_native_priority_ < this->min_) 00035 { 00036 if (TAO_debug_level > 2) 00037 { 00038 ACE_DEBUG ((LM_DEBUG, 00039 "TAO (%P|%t) - Multi_Priority_Mapping::ctor: " 00040 " base_native_priority %d out of range [%d,%d]\n", 00041 base_native_priority_, this->min_, this->max_)); 00042 } 00043 } 00044 } 00045 else 00046 { 00047 if (base_native_priority_ > this->min_) 00048 { 00049 if (TAO_debug_level > 2) 00050 { 00051 ACE_DEBUG ((LM_DEBUG, 00052 "TAO (%P|%t) - Multi_Priority_Mapping::ctor: " 00053 " base_native_priority %d out of range [%d,%d]\n", 00054 base_native_priority_, this->min_, this->max_)); 00055 } 00056 } 00057 } 00058 00059 if (base_corba_priority_ > RTCORBA::maxPriority) 00060 { 00061 if (TAO_debug_level > 2) 00062 { 00063 ACE_DEBUG ((LM_DEBUG, 00064 "TAO (%P|%t) - Multi_Priority_Mapping::ctor: " 00065 " base_corba_priority %d out of range [%d,%d]\n", 00066 base_corba_priority_, RTCORBA::minPriority, RTCORBA::maxPriority)); 00067 } 00068 } 00069 }
TAO_Multi_Priority_Mapping::~TAO_Multi_Priority_Mapping | ( | void | ) | [virtual] |
CORBA::Boolean TAO_Multi_Priority_Mapping::to_CORBA | ( | RTCORBA::NativePriority | native_priority, | |
RTCORBA::Priority & | corba_priority | |||
) | [virtual] |
Implements TAO_Priority_Mapping.
Definition at line 146 of file Multi_Priority_Mapping.cpp.
References ACE_DEBUG, ACE_SCOPE_THREAD, base_corba_priority_, base_native_priority_, LM_DEBUG, min_, ACE_Sched_Params::previous_priority(), priorities_contiguous_, priority_spacing_, and TAO_debug_level.
00148 { 00149 // Check for an invalid native priority 00150 if ((this->min_ < this->max_ && (native_priority < this->min_ || native_priority > this->base_native_priority_ )) || 00151 (this->min_ > this->max_ && (native_priority < this->base_corba_priority_ || native_priority > this->min_))) 00152 { 00153 if (TAO_debug_level > 2) 00154 { 00155 ACE_DEBUG ((LM_DEBUG, 00156 "TAO (%P|%t) - Multi_Priority_Mapping::to_CORBA: " 00157 " priority %d out of range [%d,%d]\n", 00158 native_priority, this->min_, this->base_corba_priority_)); 00159 } 00160 return 0; 00161 } 00162 00163 if (native_priority == base_native_priority_) 00164 { 00165 // If this is the highest priority endpoint, then just give it the highest priority corba base priority 00166 corba_priority = static_cast<RTCORBA::Priority> (base_corba_priority_); 00167 } 00168 else 00169 { 00170 if (priorities_contiguous_ == 1) 00171 { 00172 if ( this->min_ < this->max_ ) 00173 { 00174 corba_priority = static_cast<RTCORBA::Priority> 00175 (((native_priority - base_native_priority_) * priority_spacing_) + base_corba_priority_); 00176 } 00177 else 00178 { 00179 corba_priority = static_cast<RTCORBA::Priority> 00180 (((base_native_priority_ - native_priority) * priority_spacing_) + base_corba_priority_); 00181 } 00182 } 00183 else 00184 { 00185 // Start at the max priority and search until we reach the base priority 00186 int last_priority = this->base_native_priority_; 00187 while (true) 00188 { 00189 int previous_priority = ACE_Sched_Params::previous_priority (this->policy_, 00190 last_priority, 00191 ACE_SCOPE_THREAD); 00192 last_priority = previous_priority; 00193 00194 if (last_priority == this->min_) 00195 { 00196 break; 00197 } 00198 00199 if ( this->min_ < this->max_ ) 00200 { 00201 if (base_native_priority_ >= previous_priority) break; 00202 } 00203 else 00204 { 00205 if (base_native_priority_ <= previous_priority) break; 00206 } 00207 } 00208 00209 int priority_ndx = 1; 00210 while (true) 00211 { 00212 if (last_priority == this->min_) 00213 { 00214 break; 00215 } 00216 00217 if ( this->min_ < this->max_ ) 00218 { 00219 if (native_priority >= last_priority) break; 00220 } 00221 else 00222 { 00223 if (native_priority <= last_priority) break; 00224 } 00225 00226 int previous_priority = ACE_Sched_Params::previous_priority (this->policy_, 00227 last_priority, 00228 ACE_SCOPE_THREAD); 00229 last_priority = previous_priority; 00230 priority_ndx++; 00231 } 00232 00233 corba_priority = static_cast<RTCORBA::Priority> 00234 (base_corba_priority_ - priority_ndx); 00235 } 00236 } 00237 00238 return 1; 00239 }
CORBA::Boolean TAO_Multi_Priority_Mapping::to_native | ( | RTCORBA::Priority | corba_priority, | |
RTCORBA::NativePriority & | native_priority | |||
) | [virtual] |
Implements TAO_Priority_Mapping.
Definition at line 76 of file Multi_Priority_Mapping.cpp.
References ACE_DEBUG, ACE_SCOPE_THREAD, base_corba_priority_, base_native_priority_, LM_DEBUG, ACE_Sched_Params::previous_priority(), priorities_contiguous_, priority_spacing_, and TAO_debug_level.
00078 { 00079 // Check for an invalid native priority 00080 if (corba_priority < RTCORBA::minPriority || corba_priority > this->base_corba_priority_ ) 00081 { 00082 if (TAO_debug_level > 2) 00083 { 00084 ACE_DEBUG ((LM_DEBUG, 00085 "TAO (%P|%t) - Multi_Priority_Mapping::to_native: " 00086 " corba priority %d out of range [%d,%d]\n", 00087 corba_priority, RTCORBA::minPriority, this->base_corba_priority_)); 00088 } 00089 return 0; 00090 } 00091 00092 if (corba_priority == base_corba_priority_) 00093 { 00094 // If this is the highest priority endpoint, then just give it the highest priority corba base priority 00095 native_priority = static_cast<RTCORBA::NativePriority> (base_native_priority_); 00096 } 00097 else 00098 { 00099 if (priorities_contiguous_ == 1) 00100 { 00101 if ( this->min_ < this->max_ ) 00102 { 00103 native_priority = static_cast<RTCORBA::NativePriority> 00104 (((corba_priority - base_corba_priority_) / priority_spacing_) + base_native_priority_); 00105 } 00106 else 00107 { 00108 native_priority = static_cast<RTCORBA::NativePriority> 00109 (((base_corba_priority_ - corba_priority) / priority_spacing_) + base_native_priority_); 00110 } 00111 } 00112 else 00113 { 00114 // Start at the max priority and search until we reach the base priority 00115 int last_priority = this->base_corba_priority_; 00116 while (true) 00117 { 00118 if (last_priority == RTCORBA::minPriority) break; 00119 if (base_corba_priority_ >= --last_priority) break; 00120 } 00121 00122 int priority_ndx = 0; 00123 while (true) 00124 { 00125 if (last_priority == RTCORBA::minPriority) break; 00126 if (corba_priority >= --last_priority) break; 00127 priority_ndx++; 00128 } 00129 00130 // Start at the max priority and search until we reach the base priority 00131 last_priority = this->base_native_priority_; 00132 for (int current_ndx = 0; current_ndx < priority_ndx; current_ndx++) 00133 { 00134 native_priority = static_cast<RTCORBA::NativePriority> 00135 (ACE_Sched_Params::previous_priority (this->policy_, 00136 last_priority, 00137 ACE_SCOPE_THREAD)); 00138 } 00139 } 00140 } 00141 00142 return 1; 00143 }
int TAO_Multi_Priority_Mapping::base_corba_priority_ [private] |
int TAO_Multi_Priority_Mapping::base_native_priority_ [private] |
The base settings.
Definition at line 77 of file Multi_Priority_Mapping.h.
Referenced by to_CORBA(), and to_native().
int const TAO_Multi_Priority_Mapping::max_ [private] |
Definition at line 88 of file Multi_Priority_Mapping.h.
int const TAO_Multi_Priority_Mapping::min_ [private] |
int TAO_Multi_Priority_Mapping::policy_ [private] |
const int TAO_Multi_Priority_Mapping::priorities_contiguous_ [private] |
const int TAO_Multi_Priority_Mapping::priority_spacing_ [private] |