Re: preempt_disable() as synchronization tool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx> 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@xxxxxxxxxxxx
> > Please read the FAQ at http://kernelnewbies.org/FAQ
> >
> >
> 
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
> 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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

[Index of Archives]     [Audio]     [Hams]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Fedora Users]

  Powered by Linux