184 OSReturn os::set_priority(Thread* thread, ThreadPriority p) {
185 #ifdef ASSERT
186 if (!(!thread->is_Java_thread() ||
187 Thread::current() == thread ||
188 Threads_lock->owned_by_self()
189 || thread->is_Compiler_thread()
190 )) {
191 assert(false, "possibility of dangling Thread pointer");
192 }
193 #endif
194
195 if (p >= MinPriority && p <= MaxPriority) {
196 int priority = java_to_os_priority[p];
197 return set_native_priority(thread, priority);
198 } else {
199 assert(false, "Should not happen");
200 return OS_ERR;
201 }
202 }
203
204
205 OSReturn os::get_priority(const Thread* const thread, ThreadPriority& priority) {
206 int p;
207 int os_prio;
208 OSReturn ret = get_native_priority(thread, &os_prio);
209 if (ret != OS_OK) return ret;
210
211 for (p = MaxPriority; p > MinPriority && java_to_os_priority[p] > os_prio; p--) ;
212 priority = (ThreadPriority)p;
213 return OS_OK;
214 }
215
216
217 // --------------------- sun.misc.Signal (optional) ---------------------
218
219
220 // SIGBREAK is sent by the keyboard to query the VM state
221 #ifndef SIGBREAK
222 #define SIGBREAK SIGQUIT
223 #endif
224
225 // sigexitnum_pd is a platform-specific special signal used for terminating the Signal thread.
226
227
228 static void signal_thread_entry(JavaThread* thread, TRAPS) {
229 os::set_priority(thread, NearMaxPriority);
230 while (true) {
231 int sig;
|
184 OSReturn os::set_priority(Thread* thread, ThreadPriority p) {
185 #ifdef ASSERT
186 if (!(!thread->is_Java_thread() ||
187 Thread::current() == thread ||
188 Threads_lock->owned_by_self()
189 || thread->is_Compiler_thread()
190 )) {
191 assert(false, "possibility of dangling Thread pointer");
192 }
193 #endif
194
195 if (p >= MinPriority && p <= MaxPriority) {
196 int priority = java_to_os_priority[p];
197 return set_native_priority(thread, priority);
198 } else {
199 assert(false, "Should not happen");
200 return OS_ERR;
201 }
202 }
203
204 // The mapping from OS priority back to Java priority may be inexact because
205 // Java priorities can map M:1 with native priorities. If you want the definite
206 // Java priority then use JavaThread::java_priority()
207 OSReturn os::get_priority(const Thread* const thread, ThreadPriority& priority) {
208 int p;
209 int os_prio;
210 OSReturn ret = get_native_priority(thread, &os_prio);
211 if (ret != OS_OK) return ret;
212
213 if (java_to_os_priority[MaxPriority] > java_to_os_priority[MinPriority]) {
214 for (p = MaxPriority; p > MinPriority && java_to_os_priority[p] > os_prio; p--) ;
215 } else {
216 // niceness values are in reverse order
217 for (p = MaxPriority; p > MinPriority && java_to_os_priority[p] < os_prio; p--) ;
218 }
219 priority = (ThreadPriority)p;
220 return OS_OK;
221 }
222
223
224 // --------------------- sun.misc.Signal (optional) ---------------------
225
226
227 // SIGBREAK is sent by the keyboard to query the VM state
228 #ifndef SIGBREAK
229 #define SIGBREAK SIGQUIT
230 #endif
231
232 // sigexitnum_pd is a platform-specific special signal used for terminating the Signal thread.
233
234
235 static void signal_thread_entry(JavaThread* thread, TRAPS) {
236 os::set_priority(thread, NearMaxPriority);
237 while (true) {
238 int sig;
|