From owner-freebsd-arch Thu Jan 3 1:49:54 2002 Delivered-To: freebsd-arch@freebsd.org Received: from srv1.cosmo-project.de (srv1.cosmo-project.de [213.83.6.106]) by hub.freebsd.org (Postfix) with ESMTP id 8097037B405; Thu, 3 Jan 2002 01:49:50 -0800 (PST) Received: (from uucp@localhost) by srv1.cosmo-project.de (8.11.6/8.11.6) with UUCP id g039nJm19351; Thu, 3 Jan 2002 10:49:19 +0100 (CET) (envelope-from ticso@cicely9.cicely.de) Received: from mail.cicely.de (cicely20.cicely.de [10.1.1.22]) by cicely5.cicely.de (8.12.1/8.12.1) with ESMTP id g039gjtx049101; Thu, 3 Jan 2002 10:42:45 +0100 (CET)?g (envelope-from ticso@cicely9.cicely.de) Received: from cicely9.cicely.de (cicely9.cicely.de [10.1.7.11]) by mail.cicely.de (8.11.0/8.11.0) with ESMTP id g039gjW13904; Thu, 3 Jan 2002 10:42:45 +0100 (CET) Received: (from ticso@localhost) by cicely9.cicely.de (8.11.6/8.11.6) id g039gd763659; Thu, 3 Jan 2002 10:42:39 +0100 (CET) (envelope-from ticso) Date: Thu, 3 Jan 2002 10:42:39 +0100 From: Bernd Walter To: Terry Lambert Cc: Matthew Dillon , Alfred Perlstein , John Baldwin , arch@FreeBSD.ORG, Bernd Walter , Mike Smith , Bruce Evans , Michal Mertl , Peter Jeremy Subject: Re: When to use atomic_ functions? (was: 64 bit counters) Message-ID: <20020103094239.GH53199@cicely9.cicely.de> References: <200201030002.g0302Eo60575@apollo.backplane.com> <20020102180734.A82406@elvis.mu.org> <200201030012.g030Cgp60752@apollo.backplane.com> <3C33D3E3.38E758CA@mindspring.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3C33D3E3.38E758CA@mindspring.com> User-Agent: Mutt/1.3.24i X-Operating-System: FreeBSD cicely9.cicely.de 5.0-CURRENT alpha Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, Jan 02, 2002 at 07:45:39PM -0800, Terry Lambert wrote: > Matthew Dillon wrote: > > If we standardize the mutex used by interface device-driver interrupts > > (if it isn't already done), the collector could obtain the mutex when > > reading the counter, yes? > > IMO, statistics are snapshots in any case, so it doesn't > really matter if they are incredibly accurate on read. > > In any case, multiple reader, single write doesn't need locks > unless it has to be done atomically. Single write means always with the same CPU or thread. If you always write with the same CPU the other might keep an old value in his cache for an unknown long time. You simply trust that caches gets syncronised automaticaly by regular events like context switching. I'm not shure this is valid. > An easy way to do this atomically, even for fairly large items, > is to toggle between an active and inactive structure of data, > where the pointer to the strucutre is assigned atomically. Only you use rel/acq behavour - atomic alone isn't strong enough. > I used this property for my zero system call gettimeofday(), > for example. -- B.Walter COSMO-Project http://www.cosmo-project.de ticso@cicely.de Usergroup info@cosmo-project.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message