Date: Fri, 15 Dec 2000 08:29:36 -0800 From: Alfred Perlstein <bright@wintelcom.net> To: Chuck Paterson <cp@bsdi.com> Cc: Julian Elischer <julian@elischer.org>, smp@FreeBSD.ORG Subject: Re: atomic increment? Message-ID: <20001215082936.L19572@fw.wintelcom.net> In-Reply-To: <200012151408.eBFE8PF44272@berserker.bsdi.com>; from cp@bsdi.com on Fri, Dec 15, 2000 at 07:08:25AM -0700 References: <3A39F8DA.FD4CA0A5@elischer.org> <200012151408.eBFE8PF44272@berserker.bsdi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> Julian Elischer wrote on: Fri, 15 Dec 2000 02:56:26 PST > }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? Check -arch for the flamefest involved, feel free to bring it up with Jason Evans (jasone) if you don't agree. However Chuck Paterson is correct, make sure that if you're going to make a request for them that the thing you are incrementing isn't already under some mutex lock, or should be covered under a mutex lock and all updates done in batch mode. * Chuck Paterson <cp@bsdi.com> [001215 06:08] wrote: > Julian, > > This is not an argument against, or for, your request. > > I am sure I am starting to sound like a broken record, > but so be it. > > Please remember that atomic ops are really expensive, at > least as expensive as acquiring a mutex. In some cases, of which > X86 is not one, they are more expensive than just acquiring the > mutex. Typically they are cheaper than acquiring and releasing a > mutex, in the case of X86 about half the cost. > > So, if there are more than two atomic operations and they > could have been protected by a single mutex, then the single mutex > really is slightly better alternative. At three operations the > mutex is a much better alternative. > > This is not an argument against, or for, your request. Here's another argument I have for them: On most archs they are both non-blocking and don't disable interrupts. Just another handy feature. -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] "I have the heart of a child; I keep it in a jar on my desk." 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?20001215082936.L19572>