machine/atmoic.h
Lev Walkin
vlm at netli.com
Sat Feb 14 03:28:00 PST 2004
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 at netli.com
More information about the freebsd-hackers
mailing list