[BUG] Variable stopmachine_state should be volatile
From: Zhang, Yanmin (yanmin.zhang_at_intel.com)
Date: 11/30/05
- Previous message: Andi Kleen: "Re: [RFC][PATCH] Runtime switching of the idle function [take 2]"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 30 Nov 2005 10:04:20 +0800 To: <linux-kernel@vger.kernel.org>
The model to access variable stopmachine_state is that a main thread
writes it and other threads read it. Its declaration has no sign
volatile. In the while loop in function stopmachine, this variable is
read, and compiler might optimize it by reading it once before the loop
and not reading it again in the loop, so the thread might enter dead
loop.
Here is the patch to fix it.
Signed-off-by: Zhang Yanmin <yanmin.zhang@intel.com>
-
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/
- application/octet-stream attachment: stopmachine_state_volatile_2.6.15_rc3.patch
- Previous message: Andi Kleen: "Re: [RFC][PATCH] Runtime switching of the idle function [take 2]"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
- Re: Problem with a script
... a loop there becomes impractical. ... You still have them as uniquely named
array indexes... ... writing the code twice will only ... reading your
entire code and parsing it in their head, ... (comp.lang.php) - Re: Problem with a script
... Okay, so variables have unique labels, that doesn't mean they still couldn't be handled in
a loop. ... You still have them as uniquely named array indexes... ... I
believe that for the new guy this code would be readable, and identifying problems should really not
be any more difficult with this, plus I think that it actually might save some time to write the actual
code from the beginnig, even though it's not at it's final stage, instead of first writing everything
spread out, and then rewriting the same code again cleaned. ... If you expect a person to spend
an hour reading your entire code and parsing it in their head, you wont get any help and have
to solve the problem by yourself. ... (comp.lang.php) - Re: advice and/or help on glReadPixels
... I could not see any "BRGA" in the documentation. ... Is it possible that some
cards are not ... >>> a) Try reading the entire RGB instead of just the
red. ... a quick integer loop with a mask & shift is ... (comp.graphics.api.opengl) - Re: while (1) vs. for ( ;; )
... >to write to the next guy who will be reading the code. ... You are unfamiliar
with the term "infinite loop"? ... Balmer Consulting ... (comp.lang.c) - Re: [BUG] Variable stopmachine_state should be volatile
... Its declaration has no sign ... In the while loop in function stopmachine,
... and compiler might optimize it by reading it once before the loop ... No. volatile
may look like a solution, ... (Linux-Kernel)