diff --git a/lib/libthr/thread/thr_setprio.c b/lib/libthr/thread/thr_setprio.c index b87d5369dc44..4b7d2c099068 100644 --- a/lib/libthr/thread/thr_setprio.c +++ b/lib/libthr/thread/thr_setprio.c @@ -45,10 +45,9 @@ _pthread_setprio(pthread_t pthread, int prio) int ret; param.sched_priority = prio; - if (pthread == curthread) { - pthread = curthread; + if (pthread == curthread) THR_LOCK(curthread); - } else if ((ret = _thr_find_thread(curthread, pthread, /*include dead*/0))) + else if ((ret = _thr_find_thread(curthread, pthread, /*include dead*/0))) return (ret); if (pthread->attr.sched_policy == SCHED_OTHER || pthread->attr.prio == prio) { diff --git a/lib/libthr/thread/thr_setschedparam.c b/lib/libthr/thread/thr_setschedparam.c index 343e49c618c2..6e98fb43bc15 100644 --- a/lib/libthr/thread/thr_setschedparam.c +++ b/lib/libthr/thread/thr_setschedparam.c @@ -53,10 +53,9 @@ _pthread_setschedparam(pthread_t pthread, int policy, struct pthread *curthread = _get_curthread(); int ret; - if (pthread == curthread) { - pthread = curthread; + if (pthread == curthread) THR_LOCK(curthread); - } else if ((ret = _thr_find_thread(curthread, pthread, + else if ((ret = _thr_find_thread(curthread, pthread, /*include dead*/0)) != 0) return (ret); if (pthread->attr.sched_policy == policy &&