Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Feb 2004 03:28:17 -0800
From:      Lev Walkin <vlm@netli.com>
To:        eirikn@kerneled.com
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: machine/atmoic.h
Message-ID:  <402E0651.7020306@netli.com>
In-Reply-To: <20040214092308.GA15818@eirikn.net>
References:  <20040214092308.GA15818@eirikn.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?402E0651.7020306>