Date: Tue, 20 Dec 2011 09:43:18 -0500 From: John Baldwin <jhb@freebsd.org> To: "Poul-Henning Kamp" <phk@phk.freebsd.dk> Cc: freebsd-threads@freebsd.org, freebsd-arch@freebsd.org Subject: Re: [Patch] C1X threading support Message-ID: <201112200943.18812.jhb@freebsd.org> In-Reply-To: <73233.1324389741@critter.freebsd.dk> References: <73233.1324389741@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112200943.18812.jhb>