lkml.org 
[lkml]   [1999]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: set_current_state
Date
From
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/



-
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/



-
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:2.065 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site