RE: Premptive vs non-premptive kernel.

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

 



On Fri, 2004-06-25 at 15:53 +0530, Dhiman, Gaurav wrote:

> I have one doubt, as you said that timer interrupt sets the need_resched
> if the time allocated has expired and while returning from any interrupt
> the the scheduler will be called if need_resched is set. My question is,
> will the scheduler be invoked by any other interrupts, other than timer
> interrupt? I think after setting the need_resched when timer interrupt
> will be returning it will clear the need_resched and will call the
> scheduler, so all other interrupts occurring after that need not to
> worry about need_resched and should not check it, as scheduler has
> already been called by timer interrupt. Why are we checking the
> need_resched on return of every interrupt as in all cases it will only
> be handled by timer interrupt?

Two reasons.

Primarily, because need_resched is set by things other than
scheduler_tick().  Different places in the scheduler set it, so we need
to check for it in a more common path.  Sticking it at the end of the
return-from-interrupt code is simple.

Second, because kernel preemptions (preempting when the interrupt
handler would of returned to kernel space) can only occur when
preempt_count==0.  If it is nonzero, then we cannot preempt.  So we
check for the state "need_resched!=0 and preempt_count==0" at the end of
all interrupts.

	Robert Love



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