In my own kernel module, I am trying to initialize kthread in an interrupt handler function.
in global scope:
static struct task_struct *thread1;
irq function handler:
static irqreturn_t* func_irq_handler (int irq, void *dev_id) { printk("irq handler ... \n"); thread1 = kthread_create(thread_function,NULL,"my_thread"); if ((thread1)) { printk(KERN_INFO "%s\n" , __FUNCTION__); } return IRQ_HANDLED; }
and stream function:
static thread_function(void) { unsigned long j1=jiffies+20000; int delay = 60*HZ; printk("%s \n",__FUNCTION__); while (time_before(jiffies,j1)) { schedule(); printk(KERN_INFO "after schedule\n"); } }
request_irq as follows:
request_irq(irq,func_irq_handler,IRQF_TRIGGER_HIGH | IRQF_TRIGGER_RISING ,"test_irq",(void*)&my_miscdev);
why am I getting this error:
BUG: scheduling while atomic: swapper
source share