diff options
author | davidxu <davidxu@FreeBSD.org> | 2006-07-13 06:35:43 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2006-07-13 06:35:43 +0000 |
commit | 19b84189035f11be93ba57379660d66d24d77c2b (patch) | |
tree | a578a4c69968927b0ae5c15efa30827ff9d1c6ef /lib/libthr/thread | |
parent | bde285ca74095822da08a85bc8bc403964bd1036 (diff) | |
download | FreeBSD-src-19b84189035f11be93ba57379660d66d24d77c2b.zip FreeBSD-src-19b84189035f11be93ba57379660d66d24d77c2b.tar.gz |
Use thr_setscheduler, thr_getscheduler and thr_setschedparam to implement
pthread functions.
Diffstat (limited to 'lib/libthr/thread')
-rw-r--r-- | lib/libthr/thread/thr_create.c | 5 | ||||
-rw-r--r-- | lib/libthr/thread/thr_getschedparam.c | 26 | ||||
-rw-r--r-- | lib/libthr/thread/thr_setprio.c | 4 | ||||
-rw-r--r-- | lib/libthr/thread/thr_setschedparam.c | 6 |
4 files changed, 15 insertions, 26 deletions
diff --git a/lib/libthr/thread/thr_create.c b/lib/libthr/thread/thr_create.c index e74278d..49e9b45 100644 --- a/lib/libthr/thread/thr_create.c +++ b/lib/libthr/thread/thr_create.c @@ -144,9 +144,10 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr, if (new_thread->attr.flags & PTHREAD_SCOPE_SYSTEM) param.flags |= THR_SYSTEM_SCOPE; if (new_thread->attr.sched_inherit == PTHREAD_INHERIT_SCHED) - param.sched = NULL; + param.sched_param = NULL; else { - param.sched = &sched_param; + param.sched_param = &sched_param; + param.sched_param_size = sizeof(sched_param); sched_param.policy = new_thread->attr.sched_policy; sched_param.param.sched_priority = new_thread->attr.prio; } diff --git a/lib/libthr/thread/thr_getschedparam.c b/lib/libthr/thread/thr_getschedparam.c index acd0235..9d581ed 100644 --- a/lib/libthr/thread/thr_getschedparam.c +++ b/lib/libthr/thread/thr_getschedparam.c @@ -57,34 +57,20 @@ _pthread_getschedparam(pthread_t pthread, int *policy, * thread. */ THR_LOCK(curthread); - - /* - * XXX Here we need two separated syscalls, atomic is only - * guaranteed in thread library, a new syscall is needed. - */ - - *policy = sched_getscheduler((pid_t)curthread->tid); - if (*policy == -1) + ret = thr_getscheduler((pid_t)curthread->tid, policy, param, + sizeof(param)); + if (ret == -1) ret = errno; - else { - ret = sched_getparam((pid_t)curthread->tid, param); - if (ret == -1) - ret = errno; - } THR_UNLOCK(curthread); } /* 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 = sched_getscheduler((pid_t)pthread->tid); - if (*policy == -1) + ret = thr_getscheduler(pthread->tid, policy, param, + sizeof(param)); + if (ret == -1) ret = errno; - else { - ret = sched_getparam((pid_t)pthread->tid, param); - if (ret == -1) - ret = errno; - } THR_THREAD_UNLOCK(curthread, pthread); _thr_ref_delete(curthread, pthread); } diff --git a/lib/libthr/thread/thr_setprio.c b/lib/libthr/thread/thr_setprio.c index 51a283e..03ac39c 100644 --- a/lib/libthr/thread/thr_setprio.c +++ b/lib/libthr/thread/thr_setprio.c @@ -50,7 +50,7 @@ _pthread_setprio(pthread_t pthread, int prio) param.sched_priority = prio; if (pthread == curthread) { THR_LOCK(curthread); - ret = sched_setparam((pid_t)curthread->tid, ¶m); + ret = thr_setschedparam(curthread->tid, ¶m, sizeof(param)); if (ret == -1) ret = errno; else @@ -59,7 +59,7 @@ _pthread_setprio(pthread_t pthread, int prio) } else if ((ret = _thr_ref_add(curthread, pthread, /*include dead*/0)) == 0) { THR_THREAD_LOCK(curthread, pthread); - ret = sched_setparam((pid_t)pthread->tid, ¶m); + ret = thr_setschedparam(pthread->tid, ¶m, sizeof(param)); if (ret == -1) ret = errno; else diff --git a/lib/libthr/thread/thr_setschedparam.c b/lib/libthr/thread/thr_setschedparam.c index e04452f..5e2d2bf 100644 --- a/lib/libthr/thread/thr_setschedparam.c +++ b/lib/libthr/thread/thr_setschedparam.c @@ -55,7 +55,8 @@ _pthread_setschedparam(pthread_t pthread, int policy, if (pthread == curthread) { THR_LOCK(curthread); - ret = sched_setscheduler((pid_t)curthread->tid, policy, param); + ret = thr_setscheduler(curthread->tid, policy, param, + sizeof(param)); if (ret == -1) ret = errno; else { @@ -66,7 +67,8 @@ _pthread_setschedparam(pthread_t pthread, int policy, } else if ((ret = _thr_ref_add(curthread, pthread, /*include dead*/0)) == 0) { THR_THREAD_LOCK(curthread, pthread); - ret = sched_setscheduler((pid_t)pthread->tid, policy, param); + ret = thr_setscheduler(pthread->tid, policy, param, + sizeof(param)); if (ret == -1) ret = errno; else { |