From: Takashi Iwai Subject: Re: Lock free ring buffers and SMP safety Date: Fri, 23 Nov 2007 18:15:38 +0100 Message-ID: References: <47407708.2080902@mattbucknall.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id CC73F246BD for ; Fri, 23 Nov 2007 18:17:17 +0100 (CET) In-Reply-To: <47407708.2080902@mattbucknall.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Matt Bucknall Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Sun, 18 Nov 2007 17:31:52 +0000, Matt Bucknall wrote: > > Hello, > > Yes, this old chestnut. I've spent the best part of today trying to > ascertain whether or not, in practical terms, a single-producer, > single-consumer lock free ring-buffer can be written purely in C/C++ and > be SMP safe on multiple architectures without memory barriers. > Information I've found has been largely conflicting so I've given up > trying to get a conclusive answer. Instead I'll just go with the flow. > > What is the general consensus amongst ALSA application developers when > it comes to implementing this kind of buffer? Is it possible to use > memory barriers through some user space API call that I don't know about? Well, this question will be better answered on LAD, maybe. AFAIK, the lock-free ringbuffer is possible in most architectures with a help of memory barriers or atomic ops. But these arch-specific things are still headaches if you think of portability, of course. Takashi