From: Frederic Weisbecker <fweisbec@gmail.com>
To: vinit dhatrak <vinit.dhatrak@gmail.com>
Cc: Daniel Rodrick <daniel.rodrick@gmail.com>,
Kernel Newbies <kernelnewbies@nl.linux.org>,
Linux Newbie <linux-newbie@vger.kernel.org>
Subject: Re: preempt_disable() as synchronization tool
Date: Sat, 10 Oct 2009 19:41:59 +0200 [thread overview]
Message-ID: <20091010174157.GF5150@nowhere> (raw)
In-Reply-To: <edf0f34e0910091900v305ec56u44913503cc8689dd@mail.gmail.com>
On Sat, Oct 10, 2009 at 07:30:08AM +0530, vinit dhatrak wrote:
> On Fri, Oct 9, 2009 at 9:13 AM, Daniel Rodrick <daniel.rodrick@gmail.com> wrote:
> > Hi List,
> >
> > I have few queries related to preempt_disable() and would appreciate
> > any answers to it.
> >
> > Firstly, Does preempt_disable() disable the preemption on all the
> > processors or on just the local processor?
>
> I guess just local processor as the preempt count is maintained in
> current thread_info struct. Correct me if I am wrong here.
Yeah, once you disable the preemption, the current task will stay
on the current cpu until you reenable preemption.
So no other task can be scheduled in this cpu until it's reenabled.
> >
> > Secondly, a preempt_disable() a sufficient synchronization technique
> > to guard a data that is shared only among process context code on a
> > Uni-processor? And on SMP?
>
> It is sufficient only in case of uni-processor (Actually spin_lock
> also just disables preemption in case of uni-processor)
> >
> > Lastly, is it allowable to schedule / sleep immediately after a call
> > to preempt_disable()?
>
> No I guess kernel will panic with some error like , "scheduling while
> in Atomic Context".
It won't panic but it won't be happy either :-) You'll get the warning
message but things will continue to go ahead...badly...
In most cases, disabling preemption is done when you need to manipulate
per cpu data and then you don't want to be preempted in the middle and
risk to be scheduled in another cpu, or let another task touch the same
cpu data while you were in the middle of your work. That's why it warns
when you voluntarily schedule while you have disabled preemption, because
you are supposed to be manipulating per cpu data and it's dangerous.
> >
> > Thanks & Best Regards,
> >
> > Dan
> >
> > --
> > To unsubscribe from this list: send an email with
> > "unsubscribe kernelnewbies" to ecartis@nl.linux.org
> > Please read the FAQ at http://kernelnewbies.org/FAQ
> >
> >
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@nl.linux.org
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
next prev parent reply other threads:[~2009-10-10 17:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-09 3:43 preempt_disable() as synchronization tool Daniel Rodrick
2009-10-10 2:00 ` vinit dhatrak
2009-10-10 4:46 ` askb
[not found] ` <1255150012.7925.6.camel@linux-k65f.site>
2009-10-10 17:07 ` vinit dhatrak
2009-10-10 17:41 ` Frederic Weisbecker [this message]
2009-10-12 3:05 ` Pei Lin
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=20091010174157.GF5150@nowhere \
--to=fweisbec@gmail.com \
--cc=daniel.rodrick@gmail.com \
--cc=kernelnewbies@nl.linux.org \
--cc=linux-newbie@vger.kernel.org \
--cc=vinit.dhatrak@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.