From: "Yitzchak Eidus" <ieidus@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Re: puting task to TASK_INTERRUPTIBLE before adding it to an wait queue
Date: Fri, 17 Mar 2006 00:52:08 +0200 [thread overview]
Message-ID: <e7aeb7c60603161452t8630996kcab443bdaac4454e@mail.gmail.com> (raw)
In-Reply-To: <e7aeb7c60603161431m6d873520r2b6754e115e26f80@mail.gmail.com>
On 3/17/06, Yitzchak Eidus <ieidus@gmail.com> wrote:
> the function worker_thread in kernel 2.6.15.6 first put the task to
> TASK_INTERRUPTIBLE and only then add itself to an wait queue:
> set_current_state(TASK_INTERRUPTIBLE);
> while (!kthread_should_stop()) {
> add_wait_queue(&cwq->more_work, &wait);
> ....
> my question is, what will happen if the timeslice for the
> worker_thread will finished just before it add itself to the wait
> queue?
> wont it call schedule() that will find the task is in
> TASK_INTERRUPTIBLE state and remove it from the runqueue? ( that what
> schedule() should do no? )
> and then how will the kernel be able to call to worker_thread ever if
> it isnt in any list???
> thanks for the comments!
>
more over the whole loop look like that:
set_current_state(TASK_INTERRUPTIBLE);
while (!kthread_should_stop()) {
add_wait_queue(&cwq->more_work, &wait);
if (list_empty(&cwq->worklist))
schedule();
else
__set_current_state(TASK_RUNNING);
remove_wait_queue(&cwq->more_work, &wait);
if (!list_empty(&cwq->worklist))
run_workqueue(cwq);
set_current_state(TASK_INTERRUPTIBLE);
}
what was the logic of putting the
set_current_state(TASK_INTERRUPTIBLE); before the loop and in the last
statement of the loop?
why not use something like this:
while (!kthread_should_stop()) {
add_wait_queue(&cwq->more_work, &wait);
set_current_state(TASK_INTERRUPTIBLE);
if (list_empty(&cwq->worklist))
schedule();
else
__set_current_state(TASK_RUNNING);
remove_wait_queue(&cwq->more_work, &wait);
if (!list_empty(&cwq->worklist))
run_workqueue(cwq);
}
that do the same thing without putting the task before the loop and in
the loop...?
( unless i am missing something? )
next prev parent reply other threads:[~2006-03-16 22:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-16 22:31 Yitzchak Eidus
2006-03-16 22:52 ` Yitzchak Eidus [this message]
2006-03-17 8:01 ` Mike Galbraith
2006-03-18 6:23 ` Andy Lutomirski
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=e7aeb7c60603161452t8630996kcab443bdaac4454e@mail.gmail.com \
--to=ieidus@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®