How to create some threads running tha same function
Kaustubh Ashtekar
ksashtekar at gmail.com
Fri Sep 16 00:56:56 EDT 2011
On Thu, Sep 15, 2011 at 7:59 PM, Kristof Provost <kristof at sigsegv.be> wrote:
> On 2011-09-15 22:20:03 (+0800), Parmenides <mobile.parmenides at gmail.com>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110916/4a7cafa2/attachment.html
More information about the Kernelnewbies
mailing list