From owner-p4-projects@FreeBSD.ORG Sat Nov 20 04:46:12 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 35A8D16A4D0; Sat, 20 Nov 2004 04:46:12 +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 120CB16A4CE for ; Sat, 20 Nov 2004 04:46:12 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id DB3A143D4C for ; Sat, 20 Nov 2004 04:46:11 +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 iAK4kBo0006566 for ; Sat, 20 Nov 2004 04:46:11 GMT (envelope-from davidxu@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id iAK4kBbZ006563 for perforce@freebsd.org; Sat, 20 Nov 2004 04:46:11 GMT (envelope-from davidxu@freebsd.org) Date: Sat, 20 Nov 2004 04:46:11 GMT Message-Id: <200411200446.iAK4kBbZ006563@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 65516 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:46:12 -0000 http://perforce.freebsd.org/chv.cgi?CH=65516 Change 65516 by davidxu@davidxu_alona on 2004/11/20 04:46:00 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_suspend_np.c#2 edit Differences ... ==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_suspend_np.c#2 (text+ko) ==== @@ -55,10 +55,10 @@ else if ((ret = _thr_ref_add(curthread, thread, /*include dead*/0)) == 0) { /* Lock the threads scheduling queue: */ - THR_SCHED_LOCK(curthread, thread); + THR_THREAD_LOCK(curthread, thread); suspend_common(thread); /* Unlock the threads scheduling queue: */ - THR_SCHED_UNLOCK(curthread, thread); + THR_THREAD_UNLOCK(curthread, thread); /* Don't forget to remove the reference: */ _thr_ref_delete(curthread, thread); @@ -71,23 +71,20 @@ { struct pthread *curthread = _get_curthread(); struct pthread *thread; - kse_critical_t crit; /* 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); + THR_THREAD_LOCK(curthread, thread); suspend_common(thread); - THR_SCHED_UNLOCK(curthread, thread); + THR_THREAD_UNLOCK(curthread, thread); } } /* Release the thread list lock: */ - KSE_LOCK_RELEASE(curthread->kse, &_thread_list_lock); - _kse_critical_leave(crit); + THR_LOCK_RELEASE(curthread, &_thread_list_lock); } void @@ -97,13 +94,6 @@ (thread->state != PS_DEADLOCK) && ((thread->flags & THR_FLAGS_EXITING) == 0)) { thread->flags |= THR_FLAGS_SUSPENDED; - if ((thread->flags & THR_FLAGS_IN_RUNQ) != 0) { - THR_RUNQ_REMOVE(thread); - THR_SET_STATE(thread, PS_SUSPENDED); - } -#ifdef NOT_YET - if ((thread->attr.flags & PTHREAD_SCOPE_SYSTEM) != 0) - /* ??? */ -#endif + /* XXX how ? */ } }