mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8215707: [macosx] fix pthread_getschedparam and pthread_setschedparam calls
Reviewed-by: clanger, dholmes
This commit is contained in:
parent
526f854cc1
commit
e4bc6e7ab9
1 changed files with 10 additions and 5 deletions
|
@ -2330,14 +2330,13 @@ OSReturn os::set_native_priority(Thread* thread, int newpri) {
|
||||||
#elif defined(__APPLE__) || defined(__NetBSD__)
|
#elif defined(__APPLE__) || defined(__NetBSD__)
|
||||||
struct sched_param sp;
|
struct sched_param sp;
|
||||||
int policy;
|
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;
|
return OS_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
sp.sched_priority = newpri;
|
sp.sched_priority = newpri;
|
||||||
if (pthread_setschedparam(self, policy, &sp) != 0) {
|
if (pthread_setschedparam(thread->osthread()->pthread_id(), policy, &sp) != 0) {
|
||||||
return OS_ERR;
|
return OS_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2361,8 +2360,14 @@ OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr)
|
||||||
int policy;
|
int policy;
|
||||||
struct sched_param sp;
|
struct sched_param sp;
|
||||||
|
|
||||||
pthread_getschedparam(pthread_self(), &policy, &sp);
|
int res = pthread_getschedparam(thread->osthread()->pthread_id(), &policy, &sp);
|
||||||
*priority_ptr = sp.sched_priority;
|
if (res != 0) {
|
||||||
|
*priority_ptr = -1;
|
||||||
|
return OS_ERR;
|
||||||
|
} else {
|
||||||
|
*priority_ptr = sp.sched_priority;
|
||||||
|
return OS_OK;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
*priority_ptr = getpriority(PRIO_PROCESS, thread->osthread()->thread_id());
|
*priority_ptr = getpriority(PRIO_PROCESS, thread->osthread()->thread_id());
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue