From owner-freebsd-hackers@FreeBSD.ORG Sat Feb 14 03:28:00 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6EC8F16A4CE for ; Sat, 14 Feb 2004 03:28:00 -0800 (PST) Received: from smtp.netli.com (ip2-pal-focal.netli.com [66.243.52.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4515443D1F for ; Sat, 14 Feb 2004 03:28:00 -0800 (PST) (envelope-from vlm@netli.com) Received: (qmail 24215 invoked by uid 84); 14 Feb 2004 11:28:04 -0000 Received: from vlm@netli.com by l3-1 with qmail-scanner-0.96 (uvscan: v4.1.40/v4121. . Clean. Processed in 0.162783 secs); 14 Feb 2004 11:28:04 -0000 Received: from unknown (HELO netli.com) (172.17.1.12) by mx01-pal-lan.netli.lan with SMTP; 14 Feb 2004 11:28:04 -0000 Message-ID: <402E0651.7020306@netli.com> Date: Sat, 14 Feb 2004 03:28:17 -0800 From: Lev Walkin Organization: Netli, Inc. User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.5) Gecko/20031019 X-Accept-Language: ru, en-us, en MIME-Version: 1.0 To: eirikn@kerneled.com References: <20040214092308.GA15818@eirikn.net> In-Reply-To: <20040214092308.GA15818@eirikn.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-hackers@freebsd.org Subject: Re: machine/atmoic.h X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2004 11:28:00 -0000 Eirik Nygaard wrote: > Hi... > > I am just wondering what the atomic_* functions in machine/atmoic.h does. > I have read the assembly code and more or less understood it, but I still > don't see the need for it. So if anyone would enlighten me that would be > great. Think about parallel threads of execution (threads or a kernel with SMP). If the thread gets interrupted in the middle of non-atomic operation (say, an int is incremented via a temporary register), then the result of the operation (the value of that integer) cannot be reliably addressed in the other thread. These functions in machine/atomic.h help you to perform certain functions uninterrupted, possibly via a single assembly instruction, hence the "atomic" prefix. -- Lev Walkin vlm@netli.com