Re: timer interrupt

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

 



ah...two points:

a.   that the timer is NOT per-CPU.   but a global entity.   but many
CPU can own the timer - as deduced from timer->base structure, but
only one is running - based on timer->runng_base.   correct?   so
logically the logic of clean deletion (making sure not being in used
in another CPU) should be done in del_timer()....ie, detecting another
CPU's running_timer is pointing to the current timer, if so then call
del_timer_sync().

ie, del_timer()->del_timer_sync()???

b.   concurrent modification via mod_timer(), and reading the source,
it is synchronized by the per-CPU variable:

cat /proc/kallsyms |grep tvec_bases |grep per_cpu
c05b6b48 d per_cpu__tvec_bases

But I cannot understand why the same can be done for del_timer()?

Thanks for the answer Matthias.

On Sun, Jan 4, 2009 at 12:55 AM, Matthias Kaehlcke
<matthias@xxxxxxxxxxxx> wrote:
> 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                  `-
>



-- 
Regards,
Peter Teoh

--
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