Re: Question about kernel preemption

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

 



On Fri, Aug 14, 2009 at 4:19 PM, Greg Freemyer<greg.freemyer@xxxxxxxxx> wrote:
> On Fri, Aug 14, 2009 at 7:12 AM, Mohammed Gamal<m.gamal005@xxxxxxxxx> wrote:
>> On Fri, Aug 14, 2009 at 11:25 AM, Mulyadi
>> Santosa<mulyadi.santosa@xxxxxxxxx> wrote:
>>> On Fri, Aug 14, 2009 at 12:15 PM, Michael
>>> Blizek<michi1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>>>> Hi!
>>>>
>>>> On 00:08 Fri 14 Aug     , Mohammed Gamal wrote:
>>>>
>>>> ...
>>>>
>>>>> As far as I understood, Michi's answer explains why and when the
>>>>> kernel *can* get preempted, however what I really want to know is when
>>>>> and where kernel preemption is *triggered*. Please correct me if I did
>>>>> misunderstand anything.
>>>>
>>>> It is triggered by the timer interrupt. This is an interrupt which fires
>>>> periodically on configureable intervals. It does not only preempt the kernel,
>>>> but user space processes as well. If it fires, the kernel will enter the
>>>> scheduler and decide what to run next.
>>>
>>> In addition, IIRC:
>>> - every return from hard interrupt, either back to kernel space (if
>>> kernel level preemption is enabled) or to user space triggers
>>> preemption checking.
>>>
>>> - going back from kernel space to user space triggers preemption checking.
>>>
>>>
>>> --
>>> regards,
>>>
>>> Mulyadi Santosa
>>> Freelance Linux trainer
>>> blog: the-hydra.blogspot.com
>>>
>>
>> Thanks guys,
>> Any pointers to where this is done in the kernel source? I'm a little
>> bit lost there.
>>
>> Regards,
>> Mohammed
>
> I have not looked into the details of CONFIG_PREEMPT before.
>
> When it is enabled, does it mean every interrupt that invokes the
> scheduler can preempt a task, even if it is in kernel space.
>
> Or does it mean there is a API that allows a task to say "I'm high
> priority, run me at the next interrupt even if the kernel is what was
> interrupted?"
>
> If the latter, I believe the question is "What's the API to do that?"
>
> If the former, the question makes no sense.
>
> Greg
>
Hi All,
Basically, my questions was to know at which points the kernel would
normally call preempt_schedule() in order to trigger kernel
preemption, a first look at LXR didn't help me find where that is
performed.
However after a second look at preempt.h, I found that
preempt_schedule() gets called only in the preempt_check_resched()
macro, which is in turn called by preempt_enable().
Once we enable preemption via preempt_enable(), we check if
rescheduling is needed via preempt_check_resched() which calls
preempt_schedule() if scheduling is needed. Take a look at preempt.h
(lines 42-53)

Regards,
Mohammed

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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