Skip to contentSkip to conversation

about kernel_thread!

DISCUSSION Zhenyu Wu 3 participants 3 messages Dec 13, 2004

lore
Share & tools
lore

Zhenyu Wu

author
#0 lore raw

Hello,

I have some confusions on kernel_thread, so I want to get help.

I want to create a thread in a loadable module, then I used the function kernel_thread() in init_module(). Of course, the thread was created, but when I remove the module there are errors. I think it is because of the thread I have created that have not been killed. So, how can I kill this thread when I remove the module?

Thanks,

#1 lore raw
Quoted 4 lines · Zhenyu Wu

Hello,

I have some confusions on kernel_thread, so I want to get help.

Quoted 8 lines

I want to create a thread in a loadable module, then I used the function kernel_thread() in init_module(). Of course, the thread was created, but when I remove the module there are errors. I think it is because of the thread I have created that have not been killed. So, how can I kill this thread when I remove the module?

Thanks,

You copy the method used in other kernel modules. This involves a semaphore and having the module removing routine send the task a signal. FYI, there is a wait_for_completion() routine and a complete_and_exit() routine already defined.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.9 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by John Ashcroft.
98.36% of all statistics are fiction.

#2 lore raw
In reply to Zhenyu Wu
Quoted 9 lines · Zhenyu Wu

Hello,

I have some confusions on kernel_thread, so I want to get help.

I want to create a thread in a loadable module, then I used the function kernel_thread() in init_module(). Of course, the thread was created, but when I remove the module there are errors. I think it is because of the thread I have created that have not been killed. So, how can I kill this thread when I remove the module?

You can find sample-code here:
http://ezs.kr.hsnr.de/TreiberBuch/Download/TreiberEntwickeln2004261/6-9-kthread.c

Juergen.