mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arjan van de Ven <arjan@infradead.org>
To: linux-os@analogic.com
Cc: sounak chakraborty <sounakrin@yahoo.co.in>, linux-kernel@vger.kernel.org
Subject: Re: repeat a function after fixed time period
Date: Wed, 23 Mar 2005 21:48:54 +0100	[thread overview]
Message-ID: <1111610935.6306.97.camel@laptopd505.fenrus.org> (raw)
In-Reply-To: <Pine.LNX.4.61.0503231522070.16567@chaos.analogic.com>


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



  reply	other threads:[~2005-03-23 20:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-23 19:43 sounak chakraborty
2005-03-23 20:23 ` linux-os
2005-03-23 20:48   ` Arjan van de Ven [this message]
2005-03-23 20:56     ` linux-os
2005-03-23 21:27       ` Arjan van de Ven
2005-03-23 22:00         ` linux-os
2005-03-24  6:59           ` Arjan van de Ven
2005-03-23 23:13 sounak chakraborty
2005-03-24 12:09 ` linux-os

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1111610935.6306.97.camel@laptopd505.fenrus.org \
    --to=arjan@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-os@analogic.com \
    --cc=sounakrin@yahoo.co.in \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®