On Wed, Oct 7, 2009 at 1:57 PM, er krishna <[email protected]> wrote:
>
>
> On Wed, Oct 7, 2009 at 12:45 PM, govind raj nayak <[email protected]> 
> wrote:
>>
>> Yes, spinlock would automatically disable kernel preemption.
>
> >>>>>>I don't think so, otherwise what is the use of spin_lock_irq_save api, 
> >>>>>>if spin_lock api does it  ?.  I mean if spin_lock api >>>>>>is 
> >>>>>>disabling the kernel preemption, then can a newly occured interrupt 
> >>>>>>will preempt currently executing process which >>>>>>has taken a spin 
> >>>>>>lock by spin_lock() api. Just confirm my understanding.
>
> >>>>>>>I don't think all the spinlock api will disable kernel preemption. We 
> >>>>>>>must check in kernel code, that on which API >>>>>>>preemption is 
> >>>>>>>disable or if anybody knows, please mention those ones.
>
>
>>
>> I was just giving theeoritical overview. As far as I know not all 
>> synchronization constructs would disable the kernel preemption
>
> >>>>>>Yes, agreed.
> >>>>>>Can we say if preemption is disable but interrupts are not, then 
> >>>>>>interrupt handler won't be able to preempt the currently executing 
> >>>>>>process.
>
> >>>>>> I am just asking, if we have disable the interrupts on local processor 
> >>>>>> by some api, and suddenly if higher priority >>>>>> process/ interrupt 
> >>>>>> comes (the first process  which is currently executing has acquired a 
> >>>>>> spin lock by >>>>>>spin_lock_irq_save() api).  I just want to know 
> >>>>>> weather the higher priority process/interrupt will preempt the lower 
> >>>>>> priority >>>>>> process or it will spin.
>
>
> Just clear the confusion.
>
>
> Regards,
> Krishna
>
>>
>> automatically (for instance when acquiring a big kernel lock). In addition 
>> you could use preempt_enable() and preempt_disable() to explicitly enable or 
>> disable kernel preemption. Thanks.
>>
>> -Govindraj
>>
>> On Wed, 07 Oct 2009 11:15:06 +0530 wrote
>> >Rajat San,Just asking (since i didn't see spinlock implementation in kernel 
>> >src),On Tue, Oct 6, 2009 at 5:52 PM, Rajat Jain wrote:
>>
>> Hello Govind,
>>
>> > What happens when you go for spin locks without
>> > disabling kernel preemption? Suppose you acquire
>> > a spin lock in a system call handler (a service
>> > routine on behalf of a user mode process) with
>> > kernel preemption enabled.
>>
>> This is not possible. Spin lock APIs disable kernel preemption
>> automatically.Spin lock APIs disables kernel preemption in all its api or 
>> some specific apis only. Please confirm and elaborate.
>>
>>
>> Thanks,
>>
>> RajatBest regards,Krishna
>>
>
Krishna, you seem to be getting confused between kernel getting
preempted and kernel getting interrupted.
Any spin lock will disable kernel preemption.
If you use spin_lock() then it will just disable kernel preemption but
if you get any interrupt then its handler will get executed.
But if you use spin_lock_irqsave() then it will disable preemption
plus it will disable local interrupts.

I suggest you should read "Kernel Synchronization Methods" chapter
from Linux Kernel Development by Robert Love.


-Vinit

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to