From owner-freebsd-current@FreeBSD.ORG Thu Apr 2 07:00:58 2009 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 04DBD106566B for ; Thu, 2 Apr 2009 07:00:58 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.9.129]) by mx1.freebsd.org (Postfix) with ESMTP id C04F48FC14 for ; Thu, 2 Apr 2009 07:00:57 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id EC25873098; Thu, 2 Apr 2009 09:06:05 +0200 (CEST) Date: Thu, 2 Apr 2009 09:06:05 +0200 From: Luigi Rizzo To: current@freebsd.org Message-ID: <20090402070605.GA96848@onelab2.iet.unipi.it> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Cc: Subject: cmpxchg / atomic_cmpset_int emulation for userland (i386) ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Apr 2009 07:00:58 -0000 Hi, I have some list manipulation algorithm that I would like to use that relies rather centrally on atomic_cmpset_int(). 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. 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). cheers luigi