On Wed, 23 Mar 2005, Arjan van de Ven wrote:
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.
No, never. stop_timer() can be called at any time, even from interrupt context. The last guy to touch info->running wins. The logic works just perfectly.
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.
No such race at all.
Cheers, Dick Johnson Penguin : Linux version 2.6.11 on an i686 machine (5537.79 BogoMips). Notice : All mail here is now cached for review by Dictator Bush. 98.36% of all statistics are fiction. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

