Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
void my_softirq_handler(unsigned long data){
printk(KERN_ALERT "My softirq Handler is executing...\n");
/*printk(KERN_ALERT "Data Received: %L ...\n",++data);*/
}
/*
* hello_init the init function, called when the module is loaded.
* Returns zero if successfully loaded, nonzero otherwise.
*/
static int hello_init(void)
{
printk(KERN_ALERT "Module is up Hello!.\n");
open_softirq(MY_SOFTIRQ, my_softirq_handler, NULL);
raise_softirq(MY_SOFTIRQ);
return 0;
}
/*
* hello_exit the exit function, called when the module is removed.
*/
static void hello_exit(void)
{
printk(KERN_ALERT "Module is down bye bye!\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Mina");
The ERROR
---------
# insmod mysoftirq.ko
Using mysoftirq.ko
mysoftirq: Unknown symbol open_softirq
insmod: cannot insert `mysoftirq.ko': Unknown symbol in module (-1): No such file or directory
void my_tasklet_handler(unsigned long data){
printk(KERN_ALERT "My Tasklet Handler is executing...\n");
printk(KERN_ALERT "Data Received: %L ...\n",++data);
/*tasklet_schedule(&my_tasklet);*/
}
/*
* hello_init the init function, called when the module is loaded.
* Returns zero if successfully loaded, nonzero otherwise.
*/
static int hello_init(void)
{
printk(KERN_ALERT "Module is up Hello!.\n");
DECLARE_TASKLET(my_tasklet, my_tasklet_handler, data);
tasklet_schedule(&my_tasklet);
return 0;
}
/*
* hello_exit the exit function, called when the module is removed.
*/
static void hello_exit(void)
{
printk(KERN_ALERT "Module is down bye bye!\n");
}
I think tasklets need to be declared outside of the function - if you declare it inside the function, then it's just like you declared "int i;" or something like that - it has no meaning outside the function it's declared in.
/*
* hello_init the init function, called when the module is loaded.
* Returns zero if successfully loaded, nonzero otherwise.
*/
static int hello_init(void)
{
printk(KERN_ALERT "Module is up Hello!.\n");
tasklet_schedule(&my_tasklet);
return 0;
}
/*
* hello_exit the exit function, called when the module is removed.
*/
static void hello_exit(void)
{
printk(KERN_ALERT "Module is down bye bye!\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Mina");
if you look at the DECLARE_TASKLET macro, it's just a declaration and initialization of the tasklet struct. In my mind at least, it's easier to think of it that way.
I'm not sure what will happen if the modules exits before the tasklet starts execution... let me know what happens .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.