src/hotspot/os/bsd/os_bsd.cpp
changeset 53104 95937fc2a05e
parent 53077 33b8f6f4cdf5
child 53155 c3d6035c11f3
--- a/src/hotspot/os/bsd/os_bsd.cpp	Thu Dec 27 21:17:11 2018 -0500
+++ b/src/hotspot/os/bsd/os_bsd.cpp	Fri Dec 21 14:42:08 2018 +0100
@@ -2330,14 +2330,13 @@
 #elif defined(__APPLE__) || defined(__NetBSD__)
   struct sched_param sp;
   int policy;
-  pthread_t self = pthread_self();
-
-  if (pthread_getschedparam(self, &policy, &sp) != 0) {
+
+  if (pthread_getschedparam(thread->osthread()->pthread_id(), &policy, &sp) != 0) {
     return OS_ERR;
   }
 
   sp.sched_priority = newpri;
-  if (pthread_setschedparam(self, policy, &sp) != 0) {
+  if (pthread_setschedparam(thread->osthread()->pthread_id(), policy, &sp) != 0) {
     return OS_ERR;
   }
 
@@ -2361,8 +2360,14 @@
   int policy;
   struct sched_param sp;
 
-  pthread_getschedparam(pthread_self(), &policy, &sp);
-  *priority_ptr = sp.sched_priority;
+  int res = pthread_getschedparam(thread->osthread()->pthread_id(), &policy, &sp);
+  if (res != 0) {
+    *priority_ptr = -1;
+    return OS_ERR;
+  } else {
+    *priority_ptr = sp.sched_priority;
+    return OS_OK;
+  }
 #else
   *priority_ptr = getpriority(PRIO_PROCESS, thread->osthread()->thread_id());
 #endif