diff options
Diffstat (limited to 'lib/libthr/thread/thr_getschedparam.c')
-rw-r--r-- | lib/libthr/thread/thr_getschedparam.c | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/lib/libthr/thread/thr_getschedparam.c b/lib/libthr/thread/thr_getschedparam.c index b36d724..ff6c3ab 100644 --- a/lib/libthr/thread/thr_getschedparam.c +++ b/lib/libthr/thread/thr_getschedparam.c @@ -48,30 +48,21 @@ _pthread_getschedparam(pthread_t pthread, int *policy, struct sched_param *param) { struct pthread *curthread = _get_curthread(); - int ret; + int ret = 0; 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); } |