#include <Sched_Params.h>
Collaboration diagram for ACE_Sched_Params:
Public Types | |
typedef int | Policy |
Public Member Functions | |
ACE_Sched_Params (const Policy policy, const ACE_Sched_Priority priority, const int scope=ACE_SCOPE_THREAD, const ACE_Time_Value &quantum=ACE_Time_Value::zero) | |
Constructor. | |
~ACE_Sched_Params (void) | |
Termination. | |
Policy | policy (void) const |
void | policy (const Policy) |
ACE_Sched_Priority | priority (void) const |
void | priority (const ACE_Sched_Priority) |
int | scope (void) const |
void | scope (const int) |
const ACE_Time_Value & | quantum (void) const |
void | quantum (const ACE_Time_Value &) |
Static Public Member Functions | |
int | priority_min (const Policy, const int scope=ACE_SCOPE_THREAD) |
int | priority_max (const Policy, const int scope=ACE_SCOPE_THREAD) |
int | next_priority (const Policy, const int priority, const int scope=ACE_SCOPE_THREAD) |
int | previous_priority (const Policy, const int priority, const int scope=ACE_SCOPE_THREAD) |
Private Attributes | |
Policy | policy_ |
Scheduling policy. | |
ACE_Sched_Priority | priority_ |
int | scope_ |
ACE_Time_Value | quantum_ |
ACE_Sched_Params are passed via <ACE_OS::sched_params> to the OS to specify scheduling parameters. These parameters include scheduling policy, such as FIFO (ACE_SCHED_FIFO), round-robin (ACE_SCHED_RR), or an implementation-defined "OTHER" (ACE_SCHED_OTHER), to which many systems default; priority; and a time-slice quantum for round-robin scheduling. A "scope" parameter specifies whether the ACE_Sched_Params applies to the current process, current lightweight process (LWP) (on Solaris), or current thread. Please see the "NOTE" below about not all combinations of parameters being legal on a particular platform. For the case of thread priorities, it is intended that <ACE_OS::sched_params> usually be called from before any threads have been spawned. If spawned threads inherit their parent's priority (I think that's the default behavior for all of our platforms), then this sets the default base priority. Individual thread priorities can be adjusted as usual using <ACE_OS::thr_prio> or via the ACE_Thread interface. See the parameter descriptions in the private: section below.
Definition at line 60 of file Sched_Params.h.
|
Definition at line 74 of file Sched_Params.h. Referenced by ACE_Sched_Params(), ACE_Sched_Priority_Iterator::ACE_Sched_Priority_Iterator(), next_priority(), policy(), previous_priority(), priority_max(), and priority_min(). |
|
Constructor.
Definition at line 24 of file Sched_Params.inl. References ACE_Sched_Priority, and Policy.
|
|
Termination.
Definition at line 36 of file Sched_Params.inl. References ACE_INLINE.
00037 { 00038 } |
|
The next higher priority. "Higher" refers to scheduling priority, not to the priority value itself. (On some platforms, higher scheduling priority is indicated by a lower priority value.) If "priority" is already the highest priority (for the specified policy), then it is returned. Definition at line 240 of file Sched_Params.cpp. References ACE_NOTSUP_RETURN, Policy, and priority_max(). Referenced by ACE_Sched_Priority_Iterator::next().
00243 { 00244 #if defined (ACE_VXWORKS) 00245 return priority > priority_max (policy, scope) 00246 ? priority - 1 00247 : priority_max (policy, scope); 00248 #elif defined (ACE_HAS_WTHREADS) 00249 ACE_UNUSED_ARG (policy); 00250 ACE_UNUSED_ARG (scope); 00251 switch (priority) 00252 { 00253 case THREAD_PRIORITY_IDLE: 00254 return THREAD_PRIORITY_LOWEST; 00255 case THREAD_PRIORITY_LOWEST: 00256 return THREAD_PRIORITY_BELOW_NORMAL; 00257 case THREAD_PRIORITY_BELOW_NORMAL: 00258 return THREAD_PRIORITY_NORMAL; 00259 case THREAD_PRIORITY_NORMAL: 00260 return THREAD_PRIORITY_ABOVE_NORMAL; 00261 case THREAD_PRIORITY_ABOVE_NORMAL: 00262 return THREAD_PRIORITY_HIGHEST; 00263 case THREAD_PRIORITY_HIGHEST: 00264 return THREAD_PRIORITY_TIME_CRITICAL; 00265 case THREAD_PRIORITY_TIME_CRITICAL: 00266 return THREAD_PRIORITY_TIME_CRITICAL; 00267 default: 00268 return priority; // unknown priority: should never get here 00269 } 00270 #elif defined(ACE_HAS_THREADS) && \ 00271 (!defined(ACE_LACKS_SETSCHED) || defined (ACE_TANDEM_T1248_PTHREADS) || \ 00272 defined (ACE_HAS_PTHREAD_SCHEDPARAM)) 00273 // including STHREADS, and PTHREADS 00274 const int max = priority_max (policy, scope); 00275 return priority < max ? priority + 1 : max; 00276 #else 00277 ACE_UNUSED_ARG (policy); 00278 ACE_UNUSED_ARG (scope); 00279 ACE_UNUSED_ARG (priority); 00280 ACE_NOTSUP_RETURN (-1); 00281 #endif /* ACE_HAS_THREADS */ 00282 } |
|
Definition at line 47 of file Sched_Params.inl. References Policy, and policy_.
|
|
Definition at line 41 of file Sched_Params.inl. References policy_.
00042 { 00043 return this->policy_; 00044 } |
|
The previous, lower priority. "Lower" refers to scheduling priority, not to the priority value itself. (On some platforms, lower scheduling priority is indicated by a higher priority value.) If "priority" is already the lowest priority (for the specified policy), then it is returned. Definition at line 285 of file Sched_Params.cpp. References ACE_NOTSUP_RETURN, Policy, and priority_min().
00288 { 00289 #if defined (ACE_VXWORKS) 00290 return priority < priority_min (policy, scope) 00291 ? priority + 1 00292 : priority_min (policy, scope); 00293 #elif defined (ACE_HAS_WTHREADS) 00294 ACE_UNUSED_ARG (policy); 00295 ACE_UNUSED_ARG (scope); 00296 switch (priority) 00297 { 00298 case THREAD_PRIORITY_IDLE: 00299 return THREAD_PRIORITY_IDLE; 00300 case THREAD_PRIORITY_LOWEST: 00301 return THREAD_PRIORITY_IDLE; 00302 case THREAD_PRIORITY_BELOW_NORMAL: 00303 return THREAD_PRIORITY_LOWEST; 00304 case THREAD_PRIORITY_NORMAL: 00305 return THREAD_PRIORITY_BELOW_NORMAL; 00306 case THREAD_PRIORITY_ABOVE_NORMAL: 00307 return THREAD_PRIORITY_NORMAL; 00308 case THREAD_PRIORITY_HIGHEST: 00309 return THREAD_PRIORITY_ABOVE_NORMAL; 00310 case THREAD_PRIORITY_TIME_CRITICAL: 00311 return THREAD_PRIORITY_HIGHEST; 00312 default: 00313 return priority; // unknown priority: should never get here 00314 } 00315 #elif defined(ACE_HAS_THREADS) && \ 00316 (!defined(ACE_LACKS_SETSCHED) || defined (ACE_TANDEM_T1248_PTHREADS) || \ 00317 defined (ACE_HAS_PTHREAD_SCHEDPARAM)) 00318 // including STHREADS and PTHREADS 00319 const int min = priority_min (policy, scope); 00320 00321 return priority > min ? priority - 1 : min; 00322 #else 00323 ACE_UNUSED_ARG (policy); 00324 ACE_UNUSED_ARG (scope); 00325 ACE_UNUSED_ARG (priority); 00326 ACE_NOTSUP_RETURN (-1); 00327 #endif /* ACE_HAS_THREADS */ 00328 } |
|
Definition at line 59 of file Sched_Params.inl. References ACE_Sched_Priority.
00060 { 00061 this->priority_ = priority; 00062 } |
|
Definition at line 53 of file Sched_Params.inl.
00054 { 00055 return this->priority_; 00056 } |
|
Definition at line 140 of file Sched_Params.cpp. References ACE_NOTSUP_RETURN, ACE_SCHED_FIFO, ACE_SCHED_OTHER, ACE_SCHED_RR, ACE_SCOPE_LWP, ACE_SCOPE_PROCESS, ACE_SCOPE_THREAD, ACE_OS::memset(), Policy, ACE_OS::priority_control(), and ACE_OS::strcpy(). Referenced by next_priority().
00142 { 00143 #if defined (ACE_HAS_PRIOCNTL) && defined (ACE_HAS_STHREADS) 00144 ACE_UNUSED_ARG (scope); 00145 00146 // Call ACE_OS::priority_control only for processes (lightweight 00147 // or otherwise). Calling ACE_OS::priority_control for thread 00148 // priorities gives incorrect results. 00149 if (scope == ACE_SCOPE_PROCESS || scope == ACE_SCOPE_LWP) 00150 { 00151 // Assume that ACE_SCHED_OTHER indicates TS class, and that other 00152 // policies indicate RT class. 00153 00154 // Get the priority class ID and attributes. 00155 pcinfo_t pcinfo; 00156 // The following is just to avoid Purify warnings about unitialized 00157 // memory reads. 00158 ACE_OS::memset (&pcinfo, 0, sizeof pcinfo); 00159 ACE_OS::strcpy (pcinfo.pc_clname, 00160 policy == ACE_SCHED_OTHER ? "TS" : "RT"); 00161 00162 if (ACE_OS::priority_control (P_ALL /* ignored */, 00163 P_MYID /* ignored */, 00164 PC_GETCID, 00165 (char *) &pcinfo) == -1) 00166 return -1; 00167 00168 // OK, now we've got the class ID in pcinfo.pc_cid. In addition, 00169 // the maximum configured real-time priority is in ((rtinfo_t *) 00170 // pcinfo.pc_clinfo)->rt_maxpri, or similarly for the TS class. 00171 00172 return policy == ACE_SCHED_OTHER 00173 ? ((tsinfo_t *) pcinfo.pc_clinfo)->ts_maxupri 00174 : ((rtinfo_t *) pcinfo.pc_clinfo)->rt_maxpri; 00175 } 00176 else 00177 { 00178 // Here we handle the case for ACE_SCOPE_THREAD. Calling 00179 // ACE_OS::priority_control for thread scope gives incorrect 00180 // results. 00181 switch (policy) 00182 { 00183 case ACE_SCHED_FIFO: 00184 return ACE_THR_PRI_FIFO_MAX; 00185 case ACE_SCHED_RR: 00186 return ACE_THR_PRI_RR_MAX; 00187 case ACE_SCHED_OTHER: 00188 default: 00189 return ACE_THR_PRI_OTHER_MAX; 00190 } 00191 } 00192 #elif defined(ACE_HAS_PTHREADS) && \ 00193 (!defined(ACE_LACKS_SETSCHED) || defined (ACE_TANDEM_T1248_PTHREADS) || \ 00194 defined (ACE_HAS_PTHREAD_SCHEDPARAM)) 00195 00196 switch (scope) 00197 { 00198 case ACE_SCOPE_THREAD: 00199 switch (policy) 00200 { 00201 case ACE_SCHED_FIFO: 00202 return ACE_THR_PRI_FIFO_MAX; 00203 case ACE_SCHED_RR: 00204 return ACE_THR_PRI_RR_MAX; 00205 case ACE_SCHED_OTHER: 00206 default: 00207 return ACE_THR_PRI_OTHER_MAX; 00208 } 00209 00210 case ACE_SCOPE_PROCESS: 00211 default: 00212 switch (policy) 00213 { 00214 case ACE_SCHED_FIFO: 00215 return ACE_PROC_PRI_FIFO_MAX; 00216 case ACE_SCHED_RR: 00217 return ACE_PROC_PRI_RR_MAX; 00218 case ACE_SCHED_OTHER: 00219 default: 00220 return ACE_PROC_PRI_OTHER_MAX; 00221 } 00222 } 00223 00224 #elif defined (ACE_HAS_WTHREADS) 00225 ACE_UNUSED_ARG (policy); 00226 ACE_UNUSED_ARG (scope); 00227 return THREAD_PRIORITY_TIME_CRITICAL; 00228 #elif defined (ACE_VXWORKS) 00229 ACE_UNUSED_ARG (policy); 00230 ACE_UNUSED_ARG (scope); 00231 return 0; 00232 #else 00233 ACE_UNUSED_ARG (policy); 00234 ACE_UNUSED_ARG (scope); 00235 ACE_NOTSUP_RETURN (-1); 00236 #endif /* ACE_HAS_PRIOCNTL && defined (ACE_HAS_STHREADS) */ 00237 } |
|
Definition at line 35 of file Sched_Params.cpp. References ACE_NOTSUP_RETURN, ACE_SCHED_FIFO, ACE_SCHED_OTHER, ACE_SCHED_RR, ACE_SCOPE_LWP, ACE_SCOPE_PROCESS, ACE_SCOPE_THREAD, ACE_OS::memset(), Policy, ACE_OS::priority_control(), and ACE_OS::strcpy(). Referenced by ACE_Sched_Priority_Iterator::ACE_Sched_Priority_Iterator(), and previous_priority().
00037 { 00038 #if defined (ACE_HAS_PRIOCNTL) && defined (ACE_HAS_STHREADS) 00039 ACE_UNUSED_ARG (scope); 00040 00041 // Assume that ACE_SCHED_OTHER indicates TS class, and that other 00042 // policies indicate RT class. 00043 00044 // Call ACE_OS::priority_control only for processes (lightweight 00045 // or otherwise). Calling ACE_OS::priority_control for thread 00046 // priorities gives incorrect results. 00047 if (scope == ACE_SCOPE_PROCESS || scope == ACE_SCOPE_LWP) 00048 { 00049 if (policy == ACE_SCHED_OTHER) 00050 { 00051 // Get the priority class ID and attributes. 00052 pcinfo_t pcinfo; 00053 // The following is just to avoid Purify warnings about unitialized 00054 // memory reads. 00055 ACE_OS::memset (&pcinfo, 0, sizeof pcinfo); 00056 ACE_OS::strcpy (pcinfo.pc_clname, "TS"); 00057 00058 if (ACE_OS::priority_control (P_ALL /* ignored */, 00059 P_MYID /* ignored */, 00060 PC_GETCID, 00061 (char *) &pcinfo) == -1) 00062 // Just hope that priority range wasn't configured from -1 00063 // .. 1 00064 return -1; 00065 00066 // OK, now we've got the class ID in pcinfo.pc_cid. In 00067 // addition, the maximum configured time-share priority is in 00068 // ((tsinfo_t *) pcinfo.pc_clinfo)->ts_maxupri. The minimum 00069 // priority is just the negative of that. 00070 00071 return -((tsinfo_t *) pcinfo.pc_clinfo)->ts_maxupri; 00072 } 00073 else 00074 return 0; 00075 } 00076 else 00077 { 00078 // Here we handle the case for ACE_SCOPE_THREAD. Calling 00079 // ACE_OS::priority_control for thread scope gives incorrect 00080 // results. 00081 switch (policy) 00082 { 00083 case ACE_SCHED_FIFO: 00084 return ACE_THR_PRI_FIFO_MIN; 00085 case ACE_SCHED_RR: 00086 return ACE_THR_PRI_RR_MIN; 00087 case ACE_SCHED_OTHER: 00088 default: 00089 return ACE_THR_PRI_OTHER_MIN; 00090 } 00091 } 00092 #elif defined(ACE_HAS_PTHREADS) && \ 00093 (!defined(ACE_LACKS_SETSCHED) || defined (ACE_TANDEM_T1248_PTHREADS) || \ 00094 defined (ACE_HAS_PTHREAD_SCHEDPARAM)) 00095 00096 switch (scope) 00097 { 00098 case ACE_SCOPE_THREAD: 00099 switch (policy) 00100 { 00101 case ACE_SCHED_FIFO: 00102 return ACE_THR_PRI_FIFO_MIN; 00103 case ACE_SCHED_RR: 00104 return ACE_THR_PRI_RR_MIN; 00105 case ACE_SCHED_OTHER: 00106 default: 00107 return ACE_THR_PRI_OTHER_MIN; 00108 } 00109 00110 case ACE_SCOPE_PROCESS: 00111 default: 00112 switch (policy) 00113 { 00114 case ACE_SCHED_FIFO: 00115 return ACE_PROC_PRI_FIFO_MIN; 00116 case ACE_SCHED_RR: 00117 return ACE_PROC_PRI_RR_MIN; 00118 case ACE_SCHED_OTHER: 00119 default: 00120 return ACE_PROC_PRI_OTHER_MIN; 00121 } 00122 } 00123 00124 #elif defined (ACE_HAS_WTHREADS) 00125 ACE_UNUSED_ARG (policy); 00126 ACE_UNUSED_ARG (scope); 00127 return THREAD_PRIORITY_IDLE; 00128 #elif defined (ACE_VXWORKS) 00129 ACE_UNUSED_ARG (policy); 00130 ACE_UNUSED_ARG (scope); 00131 return 255; 00132 #else 00133 ACE_UNUSED_ARG (policy); 00134 ACE_UNUSED_ARG (scope); 00135 ACE_NOTSUP_RETURN (-1); 00136 #endif /* ACE_HAS_PRIOCNTL && defined (ACE_HAS_STHREADS) */ 00137 } |
|
Definition at line 83 of file Sched_Params.inl. References quantum_.
00084 { 00085 this->quantum_ = quant; 00086 } |
|
Definition at line 77 of file Sched_Params.inl. References quantum_.
00078 { 00079 return this->quantum_; 00080 } |
|
Definition at line 71 of file Sched_Params.inl. References scope_.
00072 { 00073 this->scope_ = scope; 00074 } |
|
Definition at line 65 of file Sched_Params.inl. References scope_. Referenced by ACE_OS::lwp_setparams().
00066 { 00067 return this->scope_; 00068 } |
|
Scheduling policy.
Definition at line 136 of file Sched_Params.h. Referenced by policy(). |
|
Default : for setting the priority for the process, LWP, or thread, as indicated by the scope_ parameter. Definition at line 140 of file Sched_Params.h. |
|
The is for time slicing. An ACE_Time_Value of 0 has special significance: it means time-slicing is disabled; with that, a thread that is running on a CPU will continue to run until it blocks or is preempted. Currently ignored if the OS doesn't directly support time slicing, such as on VxWorks, or setting the quantum (can that be done on Win32?). Definition at line 168 of file Sched_Params.h. Referenced by quantum(). |
|
must be one of the following: ACE_SCOPE_PROCESS: sets the scheduling policy for the process, and the process priority. On some platforms, such as Win32, the scheduling policy can _only_ be set at process scope. ACE_SCOPE_LWP: lightweight process scope, only used with Solaris threads. ACE_SCOPE_THREAD: sets the scheduling policy for the thread, if the OS supports it, such as with Posix threads, and the thread priority. NOTE: I don't think that these are the same as POSIX contention scope. POSIX users who are interested in, and understand, contention scope will have to set it by using system calls outside of ACE. Definition at line 158 of file Sched_Params.h. Referenced by scope(). |