diff options
author | davidxu <davidxu@FreeBSD.org> | 2008-03-06 01:59:08 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2008-03-06 01:59:08 +0000 |
commit | 5f0ffdddf16bb5fe610d2119db427fee48117fa9 (patch) | |
tree | f4e0b86044000d6ba28d44e30072777363d743f6 /lib/libthr | |
parent | c02fd5a948d488e420ef1d3f5907b52c23e7ba4a (diff) | |
download | FreeBSD-src-5f0ffdddf16bb5fe610d2119db427fee48117fa9.zip FreeBSD-src-5f0ffdddf16bb5fe610d2119db427fee48117fa9.tar.gz |
Restore code setting new thread's scheduler parameters, I was thinking
that there might be starvations, but because we have already locked the
thread, the cpuset settings will always be done before the new thread
does real-world work.
Diffstat (limited to 'lib/libthr')
-rw-r--r-- | lib/libthr/thread/thr_create.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/lib/libthr/thread/thr_create.c b/lib/libthr/thread/thr_create.c index 692ec45..0dc1436 100644 --- a/lib/libthr/thread/thr_create.c +++ b/lib/libthr/thread/thr_create.c @@ -29,6 +29,7 @@ #include "namespace.h" #include <sys/types.h> +#include <sys/rtprio.h> #include <sys/signalvar.h> #include <errno.h> #include <stdlib.h> @@ -52,6 +53,7 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr, struct pthread *curthread, *new_thread; struct thr_param param; struct sched_param sched_param; + struct rtprio rtp; int ret = 0, locked, create_suspended; sigset_t set, oset; cpuset_t *cpuset = NULL; @@ -135,8 +137,7 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr, _thr_link(curthread, new_thread); /* Return thread pointer eariler so that new thread can use it. */ (*thread) = new_thread; - if (SHOULD_REPORT_EVENT(curthread, TD_CREATE) || cpuset != NULL || - new_thread->attr.sched_inherit != PTHREAD_INHERIT_SCHED) { + if (SHOULD_REPORT_EVENT(curthread, TD_CREATE) || cpuset != NULL) { THR_THREAD_LOCK(curthread, new_thread); locked = 1; } else @@ -152,7 +153,14 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr, param.flags = 0; if (new_thread->attr.flags & PTHREAD_SCOPE_SYSTEM) param.flags |= THR_SYSTEM_SCOPE; - param.rtp = NULL; + if (new_thread->attr.sched_inherit == PTHREAD_INHERIT_SCHED) + param.rtp = NULL; + else { + sched_param.sched_priority = new_thread->attr.prio; + _schedparam_to_rtp(new_thread->attr.sched_policy, + &sched_param, &rtp); + param.rtp = &rtp; + } /* Schedule the new thread. */ if (create_suspended) { @@ -205,18 +213,6 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr, } } - if (new_thread->attr.sched_inherit != PTHREAD_INHERIT_SCHED) { - sched_param.sched_priority = new_thread->attr.prio; - if (_thr_setscheduler(TID(new_thread), - new_thread->attr.sched_policy, &sched_param)) { - ret = errno; - /* kill the new thread */ - new_thread->force_exit = 1; - THR_THREAD_UNLOCK(curthread, new_thread); - goto out; - } - } - _thr_report_creation(curthread, new_thread); THR_THREAD_UNLOCK(curthread, new_thread); out: |