diff options
author | davidxu <davidxu@FreeBSD.org> | 2006-07-13 22:45:19 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2006-07-13 22:45:19 +0000 |
commit | 2b1dbc0acb716180145708fa4f5787322ac795e2 (patch) | |
tree | 38d9ff271ff8237cbfb86fa05d16da871f8e0dd2 /lib/libthr/thread/thr_setschedparam.c | |
parent | 27c2ca32122c31456d60bac89aae091ff18728b0 (diff) | |
download | FreeBSD-src-2b1dbc0acb716180145708fa4f5787322ac795e2.zip FreeBSD-src-2b1dbc0acb716180145708fa4f5787322ac795e2.tar.gz |
Caching scheduling policy and priority in userland, a critical but baddly
written application is frequently changing thread priority for SCHED_OTHER
policy.
Diffstat (limited to 'lib/libthr/thread/thr_setschedparam.c')
-rw-r--r-- | lib/libthr/thread/thr_setschedparam.c | 14 |
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) |