src/os/bsd/vm/os_bsd.cpp

Print this page
rev 3129 : 7125793: MAC: test_gamma should always work
Summary: Fix gamma launcher on Mac OS X and reconcile test_gamma script on Unix platforms
Reviewed-by: dcubed, ohair, jcoomes, dholmes, ksrini
Contributed-by: james.melvin@oracle.com
rev 3137 : 7082553: Interpret Thread.setPriority(Thread.MAX_PRIORITY) to mean FX60 on Solaris 10 and 11
Summary: Add CriticalPriority == MaxPriority+1 and enable scheduling class as well as thread priority to change on Solaris.
Reviewed-by: dholmes, dcubed
   1 /*
   2  * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 284 #elif defined(IA64)
 285 static char cpu_arch[] = "ia64";
 286 #elif defined(IA32)
 287 static char cpu_arch[] = "i386";
 288 #elif defined(AMD64)
 289 static char cpu_arch[] = "amd64";
 290 #elif defined(ARM)
 291 static char cpu_arch[] = "arm";
 292 #elif defined(PPC)
 293 static char cpu_arch[] = "ppc";
 294 #elif defined(SPARC)
 295 #  ifdef _LP64
 296 static char cpu_arch[] = "sparcv9";
 297 #  else
 298 static char cpu_arch[] = "sparc";
 299 #  endif
 300 #else
 301 #error Add appropriate cpu_arch setting
 302 #endif
 303 






 304 
 305 #ifndef _ALLBSD_SOURCE
 306 // pid_t gettid()
 307 //
 308 // Returns the kernel thread id of the currently running thread. Kernel
 309 // thread id is used to access /proc.
 310 //
 311 // (Note that getpid() on BsdThreads returns kernel thread id too; but
 312 // on NPTL, it returns the same pid for all threads, as required by POSIX.)
 313 //
 314 pid_t os::Bsd::gettid() {
 315   int rslt = syscall(SYS_gettid);
 316   if (rslt == -1) {
 317      // old kernel, no NPTL support
 318      return getpid();
 319   } else {
 320      return (pid_t)rslt;
 321   }
 322 }
 323 


2490                                  char* buf, size_t buflen);
2491 
2492 void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) {
2493   st->print_cr("Signal Handlers:");
2494   print_signal_handler(st, SIGSEGV, buf, buflen);
2495   print_signal_handler(st, SIGBUS , buf, buflen);
2496   print_signal_handler(st, SIGFPE , buf, buflen);
2497   print_signal_handler(st, SIGPIPE, buf, buflen);
2498   print_signal_handler(st, SIGXFSZ, buf, buflen);
2499   print_signal_handler(st, SIGILL , buf, buflen);
2500   print_signal_handler(st, INTERRUPT_SIGNAL, buf, buflen);
2501   print_signal_handler(st, SR_signum, buf, buflen);
2502   print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen);
2503   print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen);
2504   print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen);
2505   print_signal_handler(st, BREAK_SIGNAL, buf, buflen);
2506 }
2507 
2508 static char saved_jvm_path[MAXPATHLEN] = {0};
2509 
2510 // Find the full path to the current module, libjvm.so or libjvm_g.so
2511 void os::jvm_path(char *buf, jint buflen) {
2512   // Error checking.
2513   if (buflen < MAXPATHLEN) {
2514     assert(false, "must use a large-enough buffer");
2515     buf[0] = '\0';
2516     return;
2517   }
2518   // Lazy resolve the path to current module.
2519   if (saved_jvm_path[0] != 0) {
2520     strcpy(buf, saved_jvm_path);
2521     return;
2522   }
2523 
2524   char dli_fname[MAXPATHLEN];
2525   bool ret = dll_address_to_library_name(
2526                 CAST_FROM_FN_PTR(address, os::jvm_path),
2527                 dli_fname, sizeof(dli_fname), NULL);
2528   assert(ret != 0, "cannot locate libjvm");
2529   char *rp = realpath(dli_fname, buf);
2530   if (rp == NULL)
2531     return;
2532 
2533   if (Arguments::created_by_gamma_launcher()) {
2534     // Support for the gamma launcher.  Typical value for buf is
2535     // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so".  If "/jre/lib/" appears at
2536     // the right place in the string, then assume we are installed in a JDK and
2537     // we're done.  Otherwise, check for a JAVA_HOME environment variable and fix
2538     // up the path so it looks like libjvm.so is installed there (append a
2539     // fake suffix hotspot/libjvm.so).
2540     const char *p = buf + strlen(buf) - 1;
2541     for (int count = 0; p > buf && count < 5; ++count) {
2542       for (--p; p > buf && *p != '/'; --p)
2543         /* empty */ ;
2544     }
2545 
2546     if (strncmp(p, "/jre/lib/", 9) != 0) {
2547       // Look for JAVA_HOME in the environment.
2548       char* java_home_var = ::getenv("JAVA_HOME");
2549       if (java_home_var != NULL && java_home_var[0] != 0) {
2550         char* jrelib_p;
2551         int len;
2552 
2553         // Check the current module name "libjvm.so" or "libjvm_g.so".
2554         p = strrchr(buf, '/');
2555         assert(strstr(p, "/libjvm") == p, "invalid library name");
2556         p = strstr(p, "_g") ? "_g" : "";
2557 
2558         rp = realpath(java_home_var, buf);
2559         if (rp == NULL)
2560           return;
2561 
2562         // determine if this is a legacy image or modules image
2563         // modules image doesn't have "jre" subdirectory
2564         len = strlen(buf);
2565         jrelib_p = buf + len;
2566         snprintf(jrelib_p, buflen-len, "/jre/lib/%s", cpu_arch);


2567         if (0 != access(buf, F_OK)) {
2568           snprintf(jrelib_p, buflen-len, "/lib/%s", cpu_arch);
2569         }
2570 











2571         if (0 == access(buf, F_OK)) {
2572           // Use current module name "libjvm[_g].so" instead of
2573           // "libjvm"debug_only("_g")".so" since for fastdebug version
2574           // we should have "libjvm.so" but debug_only("_g") adds "_g"!
2575           len = strlen(buf);
2576           snprintf(buf + len, buflen-len, "/hotspot/libjvm%s.so", p);
2577         } else {
2578           // Go back to path of .so
2579           rp = realpath(dli_fname, buf);
2580           if (rp == NULL)
2581             return;
2582         }
2583       }
2584     }
2585   }
2586 
2587   strcpy(saved_jvm_path, buf);
2588 }
2589 
2590 void os::print_jni_name_prefix_on(outputStream* st, int args_size) {
2591   // no prefix required, not even "_"
2592 }
2593 
2594 void os::print_jni_name_suffix_on(outputStream* st, int args_size) {
2595   // no suffix required
2596 }
2597 
2598 ////////////////////////////////////////////////////////////////////////////////


3553 }
3554 
3555 ////////////////////////////////////////////////////////////////////////////////
3556 // thread priority support
3557 
3558 // Note: Normal Bsd applications are run with SCHED_OTHER policy. SCHED_OTHER
3559 // only supports dynamic priority, static priority must be zero. For real-time
3560 // applications, Bsd supports SCHED_RR which allows static priority (1-99).
3561 // However, for large multi-threaded applications, SCHED_RR is not only slower
3562 // than SCHED_OTHER, but also very unstable (my volano tests hang hard 4 out
3563 // of 5 runs - Sep 2005).
3564 //
3565 // The following code actually changes the niceness of kernel-thread/LWP. It
3566 // has an assumption that setpriority() only modifies one kernel-thread/LWP,
3567 // not the entire user process, and user level threads are 1:1 mapped to kernel
3568 // threads. It has always been the case, but could change in the future. For
3569 // this reason, the code should not be used as default (ThreadPriorityPolicy=0).
3570 // It is only used when ThreadPriorityPolicy=1 and requires root privilege.
3571 
3572 #if defined(_ALLBSD_SOURCE) && !defined(__APPLE__)
3573 int os::java_to_os_priority[MaxPriority + 1] = {
3574   19,              // 0 Entry should never be used
3575 
3576    0,              // 1 MinPriority
3577    3,              // 2
3578    6,              // 3
3579 
3580    10,              // 4
3581    15,              // 5 NormPriority
3582    18,              // 6
3583 
3584    21,              // 7
3585    25,              // 8
3586    28,              // 9 NearMaxPriority
3587 
3588    31              // 10 MaxPriority


3589 };
3590 #elif defined(__APPLE__)
3591 /* Using Mach high-level priority assignments */
3592 int os::java_to_os_priority[MaxPriority + 1] = {
3593    0,              // 0 Entry should never be used (MINPRI_USER)
3594 
3595   27,              // 1 MinPriority
3596   28,              // 2
3597   29,              // 3
3598 
3599   30,              // 4
3600   31,              // 5 NormPriority (BASEPRI_DEFAULT)
3601   32,              // 6
3602 
3603   33,              // 7
3604   34,              // 8
3605   35,              // 9 NearMaxPriority
3606 
3607   36               // 10 MaxPriority


3608 };
3609 #else
3610 int os::java_to_os_priority[MaxPriority + 1] = {
3611   19,              // 0 Entry should never be used
3612 
3613    4,              // 1 MinPriority
3614    3,              // 2
3615    2,              // 3
3616 
3617    1,              // 4
3618    0,              // 5 NormPriority
3619   -1,              // 6
3620 
3621   -2,              // 7
3622   -3,              // 8
3623   -4,              // 9 NearMaxPriority
3624 
3625   -5               // 10 MaxPriority


3626 };
3627 #endif
3628 
3629 static int prio_init() {
3630   if (ThreadPriorityPolicy == 1) {
3631     // Only root can raise thread priority. Don't allow ThreadPriorityPolicy=1
3632     // if effective uid is not root. Perhaps, a more elegant way of doing
3633     // this is to test CAP_SYS_NICE capability, but that will require libcap.so
3634     if (geteuid() != 0) {
3635       if (!FLAG_IS_DEFAULT(ThreadPriorityPolicy)) {
3636         warning("-XX:ThreadPriorityPolicy requires root privilege on Bsd");
3637       }
3638       ThreadPriorityPolicy = 0;
3639     }
3640   }



3641   return 0;
3642 }
3643 
3644 OSReturn os::set_native_priority(Thread* thread, int newpri) {
3645   if ( !UseThreadPriorities || ThreadPriorityPolicy == 0 ) return OS_OK;
3646 
3647 #ifdef __OpenBSD__
3648   // OpenBSD pthread_setprio starves low priority threads
3649   return OS_OK;
3650 #elif defined(__FreeBSD__)
3651   int ret = pthread_setprio(thread->osthread()->pthread_id(), newpri);
3652 #elif defined(__APPLE__) || defined(__NetBSD__)
3653   struct sched_param sp;
3654   int policy;
3655   pthread_t self = pthread_self();
3656 
3657   if (pthread_getschedparam(self, &policy, &sp) != 0)
3658     return OS_ERR;
3659 
3660   sp.sched_priority = newpri;


   1 /*
   2  * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 284 #elif defined(IA64)
 285 static char cpu_arch[] = "ia64";
 286 #elif defined(IA32)
 287 static char cpu_arch[] = "i386";
 288 #elif defined(AMD64)
 289 static char cpu_arch[] = "amd64";
 290 #elif defined(ARM)
 291 static char cpu_arch[] = "arm";
 292 #elif defined(PPC)
 293 static char cpu_arch[] = "ppc";
 294 #elif defined(SPARC)
 295 #  ifdef _LP64
 296 static char cpu_arch[] = "sparcv9";
 297 #  else
 298 static char cpu_arch[] = "sparc";
 299 #  endif
 300 #else
 301 #error Add appropriate cpu_arch setting
 302 #endif
 303 
 304 // Compiler variant
 305 #ifdef COMPILER2
 306 #define COMPILER_VARIANT "server"
 307 #else
 308 #define COMPILER_VARIANT "client"
 309 #endif
 310 
 311 #ifndef _ALLBSD_SOURCE
 312 // pid_t gettid()
 313 //
 314 // Returns the kernel thread id of the currently running thread. Kernel
 315 // thread id is used to access /proc.
 316 //
 317 // (Note that getpid() on BsdThreads returns kernel thread id too; but
 318 // on NPTL, it returns the same pid for all threads, as required by POSIX.)
 319 //
 320 pid_t os::Bsd::gettid() {
 321   int rslt = syscall(SYS_gettid);
 322   if (rslt == -1) {
 323      // old kernel, no NPTL support
 324      return getpid();
 325   } else {
 326      return (pid_t)rslt;
 327   }
 328 }
 329 


2496                                  char* buf, size_t buflen);
2497 
2498 void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) {
2499   st->print_cr("Signal Handlers:");
2500   print_signal_handler(st, SIGSEGV, buf, buflen);
2501   print_signal_handler(st, SIGBUS , buf, buflen);
2502   print_signal_handler(st, SIGFPE , buf, buflen);
2503   print_signal_handler(st, SIGPIPE, buf, buflen);
2504   print_signal_handler(st, SIGXFSZ, buf, buflen);
2505   print_signal_handler(st, SIGILL , buf, buflen);
2506   print_signal_handler(st, INTERRUPT_SIGNAL, buf, buflen);
2507   print_signal_handler(st, SR_signum, buf, buflen);
2508   print_signal_handler(st, SHUTDOWN1_SIGNAL, buf, buflen);
2509   print_signal_handler(st, SHUTDOWN2_SIGNAL , buf, buflen);
2510   print_signal_handler(st, SHUTDOWN3_SIGNAL , buf, buflen);
2511   print_signal_handler(st, BREAK_SIGNAL, buf, buflen);
2512 }
2513 
2514 static char saved_jvm_path[MAXPATHLEN] = {0};
2515 
2516 // Find the full path to the current module, libjvm or libjvm_g
2517 void os::jvm_path(char *buf, jint buflen) {
2518   // Error checking.
2519   if (buflen < MAXPATHLEN) {
2520     assert(false, "must use a large-enough buffer");
2521     buf[0] = '\0';
2522     return;
2523   }
2524   // Lazy resolve the path to current module.
2525   if (saved_jvm_path[0] != 0) {
2526     strcpy(buf, saved_jvm_path);
2527     return;
2528   }
2529 
2530   char dli_fname[MAXPATHLEN];
2531   bool ret = dll_address_to_library_name(
2532                 CAST_FROM_FN_PTR(address, os::jvm_path),
2533                 dli_fname, sizeof(dli_fname), NULL);
2534   assert(ret != 0, "cannot locate libjvm");
2535   char *rp = realpath(dli_fname, buf);
2536   if (rp == NULL)
2537     return;
2538 
2539   if (Arguments::created_by_gamma_launcher()) {
2540     // Support for the gamma launcher.  Typical value for buf is
2541     // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm".  If "/jre/lib/" appears at
2542     // the right place in the string, then assume we are installed in a JDK and
2543     // we're done.  Otherwise, check for a JAVA_HOME environment variable and
2544     // construct a path to the JVM being overridden.
2545 
2546     const char *p = buf + strlen(buf) - 1;
2547     for (int count = 0; p > buf && count < 5; ++count) {
2548       for (--p; p > buf && *p != '/'; --p)
2549         /* empty */ ;
2550     }
2551 
2552     if (strncmp(p, "/jre/lib/", 9) != 0) {
2553       // Look for JAVA_HOME in the environment.
2554       char* java_home_var = ::getenv("JAVA_HOME");
2555       if (java_home_var != NULL && java_home_var[0] != 0) {
2556         char* jrelib_p;
2557         int len;
2558 
2559         // Check the current module name "libjvm" or "libjvm_g".
2560         p = strrchr(buf, '/');
2561         assert(strstr(p, "/libjvm") == p, "invalid library name");
2562         p = strstr(p, "_g") ? "_g" : "";
2563 
2564         rp = realpath(java_home_var, buf);
2565         if (rp == NULL)
2566           return;
2567 
2568         // determine if this is a legacy image or modules image
2569         // modules image doesn't have "jre" subdirectory
2570         len = strlen(buf);
2571         jrelib_p = buf + len;
2572 
2573         // Add the appropriate library subdir
2574         snprintf(jrelib_p, buflen-len, "/jre/lib");
2575         if (0 != access(buf, F_OK)) {
2576           snprintf(jrelib_p, buflen-len, "/lib");
2577         }
2578 
2579         // Add the appropriate client or server subdir
2580         len = strlen(buf);
2581         jrelib_p = buf + len;
2582         snprintf(jrelib_p, buflen-len, "/%s", COMPILER_VARIANT);
2583         if (0 != access(buf, F_OK)) {
2584           snprintf(jrelib_p, buflen-len, "");
2585         }
2586 
2587         // If the path exists within JAVA_HOME, add the JVM library name
2588         // to complete the path to JVM being overridden.  Otherwise fallback
2589         // to the path to the current library.
2590         if (0 == access(buf, F_OK)) {
2591           // Use current module name "libjvm[_g]" instead of
2592           // "libjvm"debug_only("_g")"" since for fastdebug version
2593           // we should have "libjvm" but debug_only("_g") adds "_g"!
2594           len = strlen(buf);
2595           snprintf(buf + len, buflen-len, "/libjvm%s%s", p, JNI_LIB_SUFFIX);
2596         } else {
2597           // Fall back to path of current library
2598           rp = realpath(dli_fname, buf);
2599           if (rp == NULL)
2600             return;
2601         }
2602       }
2603     }
2604   }
2605 
2606   strcpy(saved_jvm_path, buf);
2607 }
2608 
2609 void os::print_jni_name_prefix_on(outputStream* st, int args_size) {
2610   // no prefix required, not even "_"
2611 }
2612 
2613 void os::print_jni_name_suffix_on(outputStream* st, int args_size) {
2614   // no suffix required
2615 }
2616 
2617 ////////////////////////////////////////////////////////////////////////////////


3572 }
3573 
3574 ////////////////////////////////////////////////////////////////////////////////
3575 // thread priority support
3576 
3577 // Note: Normal Bsd applications are run with SCHED_OTHER policy. SCHED_OTHER
3578 // only supports dynamic priority, static priority must be zero. For real-time
3579 // applications, Bsd supports SCHED_RR which allows static priority (1-99).
3580 // However, for large multi-threaded applications, SCHED_RR is not only slower
3581 // than SCHED_OTHER, but also very unstable (my volano tests hang hard 4 out
3582 // of 5 runs - Sep 2005).
3583 //
3584 // The following code actually changes the niceness of kernel-thread/LWP. It
3585 // has an assumption that setpriority() only modifies one kernel-thread/LWP,
3586 // not the entire user process, and user level threads are 1:1 mapped to kernel
3587 // threads. It has always been the case, but could change in the future. For
3588 // this reason, the code should not be used as default (ThreadPriorityPolicy=0).
3589 // It is only used when ThreadPriorityPolicy=1 and requires root privilege.
3590 
3591 #if defined(_ALLBSD_SOURCE) && !defined(__APPLE__)
3592 int os::java_to_os_priority[CriticalPriority + 1] = {
3593   19,              // 0 Entry should never be used
3594 
3595    0,              // 1 MinPriority
3596    3,              // 2
3597    6,              // 3
3598 
3599   10,              // 4
3600   15,              // 5 NormPriority
3601   18,              // 6
3602 
3603   21,              // 7
3604   25,              // 8
3605   28,              // 9 NearMaxPriority
3606 
3607   31,              // 10 MaxPriority
3608 
3609   31               // 11 CriticalPriority
3610 };
3611 #elif defined(__APPLE__)
3612 /* Using Mach high-level priority assignments */
3613 int os::java_to_os_priority[CriticalPriority + 1] = {
3614    0,              // 0 Entry should never be used (MINPRI_USER)
3615 
3616   27,              // 1 MinPriority
3617   28,              // 2
3618   29,              // 3
3619 
3620   30,              // 4
3621   31,              // 5 NormPriority (BASEPRI_DEFAULT)
3622   32,              // 6
3623 
3624   33,              // 7
3625   34,              // 8
3626   35,              // 9 NearMaxPriority
3627 
3628   36,              // 10 MaxPriority
3629 
3630   36               // 11 CriticalPriority
3631 };
3632 #else
3633 int os::java_to_os_priority[CriticalPriority + 1] = {
3634   19,              // 0 Entry should never be used
3635 
3636    4,              // 1 MinPriority
3637    3,              // 2
3638    2,              // 3
3639 
3640    1,              // 4
3641    0,              // 5 NormPriority
3642   -1,              // 6
3643 
3644   -2,              // 7
3645   -3,              // 8
3646   -4,              // 9 NearMaxPriority
3647 
3648   -5,              // 10 MaxPriority
3649 
3650   -5               // 11 CriticalPriority
3651 };
3652 #endif
3653 
3654 static int prio_init() {
3655   if (ThreadPriorityPolicy == 1) {
3656     // Only root can raise thread priority. Don't allow ThreadPriorityPolicy=1
3657     // if effective uid is not root. Perhaps, a more elegant way of doing
3658     // this is to test CAP_SYS_NICE capability, but that will require libcap.so
3659     if (geteuid() != 0) {
3660       if (!FLAG_IS_DEFAULT(ThreadPriorityPolicy)) {
3661         warning("-XX:ThreadPriorityPolicy requires root privilege on Bsd");
3662       }
3663       ThreadPriorityPolicy = 0;
3664     }
3665   }
3666   if (UseCriticalJavaThreadPriority) {
3667     os::java_to_os_priority[MaxPriority] = os::java_to_os_priority[CriticalPriority];
3668   }
3669   return 0;
3670 }
3671 
3672 OSReturn os::set_native_priority(Thread* thread, int newpri) {
3673   if ( !UseThreadPriorities || ThreadPriorityPolicy == 0 ) return OS_OK;
3674 
3675 #ifdef __OpenBSD__
3676   // OpenBSD pthread_setprio starves low priority threads
3677   return OS_OK;
3678 #elif defined(__FreeBSD__)
3679   int ret = pthread_setprio(thread->osthread()->pthread_id(), newpri);
3680 #elif defined(__APPLE__) || defined(__NetBSD__)
3681   struct sched_param sp;
3682   int policy;
3683   pthread_t self = pthread_self();
3684 
3685   if (pthread_getschedparam(self, &policy, &sp) != 0)
3686     return OS_ERR;
3687 
3688   sp.sched_priority = newpri;