From owner-cvs-all@FreeBSD.ORG Wed Oct 15 16:30:28 2003 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 56C9416A4B3; Wed, 15 Oct 2003 16:30:28 -0700 (PDT) Received: from mail.chesapeake.net (chesapeake.net [208.142.252.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6C47143FBF; Wed, 15 Oct 2003 16:30:26 -0700 (PDT) (envelope-from jroberson@chesapeake.net) Received: from localhost (jroberson@localhost) by mail.chesapeake.net (8.11.6/8.11.6) with ESMTP id h9FNUQs62983; Wed, 15 Oct 2003 19:30:26 -0400 (EDT) (envelope-from jroberson@chesapeake.net) Date: Wed, 15 Oct 2003 19:30:26 -0400 (EDT) From: Jeff Roberson To: Robert Watson In-Reply-To: Message-ID: <20031015192947.E30029-100000@mail.chesapeake.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: cvs-src@FreeBSD.org cc: Jeff Roberson cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org cc: John Baldwin Subject: RE: cvs commit: src/sys/sys mutex.h X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Oct 2003 23:30:28 -0000 On Wed, 15 Oct 2003, Robert Watson wrote: > > On Tue, 14 Oct 2003, John Baldwin wrote: > > > > I know it is racy in most contexts. I use it to check to see if a thread > > > on the runq owns giant. Since I have the sched lock it isn't racy but > > > even if it was it wouldn't matter in this case. > > > > sched lock doesn't keep it from being racy. Uncontested acquire and > > releases don't go anywhere near sched lock. Are you checking a > > non-curthread thread pointer? Maybe you could just do it for curthread > > and that would be enough for your heuristic, i.e. > > > > if (thread == curthread && mtx_owned(&Giant)) { > > ... > > } > > > > I'm just worried that if this is there someone is going to use it. :( > > You mean like this? Commit! I know of a great use for this. > > while (mtx_trylock(&my_favorite_mtx)) { > int gotthebastard; > struct thread *td; > struct proc *p; > > gotthebastard = 0; > sx_slock(&allproc_lock); > LIST_FOREACH(p, &allproc, p_list) { > PROC_LOCK(p); > FOREACH_THREAD_IN_PROC(p, td) { > if (mtx_ownedby(&my_favorite_mtx, td)) { > psignal(p, SIGKILL); > gotthebastard = 1; > break; > } > } > PROC_UNLOCK(p); > if (gotthebastard) > break; > } > sx_sunlock(&allproc_lock); > printf("Someone else owned the mutex, but I got the bastard\n"); > } > > Robert N M Watson FreeBSD Core Team, TrustedBSD Projects > robert@fledge.watson.org Network Associates Laboratories >