Linus: memory_barriers discuss
The "barrier()" macro is there entirely to defeat the compiler reordering
that is sometimes deadly.
For example, the compiler doesn't know _squat_ about locking, and that's
just as well, since compiler-generated locking tends to suck dead donkeys
through a straw (ie monitors etc that some languages have, and that are
tied to the data structures and tend to be overly careful since the
compiler doesn't actually understand what's going on).
But not knowing about locking means that if you have code like this:
local_cpu_lock = 1;
.. do something critical ..
local_cpu_lock = 0;
and you use the "local_cpu_lock" to tell interrupts to not do certain
things, the compiler will be totally clueless.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.