summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_setschedparam.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libthr/thread/thr_setschedparam.c')
-rw-r--r--lib/libthr/thread/thr_setschedparam.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/libthr/thread/thr_setschedparam.c b/lib/libthr/thread/thr_setschedparam.c
index 5e2d2bf..d766e37 100644
--- a/lib/libthr/thread/thr_setschedparam.c
+++ b/lib/libthr/thread/thr_setschedparam.c
@@ -55,6 +55,13 @@ _pthread_setschedparam(pthread_t pthread, int policy,
if (pthread == curthread) {
THR_LOCK(curthread);
+ if (curthread->attr.sched_policy == policy &&
+ (policy == SCHED_OTHER ||
+ curthread->attr.prio == param->sched_priority)) {
+ pthread->attr.prio = param->sched_priority;
+ THR_UNLOCK(curthread);
+ return (0);
+ }
ret = thr_setscheduler(curthread->tid, policy, param,
sizeof(param));
if (ret == -1)
@@ -67,6 +74,13 @@ _pthread_setschedparam(pthread_t pthread, int policy,
} else if ((ret = _thr_ref_add(curthread, pthread, /*include dead*/0))
== 0) {
THR_THREAD_LOCK(curthread, pthread);
+ if (pthread->attr.sched_policy == policy &&
+ (policy == SCHED_OTHER ||
+ pthread->attr.prio == param->sched_priority)) {
+ pthread->attr.prio = param->sched_priority;
+ THR_THREAD_UNLOCK(curthread, pthread);
+ return (0);
+ }
ret = thr_setscheduler(pthread->tid, policy, param,
sizeof(param));
if (ret == -1)
OpenPOWER on IntegriCloud