summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2012-07-20 03:00:41 +0000
committerdavidxu <davidxu@FreeBSD.org>2012-07-20 03:00:41 +0000
commit4bd927cee6b011b243c700ac09bba0bf5bd832db (patch)
treedb48577e82183a30c73a1ec23d4d136b2d9d5787 /lib/libthr
parenta343cd677988ffdff20f93e0e0145cea2c9bd73a (diff)
downloadFreeBSD-src-4bd927cee6b011b243c700ac09bba0bf5bd832db.zip
FreeBSD-src-4bd927cee6b011b243c700ac09bba0bf5bd832db.tar.gz
Eliminate duplicated code.
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/thread/thr_setschedparam.c46
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);
}
OpenPOWER on IntegriCloud