From owner-freebsd-hackers@FreeBSD.ORG Mon Oct 5 17:55:26 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5679C106566B for ; Mon, 5 Oct 2009 17:55:26 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outA.internet-mail-service.net (outa.internet-mail-service.net [216.240.47.224]) by mx1.freebsd.org (Postfix) with ESMTP id 4054C8FC0C for ; Mon, 5 Oct 2009 17:55:25 +0000 (UTC) Received: from idiom.com (mx0.idiom.com [216.240.32.160]) by out.internet-mail-service.net (Postfix) with ESMTP id 1BE0122E7; Mon, 5 Oct 2009 10:55:30 -0700 (PDT) X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e Received: from julian-mac.elischer.org (home.elischer.org [216.240.48.38]) by idiom.com (Postfix) with ESMTP id 06B352D6014; Mon, 5 Oct 2009 10:55:24 -0700 (PDT) Message-ID: <4ACA330F.7060207@elischer.org> Date: Mon, 05 Oct 2009 10:55:27 -0700 From: Julian Elischer User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: Tom Judge References: <4ACA2645.30801@tomjudge.com> In-Reply-To: <4ACA2645.30801@tomjudge.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: Kernel Thread Lock Question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Oct 2009 17:55:26 -0000 Tom Judge wrote: > Do I need to hold the per thread lock here? (This is for 7.1) > > PROC_LOCK(p); > //mtx_lock_spin(&sched_lock); > breakout = 0; > FOREACH_THREAD_IN_PROC(p, td) { > thread_lock(td); > if (!TD_ON_RUNQ(td) && > !TD_IS_RUNNING(td) && > !TD_IS_SLEEPING(td)) { > breakout = 1; > thread_unlock(td); > break; > } > thread_unlock(td); > } > //mtx_unlock_spin(&sched_lock); > PROC_UNLOCK(p); > "probably not" because the value in the status word can change just after you release it anyhow so your result does not have to be consistent with anything, just with itself. > > Thanks > > Tom > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"