From owner-freebsd-smp Fri Dec 15 14:51:38 2000 From owner-freebsd-smp@FreeBSD.ORG Fri Dec 15 14:51:34 2000 Return-Path: Delivered-To: freebsd-smp@freebsd.org Received: from mail.interware.hu (mail.interware.hu [195.70.32.130]) by hub.freebsd.org (Postfix) with ESMTP id 9577237B699; Fri, 15 Dec 2000 14:51:33 -0800 (PST) Received: from luanda-49.budapest.interware.hu ([195.70.51.49] helo=elischer.org) by mail.interware.hu with esmtp (Exim 3.16 #1 (Debian)) id 1473hL-00064E-00; Fri, 15 Dec 2000 23:51:32 +0100 Sender: julian@FreeBSD.ORG Message-ID: <3A3AA04B.68EEB813@elischer.org> Date: Fri, 15 Dec 2000 14:50:51 -0800 From: Julian Elischer X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 5.0-CURRENT i386) X-Accept-Language: en, hu MIME-Version: 1.0 To: John Baldwin Cc: Alfred Perlstein , smp@FreeBSD.org Subject: Re: atomic increment? References: Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org John Baldwin wrote: > > On 15-Dec-00 Alfred Perlstein wrote: > > * John Baldwin [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 -- 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