lkml.org 
[lkml]   [2006]   [Jul]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [patch] spinlocks: remove 'volatile'
    On Thu, 6 Jul 2006 11:00:43 -0700 (PDT), Linus Torvalds <torvalds@osdl.org> wrote:

    >
    >
    > On Thu, 6 Jul 2006, linux-os (Dick Johnson) wrote:
    > >
    > > Linus, you may have been reading too many novels.
    > >
    > > If I have some code that does:
    > >
    > > extern int spinner;
    > >
    > > funct(){
    > > while(spinner)
    > > ;
    > >
    > > The 'C' compiler has no choice but to actually make that memory access
    > > and read the variable because the variable is in another module (a.k.a.
    > > file).
    >
    > You don't know how C works, do you?
    >
    > You also have no idea of what out-of-order memory accesses do to OS code,
    > right?
    >

    I think you are mixing apples and oranges. Using volatile to control o-o-o
    memory accesses is sure wrong.
    It just means "don't assume this variable has not changed because you don't
    see any access to it" to the compiler. It is designed to prevent high level
    optimizations like code movement or dead code elimination, but a _high_ level.
    It has nothing to do with memory barriers and so on. That is surely a
    misuse of volatile.

    --
    J.A. Magallon <jamagallon()ono!com> \ Software is like sex:
    \ It's better when it's free
    Mandriva Linux release 2007.0 (Cooker) for i586
    Linux 2.6.17-jam01 (gcc 4.1.1 20060518 (prerelease)) #2 SMP PREEMPT Wed
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2006-07-06 23:07    [W:4.290 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site