From owner-freebsd-hackers@FreeBSD.ORG Sat Mar 10 03:51:04 2007 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7622616A401 for ; Sat, 10 Mar 2007 03:51:04 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.freebsd.org (Postfix) with ESMTP id 5111813C461 for ; Sat, 10 Mar 2007 03:51:04 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id ED80B46D58; Fri, 9 Mar 2007 22:51:03 -0500 (EST) Date: Sat, 10 Mar 2007 03:51:03 +0000 (GMT) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Vlad GALU In-Reply-To: Message-ID: <20070310034922.R30274@fledge.watson.org> References: <45F1A97D.7090608@cs.rice.edu> <989648.79906.qm@web32913.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: hackers@freebsd.org Subject: Re: user-space locks X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Mar 2007 03:51:04 -0000 On Sat, 10 Mar 2007, Vlad GALU wrote: > On 3/10/07, Kip Macy wrote: >> umtx > > Is it safe/recommended to use spinlocks, like in jemalloc, for very small > portions of code? I'm particularly interested in protecting writes to a > couple of word sized ints on amd64, so the critical section wouldn't be > longer than two assignments. Of course, I could use a lockless queue for my > purposes, but I'm asking anyway. I believe that the system malloc library is forced to use low level locking primitives because the pthread library depends on malloc. I would suggest using the pthread mutex primitives where at all possible. We might want to consider adding "adaptive" mutex support to the pthread libraries if we don't have it. Robert N M Watson Computer Laboratory University of Cambridge