diff options
author | davidxu <davidxu@FreeBSD.org> | 2012-07-20 03:00:41 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2012-07-20 03:00:41 +0000 |
commit | 4bd927cee6b011b243c700ac09bba0bf5bd832db (patch) | |
tree | db48577e82183a30c73a1ec23d4d136b2d9d5787 /lib | |
parent | a343cd677988ffdff20f93e0e0145cea2c9bd73a (diff) | |
download | FreeBSD-src-4bd927cee6b011b243c700ac09bba0bf5bd832db.zip FreeBSD-src-4bd927cee6b011b243c700ac09bba0bf5bd832db.tar.gz |
Eliminate duplicated code.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libthr/thread/thr_setschedparam.c | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/lib/libthr/thread/thr_setschedparam.c b/lib/libthr/thread/thr_setschedparam.c index a8a15d1..343e49c 100644 --- a/lib/libthr/thread/thr_setschedparam.c +++ b/lib/libthr/thread/thr_setschedparam.c @@ -54,39 +54,25 @@ _pthread_setschedparam(pthread_t pthread, int policy, int ret; if (pthread == curthread) { + 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); - if (ret == -1) - ret = errno; - else { - curthread->attr.sched_policy = policy; - curthread->attr.prio = param->sched_priority; - } - THR_UNLOCK(curthread); } else if ((ret = _thr_find_thread(curthread, pthread, - /*include dead*/0)) == 0) { - 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); - if (ret == -1) - ret = errno; - else { - pthread->attr.sched_policy = policy; - pthread->attr.prio = param->sched_priority; - } + /*include dead*/0)) != 0) + return (ret); + 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); + if (ret == -1) + ret = errno; + else { + pthread->attr.sched_policy = policy; + pthread->attr.prio = param->sched_priority; + } + THR_THREAD_UNLOCK(curthread, pthread); return (ret); } |