Date: Fri, 15 Dec 2000 14:50:51 -0800 From: Julian Elischer <julian@elischer.org> To: John Baldwin <jhb@FreeBSD.org> Cc: Alfred Perlstein <bright@wintelcom.net>, smp@FreeBSD.org Subject: Re: atomic increment? Message-ID: <3A3AA04B.68EEB813@elischer.org> References: <XFMail.001215110205.jhb@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
John Baldwin wrote: > > On 15-Dec-00 Alfred Perlstein wrote: > > * John Baldwin <jhb@FreeBSD.ORG> [001215 10:51] 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 > > > > I think he's looking for a useable and intuative interface. > > > > no offence I hope. :) > > I didn't come up with it. :) atomic_add_int(&my_int_var, 1) doesn't appear too > weird to me. Of course, the movl being complained about is actually rather > rediculous. It's in the instruction cache, so the '1' is a cache hit, and this > instruction is probably all of 1 clock. Compared to the overhead of the bus > lock, that is completely lost in the noise. Also, staring at the microcosm of > the asm on one machine is not necessarily going to apply to other machines at > all. the mov uses up a register which in one example I was using here, forced a much needed number to be written to memory and later restored. That caused 1/ Extra delay as some percentage of the read-ahead cache was used by the move. I'm sure it was not a lot but it probably pused something else back a bit maing it slightly less likely to be in by the time it was needed. 2/ Cluttering of the registers.. which forced: 3/ extra bus cycles as the processor wrote values to memory (for no real reason) > > -- > > 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/ > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-smp" in the body of the message -- __--_|\ 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?3A3AA04B.68EEB813>