Why can the kernel be stuck by a busy kernel thread ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.");

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux