lkml.org 
[lkml]   [2005]   [Mar]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: repeat a function after fixed time period
From
Date

>
> This kernel code should do just fine.
>
>
>
> struct INFO {
> struct timer_list timer; // For test timer
> atomic_t running; // Timer is running
> };
>
> //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> //
> // This stops the timer. This must NOT be called with a spin-lock
> // held.
> //
> static void stop_timer()
> {
> if(atomic_read(&info->running))
> {
> atomic_dec(&info->running);

this is a race.

> if(info->timer.function)
> del_timer(&info->timer);

you probably want del_timer_sync() here.


> static void start_timer(void)
> {
> if(!atomic_read(&info->running))
> {
> atomic_inc(&info->running);

same race.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-04-06 13:30    [W:1.489 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site