Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Dec 2000 14:44:43 -0800
From:      Julian Elischer <julian@elischer.org>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        smp@FreeBSD.org
Subject:   Re: atomic increment?
Message-ID:  <3A3A9EDB.C8229E40@elischer.org>
References:  <XFMail.001215105012.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
John Baldwin wrote:
> 
> On 15-Dec-00 Julian Elischer wrote:
> > CAn we have an atomic increment and decrement primative?
> >
> > presently we get:
> >
> > .L565:
> >         movl $1,%eax
> >#APP
> >         lock
> >         addl %eax,4(%ebx)
> >
> >
> > the movl is totally useless and it would be
> > an absolutly trivial addition..
> > the question is;
> > is there a religious reason we don't already have it?
> 
> man atomic

man atomic doesn't mention increment, just addition,
which is what I used to get the (annoying) code above.

Gcc has to supply the '1' as  astandard argument
and can not optimise it. It we had a 'standard op of 'inc'
then the argument is un-needed which frees up a register
which may make other code more efficient, and it reduces the 
instruction stream chunk used by the code leaving more of the 
readahead for useful information.

it's not  a major thing but since increment and decrement by a set
amount is very common (all the  lock examples you find use them)
it seems a logical thing to actually define in an efficient manner.

> 
> --
> 
> John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/
> PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
> "Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

-- 
      __--_|\  Julian Elischer
     /       \ julian@elischer.org
    (   OZ    ) World tour 2000
---> X_.---._/  presently in:  Budapest
            v


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-smp" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A3A9EDB.C8229E40>