linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* (no subject)
@ 2003-12-11 23:37 Hettinger Tamas
  2003-12-12  1:29 ` Jonathan Corbet
  0 siblings, 1 reply; 2+ messages in thread
From: Hettinger Tamas @ 2003-12-11 23:37 UTC (permalink / raw)
  To: linux-kernel

Hi everybody !

I've been developing a kernel module and I needed some timer functions. I
found init_timer() add_timer() del_timer() etc... but I would ask some
questions about them.

1) When I set a timer, it is added to a timer_list chain with add_timer().
If the time is up and the scheduled function is called, should I remove the
timer_list struct from the chain via del_timer() ? Or is it removed
automatically ?

2) How can a module safely removed if it has some running timers ? I have to
call del_timer() in cleanup_module() for each running timer ? And what's the
purpose of the timer_pending function ?

thanks


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re:
  2003-12-11 23:37 Hettinger Tamas
@ 2003-12-12  1:29 ` Jonathan Corbet
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Corbet @ 2003-12-12  1:29 UTC (permalink / raw)
  To: Hettinger Tamas; +Cc: linux-kernel

> 1) When I set a timer, it is added to a timer_list chain with add_timer().
> If the time is up and the scheduled function is called, should I remove the
> timer_list struct from the chain via del_timer() ? Or is it removed
> automatically ?

It will be removed automatically, just before your timer function is called.

> 2) How can a module safely removed if it has some running timers ? I have to
> call del_timer() in cleanup_module() for each running timer ? 

You cannot remove a module (safely) if there are outstanding timers.  Use
del_timer_sync() to get rid of them and ensure they aren't running on
another processor.

Chapter 6 of Linux Device Drivers covers this topic; see:

	http://www.xml.com/ldd/chapter/book/ch06.html

jon

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-12-12  1:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-11 23:37 Hettinger Tamas
2003-12-12  1:29 ` Jonathan Corbet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).