mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Dong Feng" <middle.fengdong@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: The purpose and implementation of cond_resched()
Date: Thu, 22 Feb 2007 00:13:43 +0800	[thread overview]
Message-ID: <a2ebde260702210813h14bc98b6s8c4c8c560c3647ff@mail.gmail.com> (raw)

I have a question about cond_resched().

What is the condition under which I should invoke cond_resched() irreplaceably?

For example, I see the following code in ksoftirqd(),

preempt_enable_no_resched();
cond_resched();
preempt_disable();

But I do not understand why I should not write the following code,

preempt_enable();
preempt_disable();

Are the above two pieces of code equal in functionality?

On the other hand, I see cond_resched() check and set PREEMPT_ACTIVE.
I currently do not understand why it should do this, since I think
PREEMPT_ACTIVE is only used to be set in the return-from-interrupt
code in order to prevent schedule() from removing task from run queue
unpredictably. But for cond_resched(), which is a planned voluntary
switch, why does it also deal with this flag?

             reply	other threads:[~2007-02-21 16:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-21 16:13 Dong Feng [this message]
2007-02-21 17:08 ` Dong Feng

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=a2ebde260702210813h14bc98b6s8c4c8c560c3647ff@mail.gmail.com \
    --to=middle.fengdong@gmail.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

all inboxes | Powered by JetHome®