[lkml]   [2001]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [newbie] timer in module
Le Fri, 18 May 2001 08:32:33 -0400 (EDT)
Bart Trojanowski <> a ecrit :

> On Fri, 18 May 2001, sebastien person wrote:
> > I have a network module that need to regularly get data from network
> > adaptater.
> > But I don't know if it safe to do a loop with a timer in the module.
> First off you have to decide where you want to run your 'get data'.
> are three context you can pick from: user priority or from the kernel.
> you run the loop below from a user context then you will have a very
> unresponsive system but at least other things will still run. If you
> that from a kernel context nothing else will run... unless you
> call the scheduler.

So the fact to call the scheduler allow me to handle send request for
example ?

> > My aim is to do a get data call every x seconds (x is variable).
> You mentioned a timer... it runs in kernel context but at least it
> will not end up hanging your system up. This is how you would use one:
> struct tq_struct timer;
> init_timer(&timer);
> timer.routine = func;
> = something;
> mod_timer(&timer, 5*HZ); // 5 seconds from now
> void func( unsigned long something ) {
> get_data( something );
> mod_timer(&timer, 5*HZ); // again in 5 seconds
> }
> Make sure you call 'del_timer_sync' once you are done.
> > Is it better to let an external program executing timer call and get
> > call via ioctl ?
> Since you are getting data every 5 seconds you may as well use a user
> space program. It does not seem like you are looking for phenomenal
> responsiveness here.
> Bart.
> --
> WebSig:

Thanks for all these details
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 12:53    [W:0.061 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site