Use override/default for RTPortableServer
[ACE_TAO.git] / ACE / ace / Sched_Params.cpp
blob409e7120ac5467d8bf2613f09f21c4f052dafbf8
2 //=============================================================================
3 /**
4 * @file Sched_Params.cpp
6 * @author David Levine
7 */
8 //=============================================================================
10 #include "ace/Sched_Params.h"
12 #if !defined (__ACE_INLINE__)
13 #include "ace/Sched_Params.inl"
14 #endif /* __ACE_INLINE__ */
16 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
18 int
19 ACE_Sched_Params::priority_min (const Policy policy,
20 const int scope)
22 #if defined(ACE_HAS_PTHREADS) && !defined(ACE_LACKS_SETSCHED)
23 switch (scope)
25 case ACE_SCOPE_THREAD:
26 switch (policy)
28 case ACE_SCHED_FIFO:
29 return ACE_THR_PRI_FIFO_MIN;
30 case ACE_SCHED_RR:
31 return ACE_THR_PRI_RR_MIN;
32 case ACE_SCHED_OTHER:
33 default:
34 return ACE_THR_PRI_OTHER_MIN;
37 case ACE_SCOPE_PROCESS:
38 default:
39 switch (policy)
41 case ACE_SCHED_FIFO:
42 return ACE_PROC_PRI_FIFO_MIN;
43 case ACE_SCHED_RR:
44 return ACE_PROC_PRI_RR_MIN;
45 case ACE_SCHED_OTHER:
46 default:
47 return ACE_PROC_PRI_OTHER_MIN;
51 #elif defined (ACE_HAS_WTHREADS)
52 ACE_UNUSED_ARG (policy);
53 ACE_UNUSED_ARG (scope);
54 return THREAD_PRIORITY_IDLE;
55 #elif defined (ACE_VXWORKS)
56 ACE_UNUSED_ARG (policy);
57 ACE_UNUSED_ARG (scope);
58 # if defined (VX_TASK_PRIORITY_MAX)
59 return VX_TASK_PRIORITY_MAX;
60 # else
61 return 255;
62 # endif
63 #else
64 ACE_UNUSED_ARG (policy);
65 ACE_UNUSED_ARG (scope);
66 ACE_NOTSUP_RETURN (-1);
67 #endif /* ACE_HAS_PTHREADS */
70 int
71 ACE_Sched_Params::priority_max (const Policy policy,
72 const int scope)
74 #if defined(ACE_HAS_PTHREADS) && \
75 (!defined(ACE_LACKS_SETSCHED) || \
76 defined (ACE_HAS_PTHREAD_SCHEDPARAM))
78 switch (scope)
80 case ACE_SCOPE_THREAD:
81 switch (policy)
83 case ACE_SCHED_FIFO:
84 return ACE_THR_PRI_FIFO_MAX;
85 case ACE_SCHED_RR:
86 return ACE_THR_PRI_RR_MAX;
87 case ACE_SCHED_OTHER:
88 default:
89 return ACE_THR_PRI_OTHER_MAX;
92 case ACE_SCOPE_PROCESS:
93 default:
94 switch (policy)
96 case ACE_SCHED_FIFO:
97 return ACE_PROC_PRI_FIFO_MAX;
98 case ACE_SCHED_RR:
99 return ACE_PROC_PRI_RR_MAX;
100 case ACE_SCHED_OTHER:
101 default:
102 return ACE_PROC_PRI_OTHER_MAX;
106 #elif defined (ACE_HAS_WTHREADS)
107 ACE_UNUSED_ARG (policy);
108 ACE_UNUSED_ARG (scope);
109 return THREAD_PRIORITY_TIME_CRITICAL;
110 #elif defined (ACE_VXWORKS)
111 ACE_UNUSED_ARG (policy);
112 ACE_UNUSED_ARG (scope);
113 # if defined (VX_TASK_PRIORITY_MIN)
114 return VX_TASK_PRIORITY_MIN;
115 # else
116 return 0;
117 # endif
118 #else
119 ACE_UNUSED_ARG (policy);
120 ACE_UNUSED_ARG (scope);
121 ACE_NOTSUP_RETURN (-1);
122 #endif /* ACE_HAS_PTHREADS */
126 ACE_Sched_Params::next_priority (const Policy policy,
127 const int priority,
128 const int scope)
130 #if defined (ACE_HAS_WTHREADS)
131 ACE_UNUSED_ARG (policy);
132 ACE_UNUSED_ARG (scope);
133 switch (priority)
135 case THREAD_PRIORITY_IDLE:
136 return THREAD_PRIORITY_LOWEST;
137 case THREAD_PRIORITY_LOWEST:
138 return THREAD_PRIORITY_BELOW_NORMAL;
139 case THREAD_PRIORITY_BELOW_NORMAL:
140 return THREAD_PRIORITY_NORMAL;
141 case THREAD_PRIORITY_NORMAL:
142 return THREAD_PRIORITY_ABOVE_NORMAL;
143 case THREAD_PRIORITY_ABOVE_NORMAL:
144 return THREAD_PRIORITY_HIGHEST;
145 case THREAD_PRIORITY_HIGHEST:
146 return THREAD_PRIORITY_TIME_CRITICAL;
147 case THREAD_PRIORITY_TIME_CRITICAL:
148 return THREAD_PRIORITY_TIME_CRITICAL;
149 default:
150 return priority; // unknown priority: should never get here
152 #elif defined(ACE_HAS_THREADS) && \
153 (!defined(ACE_LACKS_SETSCHED) || \
154 defined (ACE_HAS_PTHREAD_SCHEDPARAM))
155 // including STHREADS, and PTHREADS
156 int const max = priority_max (policy, scope);
157 return priority < max ? priority + 1 : max;
158 #elif defined (ACE_VXWORKS)
159 int const max = priority_max (policy, scope);
160 return priority > max ? priority - 1 : max;
161 #else
162 ACE_UNUSED_ARG (policy);
163 ACE_UNUSED_ARG (scope);
164 ACE_UNUSED_ARG (priority);
165 ACE_NOTSUP_RETURN (-1);
166 #endif /* ACE_HAS_THREADS */
170 ACE_Sched_Params::previous_priority (const Policy policy,
171 const int priority,
172 const int scope)
174 #if defined (ACE_HAS_WTHREADS)
175 ACE_UNUSED_ARG (policy);
176 ACE_UNUSED_ARG (scope);
177 switch (priority)
179 case THREAD_PRIORITY_IDLE:
180 return THREAD_PRIORITY_IDLE;
181 case THREAD_PRIORITY_LOWEST:
182 return THREAD_PRIORITY_IDLE;
183 case THREAD_PRIORITY_BELOW_NORMAL:
184 return THREAD_PRIORITY_LOWEST;
185 case THREAD_PRIORITY_NORMAL:
186 return THREAD_PRIORITY_BELOW_NORMAL;
187 case THREAD_PRIORITY_ABOVE_NORMAL:
188 return THREAD_PRIORITY_NORMAL;
189 case THREAD_PRIORITY_HIGHEST:
190 return THREAD_PRIORITY_ABOVE_NORMAL;
191 case THREAD_PRIORITY_TIME_CRITICAL:
192 return THREAD_PRIORITY_HIGHEST;
193 default:
194 return priority; // unknown priority: should never get here
196 #elif defined(ACE_HAS_THREADS) && \
197 (!defined(ACE_LACKS_SETSCHED) || \
198 defined (ACE_HAS_PTHREAD_SCHEDPARAM))
199 // including STHREADS and PTHREADS
200 int const min = priority_min (policy, scope);
201 return priority > min ? priority - 1 : min;
202 #elif defined (ACE_VXWORKS)
203 int const min = priority_min (policy, scope);
204 return priority < min ? priority + 1 : min;
205 #else
206 ACE_UNUSED_ARG (policy);
207 ACE_UNUSED_ARG (scope);
208 ACE_UNUSED_ARG (priority);
209 ACE_NOTSUP_RETURN (-1);
210 #endif /* ACE_HAS_THREADS */
213 ACE_END_VERSIONED_NAMESPACE_DECL