queue_task(..... , &tq_timer) does not work for me!
From: Sathish Kumar. V (sathishk_at_catsglobal.co.in)
Date: 09/08/04
- Next message: Kasper Dupont: "Re: system call table?"
- Previous message: Exillis: "iostream breaks plug-in DSO"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 8 Sep 2004 05:14:22 -0700
Hi,
This is a continuation of thread, which i couldn't able to post it
on that thread itself. sorry.
I am learning the scheduling chapter[11] of lkmpg and wrote a modified
code[based on the thread]. I use kernel 2.4 supplied with latest
knoppix.
The code given in that book does not work as the timer handling
function does not get called. The modified code[based on the
newsgroup thread] works once and the timer task does not get
re-queued. I am stuck here. The modified code is pasted below:
===============================================================================
# include <linux/kernel.h>
# include <linux/module.h>
# if CONFIG_MODVERSIONS == 1
# define MODVERSIONS
# include <linux/modversions.h>
# endif
# include <linux/proc_fs.h>
# include <linux/tqueue.h>
# include <linux/sched.h>
static int TimerCounter=0;
static struct wait_queue *WaitQ=NULL;
static void interrupt_routine(void *);
static char exit_mod=0;
static struct tq_struct Task;
static void interrupt_routine(void *nothing)
{
printk("start sync=%d\n",Task.sync);
TimerCounter++;
if(exit_mod==0)
{
Task.list.next=NULL;
Task.list.prev=NULL;
Task.routine=interrupt_routine;
Task.data=0;
Task.sync=0;
queue_task(&Task, &tq_timer);
}
else
wake_up(&WaitQ);
printk("end sync=%d\n",Task.sync);
}
int procfile_read(char *buffer,
char **buffer_location,
off_t offset,
int buffer_length,
int *eof,
void *data)
{
static char mybuffer[80];
int len;
static int count = 1;
if(offset>0)
return 0;
len=sprintf(mybuffer,"Timer called %d times\n",TimerCounter);
count++;
*buffer_location=mybuffer;
return len;
}
int init_module()
{
init_waitqueue_head(&WaitQ);
Task.list.next=NULL;
Task.list.prev=NULL;
Task.sync=0;
Task.routine=interrupt_routine;
Task.data=0;
queue_task(&Task, &tq_timer);
create_proc_read_entry("mytimer",
0644,
&proc_root,
procfile_read,
NULL);
return 0;
}
void cleanup_module()
{
exit_mod=1;
remove_proc_entry("mytimer",&proc_root);
sleep_on(&WaitQ);
}
===============================================================================
and the sync is always 0 [start sync and end sync are printed once and
thats it]
rmmod hangs which is obvious as nobody is there to wake it up, as the
bh is not called again.
Any help in spotting the problem would be highly appreciated.
Thanks
Sathish
- Next message: Kasper Dupont: "Re: system call table?"
- Previous message: Exillis: "iostream breaks plug-in DSO"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|