<br><br><div class="gmail_quote">On Thu, Sep 15, 2011 at 7:59 PM, Kristof Provost <span dir="ltr"><<a href="mailto:kristof@sigsegv.be">kristof@sigsegv.be</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 2011-09-15 22:20:03 (+0800), Parmenides <<a href="mailto:mobile.parmenides@gmail.com">mobile.parmenides@gmail.com</a>> wrote:<br>
> I will try to test how to create kernel threads and have write a> }</div><div class="im">
<br></div></blockquote><div><br></div><div><snip></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">
</div>You're passing the address of a stack variable (i) as data pointer.<br>
That's not right, because as soon as you exit the kthread_init function<br>
the data may be overwritten.<br></blockquote><div><br></div><div>Also, even if you declare i as global to solve this issue, you would not get what you expect because all the threads you create get the _same_ address pointing to the same variable i. This variable will keep on incrementing in the background till all your threads are created and thus your threads will print the current value of i which is not what you expect.</div>
<div><br></div><div>You can pass the variable i as a _value_ directly instead of passing a pointer to solve this problem.</div><div><br></div><div>Kaustubh</div></div>