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 > kernel module which creates a number of kernel threads running the > same function. But the results is somewhat confusing. > > static int kthread_init(void) > { > int i; > > for (i = 0; i < MAX_KTHREAD; i++){ > ktask[i] = kthread_run(my_kthread, &i, "mythread[%d]", i); > } > return 0; > }
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. The fact that it works in some cases is pure coincidence. Regards, Kristof _______________________________________________ Kernelnewbies mailing list [email protected] http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
