# HG changeset patch # User mbaesken # Date 1570710043 -7200 # Node ID 9770ff6f0b20ad42a3e34c2d0bfe1faf3a2d66c3 # Parent 97974e906efb771c72f9dfa25342b5107a9a57b4 8232107: support ThreadPriorityPolicy flag on AIX Reviewed-by: clanger, dholmes diff -r 97974e906efb -r 9770ff6f0b20 src/hotspot/os/aix/os_aix.cpp --- a/src/hotspot/os/aix/os_aix.cpp Mon Oct 14 22:20:03 2019 -0400 +++ b/src/hotspot/os/aix/os_aix.cpp Thu Oct 10 14:20:43 2019 +0200 @@ -2643,8 +2643,24 @@ 60 // 11 CriticalPriority }; +static int prio_init() { + if (ThreadPriorityPolicy == 1) { + if (geteuid() != 0) { + if (!FLAG_IS_DEFAULT(ThreadPriorityPolicy)) { + warning("-XX:ThreadPriorityPolicy=1 may require system level permission, " \ + "e.g., being the root user. If the necessary permission is not " \ + "possessed, changes to priority will be silently ignored."); + } + } + } + if (UseCriticalJavaThreadPriority) { + os::java_to_os_priority[MaxPriority] = os::java_to_os_priority[CriticalPriority]; + } + return 0; +} + OSReturn os::set_native_priority(Thread* thread, int newpri) { - if (!UseThreadPriorities) return OS_OK; + if (!UseThreadPriorities || ThreadPriorityPolicy == 0) return OS_OK; pthread_t thr = thread->osthread()->pthread_id(); int policy = SCHED_OTHER; struct sched_param param; @@ -2659,7 +2675,7 @@ } OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr) { - if (!UseThreadPriorities) { + if (!UseThreadPriorities || ThreadPriorityPolicy == 0) { *priority_ptr = java_to_os_priority[NormPriority]; return OS_OK; } @@ -3569,6 +3585,9 @@ } } + // initialize thread priority policy + prio_init(); + return JNI_OK; }