lkml.org 
[lkml]   [1999]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: set_current_state
    Andrea Arcangeli wrote:
    > >Looking at the sched.h header file, it's pretty clear that this is there
    > >to protect against race conditions on SMP kernels. Which makes me
    >
    > Exactly, I noticed the SMP race some week ago (see the thread SMP races
    > all over the place). You can find all the details on linux-kernel.

    I've been wondering why this is safe on UP.

    What's to stop the compiler reordering the write to current->state
    after the test for the condition?

    Sure, state is declared volatile, but the condition usually isn't and
    AFAIK the ordering of volatile operations is only defined with respect
    to each other.

    Scenario:

    current->state = TASK_INTERRUPTIBLE;
    if (condition)

    Rewritten by compiler as:

    tmp = condition;
    /* Interrupt occurs here. */
    current->state = TASK_INTERRUPTIBLE;
    if (tmp)

    Just a thought. Obviously it never happens so I must be missing
    something :-)

    -- Jamie

    -
    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:53    [W:0.022 / U:29.696 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site