Re: timer interrupt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



El Sat, Jan 03, 2009 at 11:13:45PM +0800 Peter Teoh ha dit:

> On Sat, Jan 3, 2009 at 6:20 PM, Microbit_Ubuntu
> <microbit@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> > Hello all,
> >
> > I've just joined up with this list, so this is mainly an initial "ping"
> > to see if I can post.
> > I'm a newbie studying embedded linux on an Olimex SAM9-L9260 target,
> > cross compiling on Ubuntu 8.10.
> >
> > Eventually I'd like to ask a couple of questions. On the subject of
> > timer INTs, I actually just got timer callbacks going in this sort of
> > newbie handler approach :
> >
> > static void timer_fire(unsigned long data)
> > {
> >  mod_timer(&timer_ticktock, jiffies + (timer_tick*HZ));
> >  printk ("Timer fired at %lu jiffies\n",jiffies);
> > }
> >
> 
> since u used mod_timer(), did u also use del_timer() to delete the
> timer in your exit module code?
> 
> (check for example, drivers/char/synclinkmp.c:shutdown() routine).
> 
> but from kernel/timer.c these are the API for xxx_timer():
> 
> EXPORT_SYMBOL(init_timer);
> EXPORT_SYMBOL(init_timer_deferrable);
> EXPORT_SYMBOL(__mod_timer);
> EXPORT_SYMBOL(mod_timer);
> EXPORT_SYMBOL(del_timer);
> EXPORT_SYMBOL(try_to_del_timer_sync);
> EXPORT_SYMBOL(del_timer_sync);
> 
> so it seemed there is another del_timer_sync(), or
> try_to_del_timer_sync()....search the drivers subdirectory for
> examples....i am not sure of the differences among these.

on a smp system del_timer() could be called while the timer is
executing on another processor. this could cause a race condition
when the timer function uses resources that are freed after returning
from del_timer(). to assure that the timer isn't running after
deleting it, use del_timer_sync().

-- 
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

       The yellow ships hung in the air just like bricks dont do
                 (The Hitch-Hiker's Guide to the Galaxy)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux