lkml.org 
[lkml]   [2008]   [Jul]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: semaphore: lockless fastpath using atomic_{inc,dec}_return
On Wed, 09 Jul 2008 16:39:43 +0100
Bruno Santos <bsantos@av.it.pt> wrote:

> Hi,
>
> >hi,
> >
> >not to ruin the party but... how is this lockless? An atomic
> >variable is every bit a "lock" as a spinlock is... and very much
> >equally expensive as well for most cases ;-(
>
> Perhaps not the best the choice of words, I should have omitted the
> word lockless. But it seems my understanding of lockless and yours is
> different. And indeed, it's very expensive as a spinlock, but
> comparatively, is only one operation, that if successful doesn't have
> to lock and then unlock (that's why I called it lockless ...).

ok I only come from an Intel/x86 background, where unlock is basically
free, and the "lock" is exactly the same cost as an atomic op.
(in fact, an atomic op and a lock are the exact same code.. you're just
open coding it)

> The mutex takes the same approach, however it uses it's own flavour
> of atomic ops. What I'm really interested is if this brings any
> benefit in terms of performance.

on x86... I would highly doubt it since you have the same number of
atomic operations. (it's not the lock that is expensive. ever. it's
always the fact that a lock implies an atomic operation that makes it
expensive)


\
 
 \ /
  Last update: 2008-07-09 17:53    [W:0.080 / U:0.512 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site