8215707: [macosx] fix pthread_getschedparam and pthread_setschedparam calls
authormbaesken
Fri, 21 Dec 2018 14:42:08 +0100
changeset 53104 95937fc2a05e
parent 53103 67e3a8b3449c
child 53105 6ac04cfbefdf
8215707: [macosx] fix pthread_getschedparam and pthread_setschedparam calls Reviewed-by: clanger, dholmes
src/hotspot/os/bsd/os_bsd.cpp
--- 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