diff options
author | davidxu <davidxu@FreeBSD.org> | 2010-09-13 07:03:01 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2010-09-13 07:03:01 +0000 |
commit | e87e922f3125332f002638f5f231acc7544b7ebf (patch) | |
tree | 82f35174d92e7167b6c95a574f45720b60ded582 /lib/libthr/thread/thr_affinity.c | |
parent | 8ff2afea3997418eb503ad0843ed126e994fe54b (diff) | |
download | FreeBSD-src-e87e922f3125332f002638f5f231acc7544b7ebf.zip FreeBSD-src-e87e922f3125332f002638f5f231acc7544b7ebf.tar.gz |
Convert thread list lock from mutex to rwlock.
Diffstat (limited to 'lib/libthr/thread/thr_affinity.c')
-rw-r--r-- | lib/libthr/thread/thr_affinity.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/libthr/thread/thr_affinity.c b/lib/libthr/thread/thr_affinity.c index 7a12a89..ae43fcb 100644 --- a/lib/libthr/thread/thr_affinity.c +++ b/lib/libthr/thread/thr_affinity.c @@ -50,8 +50,7 @@ _pthread_setaffinity_np(pthread_t td, size_t cpusetsize, const cpuset_t *cpusetp -1, cpusetsize, cpusetp); if (error == -1) error = errno; - } else { - THR_THREAD_LOCK(curthread, td); + } else if ((error = _thr_find_thread(curthread, td, 0)) == 0) { if (td->state == PS_DEAD) { THR_THREAD_UNLOCK(curthread, td); return (EINVAL); @@ -73,10 +72,18 @@ _pthread_getaffinity_np(pthread_t td, size_t cpusetsize, cpuset_t *cpusetp) lwpid_t tid; int error; - tid = TID(td); - error = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, - (td == curthread) ? -1 : tid, cpusetsize, cpusetp); - if (error == -1) - error = errno; + if (td == curthread) { + error = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, + (td == curthread) ? -1 : tid, cpusetsize, cpusetp); + if (error == -1) + error = errno; + } else if ((error = _thr_find_thread(curthread, td, 0)) == 0) { + tid = TID(td); + error = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, + (td == curthread) ? -1 : tid, cpusetsize, cpusetp); + if (error == -1) + error = errno; + THR_THREAD_UNLOCK(curthread, td); + } return (error); } |