Re: How spin_lock and preempt disable works?

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

 



On 4/30/06, Gaurav Dhiman <gauravd.chd@xxxxxxxxx> wrote:
On 4/29/06, Manjunath Naik <peter.desouzain@xxxxxxxxx> wrote:
>
>
>
> On 4/29/06, Hareesh Nagarajan <hnagar2@xxxxxxxxx> wrote:
> > On 4/29/06, Manjunath Naik < peter.desouzain@xxxxxxxxx> wrote:
> >
> > > I was not able to understand what exaclty is happened in this macro.
> > ...
> > [snip]
> > ...
> > > But I was not able to understand how exactly it works:
> > ...
> > [snip]
> > ...
> > > #define preempt_disable() \
> > > But I was not able to understand how exactly preempting works. when
> >
> > While we hold a spin lock to protect a critical region, it is
> > necessary for us to disable preemption. To disable preemption, we
> > increment the preempt count.
> >
> > > schedular wants to schedule the other process, it checks the
> > > thread_info->preempt_count value? If it is yes plese provide me some
> links
> > > or code reference for it.
> >
> > Documentation/preempt- locking.txt
> >
> > --
> > ./hareesh
> >
>
>
> If prempt_count is incremented how it will leads to disable the preemption?
> who will check the counter? Is scheduler will check this counter before
> selecting other process for context switch. If yes, how sheduler gets the
> priority to run itself.

You know that disabling preemtion is done by just incrementing the
premt_count for that process. If the process's preempt_count is non
zero, then the process can not be preempted and this check is done
while returning from system call and interrupt context (as mentioned
by Jan Hudec as well). Here is the code which actually checks this
preempt_count and preempt only if this count is zero and process need
to be rescheduled, means there is either some high priority process
available ot the timeslice of current process has expired.

code which checks preemption count while returning from interrupt context.
http://lxr.linux.no/source/arch/i386/kernel/entry.S#L161

Hope you will understand the code, but if you find any problem do mail
your problems.

regards,
Gaurav


>
>
>
>


--
--
-Gaurav
Email: gauravd.chd@xxxxxxxxx
---------------------------------
Read my blog at: http://lkdp.blogspot.com/
---------------------------------

 
thats fine. I understood it. Even though  inside timer interrupt schedule() is called I had forgotten at that moment it.
 
Now I facing trouble to understand the Linux assembly code. Is their anr good site for it. So that I can learn the minimum things within another 4-5 days.
 
Thanks
Manjunath
 

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux