diff options
author | davidxu <davidxu@FreeBSD.org> | 2012-07-20 03:27:07 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2012-07-20 03:27:07 +0000 |
commit | 298769009da2d2356405a4415808b404e7c7d234 (patch) | |
tree | 1b6cef784d5a2d8453d8014b683ffcf11b224fae /lib/libthr | |
parent | 4583d3fdda444b54d1b6c10aead93bd7a73c8b7b (diff) | |
download | FreeBSD-src-298769009da2d2356405a4415808b404e7c7d234.zip FreeBSD-src-298769009da2d2356405a4415808b404e7c7d234.tar.gz |
Eliminate duplicated code.
Diffstat (limited to 'lib/libthr')
-rw-r--r-- | lib/libthr/thread/thr_getschedparam.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/lib/libthr/thread/thr_getschedparam.c b/lib/libthr/thread/thr_getschedparam.c index b36d724..e9f5d3b 100644 --- a/lib/libthr/thread/thr_getschedparam.c +++ b/lib/libthr/thread/thr_getschedparam.c @@ -53,25 +53,16 @@ _pthread_getschedparam(pthread_t pthread, int *policy, if (policy == NULL || param == NULL) return (EINVAL); - if (pthread == curthread) { - /* - * Avoid searching the thread list when it is the current - * thread. - */ + /* + * Avoid searching the thread list when it is the current + * thread. + */ + if (pthread == curthread) THR_LOCK(curthread); - *policy = curthread->attr.sched_policy; - param->sched_priority = curthread->attr.prio; - THR_UNLOCK(curthread); - ret = 0; - } - /* Find the thread in the list of active threads. */ - else if ((ret = _thr_ref_add(curthread, pthread, /*include dead*/0)) - == 0) { - THR_THREAD_LOCK(curthread, pthread); - *policy = pthread->attr.sched_policy; - param->sched_priority = pthread->attr.prio; - THR_THREAD_UNLOCK(curthread, pthread); - _thr_ref_delete(curthread, pthread); - } + else if ((ret = _thr_find_thread(curthread, pthread, /*include dead*/0))) + return (ret); + *policy = pthread->attr.sched_policy; + param->sched_priority = pthread->attr.prio; + THR_THREAD_UNLOCK(curthread, pthread); return (ret); } |