lkml.org 
[lkml]   [2000]   [Jan]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: (*(unsigned long *)&jiffies)++;
    Date
    On Thu, 06 Jan 2000, Richard B. Johnson wrote:
    > 1 movl foo,%eax ! Get it
    > 2 leal 1(%eax),%edx ! bump it by one
    > 3 movl %edx,foo ! write it back
    > 4 movl foo,%eax ! Then do something dumb
    > 5 movl foo,%edx ! Then do something dumb again
    > 6 pushl %edx
    > 7 pushl $.LC0
    > 8 call printf
    > 9 addl $8,%esp

    This is the correct behaviour the code must follow.
    Even if it has just stored the value in foo ( 3 ) and even it can think that
    the value is %edx is the last one, the volatile keyword force a reload in 5.
    The step 4 is not clear for me !
    IMVHO doing a jiffies++ or (*(unsigned long *)&jiffies)++ is exactly the same
    thing in this case.
    I mean that :

    incl jiffies

    or

    movl jiffies, %eax
    incl %eax
    movl %eax, jiffies

    does not introduce worse issues in SMP.
    Sure the volatile keyword avoid the compiler to optimize :

    movl jiffies, %eax
    incl %eax

    ...

    movl %eax, jiffies

    As a general rule I suggest to introduce any tricks that can solve speed or
    code optimization issues where there's the need, avoiding them in caseless
    situations.


    Cheers,
    Davide.

    --
    "Debian, the freedom in freedom."


    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:55    [W:2.289 / U:0.128 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site