hotspot/src/share/vm/runtime/os.cpp
changeset 13857 93015306affa
parent 13728 882756847a04
child 13921 cfc740741651
equal deleted inserted replaced
13751:7fd047780d47 13857:93015306affa
   199     assert(false, "Should not happen");
   199     assert(false, "Should not happen");
   200     return OS_ERR;
   200     return OS_ERR;
   201   }
   201   }
   202 }
   202 }
   203 
   203 
   204 
   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()
   205 OSReturn os::get_priority(const Thread* const thread, ThreadPriority& priority) {
   207 OSReturn os::get_priority(const Thread* const thread, ThreadPriority& priority) {
   206   int p;
   208   int p;
   207   int os_prio;
   209   int os_prio;
   208   OSReturn ret = get_native_priority(thread, &os_prio);
   210   OSReturn ret = get_native_priority(thread, &os_prio);
   209   if (ret != OS_OK) return ret;
   211   if (ret != OS_OK) return ret;
   210 
   212 
   211   for (p = MaxPriority; p > MinPriority && java_to_os_priority[p] > os_prio; p--) ;
   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   }
   212   priority = (ThreadPriority)p;
   219   priority = (ThreadPriority)p;
   213   return OS_OK;
   220   return OS_OK;
   214 }
   221 }
   215 
   222 
   216 
   223