Date: Thu, 2 Apr 2009 12:47:27 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: Luigi Rizzo <rizzo@iet.unipi.it> Cc: current@freebsd.org Subject: Re: cmpxchg / atomic_cmpset_int emulation for userland (i386) ? Message-ID: <20090402094727.GC31897@deviant.kiev.zoral.com.ua> In-Reply-To: <20090402085854.GA2237@onelab2.iet.unipi.it> References: <20090402070605.GA96848@onelab2.iet.unipi.it> <20090402084833.GZ31897@deviant.kiev.zoral.com.ua> <20090402085854.GA2237@onelab2.iet.unipi.it>
next in thread | previous in thread | raw e-mail | index | archive | help
--j9j9RojA/SLAeXkU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 02, 2009 at 10:58:54AM +0200, Luigi Rizzo wrote: > On Thu, Apr 02, 2009 at 11:48:33AM +0300, Kostik Belousov wrote: > > On Thu, Apr 02, 2009 at 09:06:05AM +0200, Luigi Rizzo wrote: > > > Hi, > > > I have some list manipulation algorithm that I would like to use > > > that relies rather centrally on atomic_cmpset_int(). > > >=20 > > > This is an atomic instruction on 486+, but not available on 386 > > > and maybe other platforms. i386/atomic.h has a replacement > > > but it uses "pushfl; cli; ... popfl;" so it cannot run in userland. > > >=20 > > > I was wondering if there is a good emulation for that instruction > > > on the i386 that is suitable for userland (other architectures > > > we support have a CPU instruction that does it, or in the case of ARM, > > > a usable emulation for userland). > >=20 > > FreeBSD cannot boot on anything < 486, i.e. cmpxchgl and xaddl may be > > considered always supported by the CPU. >=20 > It was a slightly more generic question -- this stuff is for userland > so while we can assume it works on modern FreeBSD versions, I would > like to see what constraints it has on older versions of FreeBSD. > Of course I can emulate the critical section with a pthread lock, > but that would be the worst case option. Support for FPU-less operations was removed from HEAD in Jul 2003. The support for i386+387 seems to be removed in 2004, i.e. before 5.x. The kernel explicitely requires working read-only mappings of the pages for kernel mode, AKA WP bit in CR0. Also, kernel assumes that cmpxchgl is always present. Do you want to support 4.x ? --j9j9RojA/SLAeXkU Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAknUia4ACgkQC3+MBN1Mb4jb2wCgrRut4dpvGPNjneo1ztK1Y8lL p8gAn1wPPu5RY9r1jVP201S7j4CcJ3BL =E0sP -----END PGP SIGNATURE----- --j9j9RojA/SLAeXkU--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090402094727.GC31897>