2 //=============================================================================
4 * @file Sched_Params.cpp
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
19 ACE_Sched_Params::priority_min (const Policy policy
,
22 #if defined(ACE_HAS_PTHREADS) && !defined(ACE_LACKS_SETSCHED)
25 case ACE_SCOPE_THREAD
:
29 return ACE_THR_PRI_FIFO_MIN
;
31 return ACE_THR_PRI_RR_MIN
;
34 return ACE_THR_PRI_OTHER_MIN
;
37 case ACE_SCOPE_PROCESS
:
42 return ACE_PROC_PRI_FIFO_MIN
;
44 return ACE_PROC_PRI_RR_MIN
;
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
;
64 ACE_UNUSED_ARG (policy
);
65 ACE_UNUSED_ARG (scope
);
66 ACE_NOTSUP_RETURN (-1);
67 #endif /* ACE_HAS_PTHREADS */
71 ACE_Sched_Params::priority_max (const Policy policy
,
74 #if defined(ACE_HAS_PTHREADS) && \
75 (!defined(ACE_LACKS_SETSCHED) || \
76 defined (ACE_HAS_PTHREAD_SCHEDPARAM))
80 case ACE_SCOPE_THREAD
:
84 return ACE_THR_PRI_FIFO_MAX
;
86 return ACE_THR_PRI_RR_MAX
;
89 return ACE_THR_PRI_OTHER_MAX
;
92 case ACE_SCOPE_PROCESS
:
97 return ACE_PROC_PRI_FIFO_MAX
;
99 return ACE_PROC_PRI_RR_MAX
;
100 case ACE_SCHED_OTHER
:
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
;
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
,
130 #if defined (ACE_HAS_WTHREADS)
131 ACE_UNUSED_ARG (policy
);
132 ACE_UNUSED_ARG (scope
);
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
;
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
;
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
,
174 #if defined (ACE_HAS_WTHREADS)
175 ACE_UNUSED_ARG (policy
);
176 ACE_UNUSED_ARG (scope
);
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
;
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
;
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