LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-14-2006, 03:06 PM   #1
pvpnguyen
Member
 
Registered: Mar 2006
Posts: 38

Rep: Reputation: 15
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.
 
Old 03-15-2006, 04:34 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Try making "datapassed" static.
 
Old 03-15-2006, 05:42 PM   #3
pvpnguyen
Member
 
Registered: Mar 2006
Posts: 38

Original Poster
Rep: Reputation: 15
Hello paulsm4,

datapassed is defined as static already. Can you think of anything else?, thanks so much
 
Old 08-25-2007, 06:05 PM   #4
sixerjman
Member
 
Registered: Sep 2004
Distribution: Debian Testing / Unstable
Posts: 180
Blog Entries: 1

Rep: Reputation: 32
Workqueues got totally redone in kernel 2.6.20

INIT_WORK no longer takes a data parameter.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
link dies intermittently-seemingly at random- between win<->linux not linux<->linux?? takahaya Linux - Networking 10 03-09-2007 10:37 PM
triple boot linux/linux/linux No Windows involved toastermaker Linux - Newbie 12 03-02-2006 10:40 PM
Redhat (rhel v2.1) bootup problem with linux (linux vs linux-up) namgor Linux - Software 2 06-24-2004 02:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration