Date: Sat, 20 Nov 2004 04:53:21 GMT From: David Xu <davidxu@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 65518 for review Message-ID: <200411200453.iAK4rL8E013179@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=65518 Change 65518 by davidxu@davidxu_alona on 2004/11/20 04:52:19 Use thread lock. there should be thr_suspend_thread, thr_resume_thread to suspend or resume thread directly on kernel, will introduce it later. Affected files ... .. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_resume_np.c#2 edit Differences ... ==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_resume_np.c#2 (text+ko) ==== @@ -35,7 +35,7 @@ #include <pthread.h> #include "thr_private.h" -static struct kse_mailbox *resume_common(struct pthread *); +static long resume_common(struct pthread *); __weak_reference(_pthread_resume_np, pthread_resume_np); __weak_reference(_pthread_resume_all_np, pthread_resume_all_np); @@ -46,18 +46,18 @@ _pthread_resume_np(pthread_t thread) { struct pthread *curthread = _get_curthread(); - struct kse_mailbox *kmbx; + long tid = -1; int ret; /* Add a reference to the thread: */ if ((ret = _thr_ref_add(curthread, thread, /*include dead*/0)) == 0) { /* Lock the threads scheduling queue: */ - THR_SCHED_LOCK(curthread, thread); - kmbx = resume_common(thread); - THR_SCHED_UNLOCK(curthread, thread); + THR_THREAD_LOCK(curthread, thread); + tid = resume_common(thread); + THR_THREAD_UNLOCK(curthread, thread); _thr_ref_delete(curthread, thread); - if (kmbx != NULL) - kse_wakeup(kmbx); + if (tid !=-1) + thr_wake(tid); } return (ret); } @@ -67,29 +67,26 @@ { struct pthread *curthread = _get_curthread(); struct pthread *thread; - struct kse_mailbox *kmbx; - kse_critical_t crit; + long tid; /* Take the thread list lock: */ - crit = _kse_critical_enter(); - KSE_LOCK_ACQUIRE(curthread->kse, &_thread_list_lock); + THR_LOCK_ACQUIRE(curthread, &_thread_list_lock); TAILQ_FOREACH(thread, &_thread_list, tle) { if (thread != curthread) { - THR_SCHED_LOCK(curthread, thread); - kmbx = resume_common(thread); - THR_SCHED_UNLOCK(curthread, thread); - if (kmbx != NULL) - kse_wakeup(kmbx); + THR_THREAD_LOCK(curthread, thread); + tid = resume_common(thread); + THR_THREAD_UNLOCK(curthread, thread); + if (tid != -1) + thr_wake(tid); } } /* Release the thread list lock: */ - KSE_LOCK_RELEASE(curthread->kse, &_thread_list_lock); - _kse_critical_leave(crit); + THR_LOCK_RELEASE(curthread, &_thread_list_lock); } -static struct kse_mailbox * +static long resume_common(struct pthread *thread) { /* Clear the suspend flag: */ @@ -103,5 +100,5 @@ if (thread->state == PS_SUSPENDED) return (_thr_setrunnable_unlocked(thread)); else - return (NULL); + return (-1); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200411200453.iAK4rL8E013179>