Messages in this thread | | | Subject | Re: repeat a function after fixed time period | From | Arjan van de Ven <> | Date | Wed, 23 Mar 2005 21:48:54 +0100 |
| |
> > 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/
| |