From owner-p4-projects@FreeBSD.ORG Sat Nov 20 04:53:22 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DDCA816A4D0; Sat, 20 Nov 2004 04:53:21 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A262A16A4CE for ; Sat, 20 Nov 2004 04:53:21 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 76EFF43D3F for ; Sat, 20 Nov 2004 04:53:21 +0000 (GMT) (envelope-from davidxu@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id iAK4rLFO013182 for ; Sat, 20 Nov 2004 04:53:21 GMT (envelope-from davidxu@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id iAK4rL8E013179 for perforce@freebsd.org; Sat, 20 Nov 2004 04:53:21 GMT (envelope-from davidxu@freebsd.org) Date: Sat, 20 Nov 2004 04:53:21 GMT Message-Id: <200411200453.iAK4rL8E013179@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to davidxu@freebsd.org using -f From: David Xu To: Perforce Change Reviews Subject: PERFORCE change 65518 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Nov 2004 04:53:22 -0000 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 #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); }