From owner-freebsd-threads@FreeBSD.ORG Tue Dec 20 14:52:51 2011 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4E4F01065678; Tue, 20 Dec 2011 14:52:51 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 25B6B8FC17; Tue, 20 Dec 2011 14:52:51 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) by cyrus.watson.org (Postfix) with ESMTPSA id CBE2A46B32; Tue, 20 Dec 2011 09:52:50 -0500 (EST) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 5D0E6B955; Tue, 20 Dec 2011 09:52:50 -0500 (EST) From: John Baldwin To: "Poul-Henning Kamp" Date: Tue, 20 Dec 2011 09:43:18 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p8; KDE/4.5.5; amd64; ; ) References: <73233.1324389741@critter.freebsd.dk> In-Reply-To: <73233.1324389741@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201112200943.18812.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 20 Dec 2011 09:52:50 -0500 (EST) Cc: freebsd-threads@freebsd.org, freebsd-arch@freebsd.org Subject: Re: [Patch] C1X threading support X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Dec 2011 14:52:51 -0000 On Tuesday, December 20, 2011 9:02:21 am Poul-Henning Kamp wrote: > In message <201112200822.26369.jhb@freebsd.org>, John Baldwin writes: > > >The reason I can think of why you might not specify > >this is if you want to support machines that have very limited support for > >atomic operations (e.g. only an exchange instruction or a single-bit test-and- > >set as opposed to a full-world test-and-set such as cmpxchg on x86 or cas on > >sparc). > > There is no way this can be impossible on a platform which can > implement a mutex in the first place: > > > mtx_lock(l) > { > atomic_magic_lock(l->lock_field) > l->id = thread_id; > } > > mtx_unlock(l) > { > assert(l->id == thread_id); > l->id = NULL; > atomic_magic_unlock(l->lock_field) > } > > mtx_assert_held(l) > { > assert(l->lock-field != 0); > assert(l->id == thread_id); > } Yep, having a helper field to track the owner would work fine on such degenerate platforms. -- John Baldwin