From owner-p4-projects@FreeBSD.ORG Fri Dec 31 15:06:22 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id F054816A4D0; Fri, 31 Dec 2004 15:06: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 CAEB516A4CE for ; Fri, 31 Dec 2004 15:06:21 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9C54D43D3F for ; Fri, 31 Dec 2004 15:06:21 +0000 (GMT) (envelope-from davidxu@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id iBVF6LO0009648 for ; Fri, 31 Dec 2004 15:06:21 GMT (envelope-from davidxu@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id iBVF6L0q009645 for perforce@freebsd.org; Fri, 31 Dec 2004 15:06:21 GMT (envelope-from davidxu@freebsd.org) Date: Fri, 31 Dec 2004 15:06:21 GMT Message-Id: <200412311506.iBVF6L0q009645@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 67986 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: Fri, 31 Dec 2004 15:06:23 -0000 http://perforce.freebsd.org/chv.cgi?CH=67986 Change 67986 by davidxu@davidxu_tiger on 2004/12/31 15:05:22 now suspending a thread works, required by java. Affected files ... .. //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_resume_np.c#3 edit Differences ... ==== //depot/projects/davidxu_thread/src/lib/libthread/thread/thr_resume_np.c#3 (text+ko) ==== @@ -35,29 +35,25 @@ #include #include "thr_private.h" -static long resume_common(struct pthread *); - __weak_reference(_pthread_resume_np, pthread_resume_np); __weak_reference(_pthread_resume_all_np, pthread_resume_all_np); +static void inline resume_common(struct pthread *thread); /* Resume a thread: */ int _pthread_resume_np(pthread_t thread) { struct pthread *curthread = _get_curthread(); - 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_THREAD_LOCK(curthread, thread); - tid = resume_common(thread); + resume_common(thread); THR_THREAD_UNLOCK(curthread, thread); _thr_ref_delete(curthread, thread); - if (tid !=-1) - thr_wake(tid); } return (ret); } @@ -67,38 +63,28 @@ { struct pthread *curthread = _get_curthread(); struct pthread *thread; - long tid; /* Take the thread list lock: */ - THR_LOCK_ACQUIRE(curthread, &_thread_list_lock); + THREAD_LIST_LOCK(curthread); TAILQ_FOREACH(thread, &_thread_list, tle) { if (thread != curthread) { THR_THREAD_LOCK(curthread, thread); - tid = resume_common(thread); + resume_common(thread); THR_THREAD_UNLOCK(curthread, thread); - if (tid != -1) - thr_wake(tid); } } /* Release the thread list lock: */ - THR_LOCK_RELEASE(curthread, &_thread_list_lock); + THREAD_LIST_UNLOCK(curthread); } -static long +static void inline resume_common(struct pthread *thread) { /* Clear the suspend flag: */ - thread->flags &= ~THR_FLAGS_SUSPENDED; - - /* - * If the thread's state is suspended, that means it is - * now runnable but not in any scheduling queue. Set the - * state to running and insert it into the run queue. - */ - if (thread->state == PS_SUSPENDED) - return (_thr_setrunnable_unlocked(thread)); - else - return (-1); + thread->flags &= ~THR_FLAGS_NEED_SUSPEND; + thread->cycle++; + umtx_wake((struct umtx *)&thread->cycle, 1); + thr_kill(thread->tid, SIGCANCEL); }