Re: How spin_lock and preempt disable works?

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

 



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/
---------------------------------

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[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