public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: torvalds@transmeta.com (Linus Torvalds)
To: linux-kernel@vger.kernel.org
Subject: Re: 2.4.6 possible problem
Date: Tue, 17 Jul 2001 19:24:23 +0000 (UTC)	[thread overview]
Message-ID: <9j23d7$1qs$1@penguin.transmeta.com> (raw)
In-Reply-To: <3B54454B.97AA34E6@ueidaq.com> <Pine.LNX.3.95.1010717103652.1430A-100000@chaos.analogic.com>

In article <Pine.LNX.3.95.1010717103652.1430A-100000@chaos.analogic.com>,
Richard B. Johnson <root@chaos.analogic.com> wrote:
>
>    ticks = 1 * HZ;        /* For 1 second */
>    while((ticks = interruptible_sleep_on_timeout(&wqhead, ticks)) > 0)
>                  ;

Don't do this.

Imagine what happens if a signal comes in and wakes you up? The signal
will continue to be pending, which will make your "sleep loop" be a busy
loop as you can never go to sleep interruptibly with a pending signal.

In short: if you have to wait for a certain time or for a certain event,
you MUST NOT USE a interruptible sleep.

If it is ok to return early due to signals or similar (which is nice -
you can allow people to kill the process), then you use an interruptible
sleep, but then you mustn't have the above kind of loop.

		Linus

  parent reply	other threads:[~2001-07-17 19:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-17 14:01 2.4.6 possible problem Alex Ivchenko
2001-07-17 14:46 ` Richard B. Johnson
2001-07-17 18:44   ` Alex Ivchenko
2001-07-17 18:52     ` Richard B. Johnson
2001-07-17 19:24   ` Linus Torvalds [this message]
2001-07-17 19:36     ` Richard B. Johnson
2001-07-17 19:42       ` Richard B. Johnson
2001-07-17 22:33       ` Alex Ivchenko

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='9j23d7$1qs$1@penguin.transmeta.com' \
    --to=torvalds@transmeta.com \
    --cc=linux-kernel@vger.kernel.org \
    /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