From e87e922f3125332f002638f5f231acc7544b7ebf Mon Sep 17 00:00:00 2001 From: davidxu Date: Mon, 13 Sep 2010 07:03:01 +0000 Subject: Convert thread list lock from mutex to rwlock. --- lib/libthr/thread/thr_affinity.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'lib/libthr/thread/thr_affinity.c') 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); } -- cgit v1.1