Help me with linux workqueue
Hello all,
I write a small linux module to test out linux workqueue which is shown below. The function MyThread gets called but the data passed to it is wrong. Do you have any idea why? Thanks so much for you help. This is on Suse server Interprise 9.0
#include <linux/workqueue.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
MODULE_LICENSE("Dual BSD/GPL");
void MyThread(void *data);
static int datapassed;
static struct work_struct *ncbWorkStruct;
static int __init TestNcb_init(void)
{
datapassed = 0x99;
ncbWorkStruct = kmalloc(sizeof(struct work_struct), GFP_ATOMIC);
INIT_WORK(ncbWorkStruct, MyThread, &datapassed);
schedule_work(ncbWorkStruct);
printk(KERN_ALERT "End Init\n");
return 0;
}
static void __exit TestNcb_exit(void)
{
printk(KERN_ALERT "End Exit\n");
}
void MyThread(void *data)
{
int local = (int)*((int *)data);
printk("&&& DataPassed is %x\n", local);
printk("&&& Data is %x\n", datapassed);
return;
}
module_init(TestNcb_init);
module_exit(TestNcb_exit);
Last edited by pvpnguyen; 03-14-2006 at 03:55 PM.
|