Why can the kernel be stuck by a busy kernel thread ?
Parmenides
mobile.parmenides at gmail.com
Fri Oct 14 10:04:12 EDT 2011
Hi,
I code a kernel module which do some nop. When inserted into the
kernel, the kernel will be stuck and can not reponse my keypress
anymore. So, I have to reboot to get out. Why?
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/kthread.h>
struct task_struct *ktask = NULL;
static int thread_func(void *data)
{
int i;
while (!kthread_should_stop()){
for (i = 0; i < 1000; i++){
asm volatile ("nop\n\t");
}
}
return 0;
}
static int tst_init(void)
{
ktask = kthread_run(thread_func, NULL, "mythread");
return 0;
}
static void tst_exit(void)
{
if (ktask){
kthread_stop(ktask);
ktask = NULL;
}
}
module_init(tst_init);
module_exit(tst_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Parmenides");
MODULE_DESCRIPTION("Something.");
More information about the Kernelnewbies
mailing list