I just started programming Linux kernel threads. I have a problem that I would like to share with you guys. My code is:
void do_big_things(void *data)
{
}
struct task_struct *t1;
struct task_struct *t2;
void calling_fucntion()
{
for(j =0; j < 100; j++)
{
t1 = kthread_run(do_big_things, &data1, "thread1");
t2 = kthread_run(do_big_things, &data2, "thread2");
}
}
Now, as far as I came to this problem (I may be wrong), it is that threads t1 and t2 are created and started by the kernel, and then the program returns at the beginning of the loop to create and start two more threads. Since there is no condition to wait for these threads to complete, the kernel creates so many threads that it causes a stack overflow.
All I want to know is how to make the program wait for the completion of these two threads, and then return to the loop, starting up two more threads.
Any help would be greatly appreciated.
source
share