I am trying to develop a kernel module which has to execute a thread.
I am facing an error while compiling the module.
This is the module:
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/kthread.h> // for threads
static struct task_struct *thread1;
int thread_fn(void) {
while(1) {
printk("Thread_fuction is running ...\n");
msleep(2000);
}
return 0;
}
int thread_init(void) {
char our_thread[8]="thread1";
printk(KERN_INFO "in init");
thread1 = kthread_create(thread_fn,NULL,our_thread);
if((thread1)) {
printk(KERN_INFO "in if");
wake_up_process(thread1);
}
return 0;
}
void thread_cleanup(void) {
int ret;
ret = kthread_stop(thread1);
if(!ret)
printk(KERN_INFO "Thread stopped");
}
MODULE_LICENSE("GPL");
module_init(thread_init);
module_exit(thread_cleanup);
And this is the error :
thread.c:25:26: error: passing argument 1 of ‘kthread_create_on_node’ from incompatible pointer type [-Werror=incompatible-pointer-types] thread1 = kthread_create(thread_fn,NULL,our_thread);
Could anyone help me to solve the problem?