user-space locks

Robert Watson rwatson at FreeBSD.org
Sat Mar 10 03:51:04 UTC 2007


On Sat, 10 Mar 2007, Vlad GALU wrote:

> On 3/10/07, Kip Macy <kip.macy at gmail.com> 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


More information about the freebsd-hackers mailing list