On Thu, Sep 15, 2011 at 7:59 PM, Kristof Provost <[email protected]> wrote:

> On 2011-09-15 22:20:03 (+0800), Parmenides <[email protected]>
> wrote:
> >    I will try to test how to create kernel threads and have write a>
>   }
>
>
<snip>


> You're passing the address of a stack variable (i) as data pointer.
> That's not right, because as soon as you exit the kthread_init function
> the data may be overwritten.
>

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.

You can pass the variable i as a _value_ directly instead of passing a
pointer to solve this problem.

Kaustubh
_______________________________________________
Kernelnewbies mailing list
[email protected]
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Reply via email to