Re: Interrupt Context

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

 



On 7/12/05, Ketan Mukadam <ketanm@xxxxxxxxx> wrote:
> On 7/12/05, Rik van Riel <riel@xxxxxxxxxxx> wrote:
> > On Mon, 11 Jul 2005, Karane Mariano Vieira wrote:
> >
> > > Just a silly doubt,
> > >
> > > when the schedule() runs activated by the timer interrupt handler, it
> > > runs in which context? interrupt context?
> >
> > The function schedule() is never directly activated by the
> > timer interrupt handler.
> >
> > Instead, when the timer irq handler notices the scheduler
> > should run, it sets a flag.  After the irq handler has
> > finished (and quit), the part of the kernel that is
> > responsible for switching back to userspace mode notices
> > that the flag got set.
> >
> > That part of the kernel, running in process context,
> > then calls the scheduler.
> >
> 
> For more details about how the kernel "returns from interrupt" read
> 
> Understanding the Linux Kernel, Second Edition
> By Daniel P. Bovet, Marco Cesati
> 
> An excellent book to clear your fundamentals about Linux.
> 

Here is the code related to that:

File: usr/src/<kernel_version>/arch/i386/kernel/entry.S#L161

161 ret_from_intr:
162         GET_THREAD_INFO(%ebp)
163         movl EFLAGS(%esp), %eax         # mix EFLAGS and CS
164         movb CS(%esp), %al
165         testl $(VM_MASK | 3), %eax
166         jz resume_kernel                # returning to kernel or vm86-space
167 ENTRY(resume_userspace)
168         cli                             # make sure we don't miss
an interrupt
169                                         # setting need_resched or sigpending
170                                         # between sampling and the iret
171         movl TI_flags(%ebp), %ecx
172         andl $_TIF_WORK_MASK, %ecx      # is there any work to be done on
173                                         # int/exception return?
174         jne work_pending
175         jmp restore_all

............
...........
...........
............
265 work_pending:
266         testb $_TIF_NEED_RESCHED, %cl
267         jz work_notifysig
268 work_resched:
269         call schedule

On line 269 we are calling the schedule function if the
$_TIF_NEED_RESCHED is set.

-Gaurav

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

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