Re: Question about kernel preemption

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

 



Hi!

On 15:59 Thu 13 Aug     , Mohammed Gamal wrote:
> Hi All,
> I know that kernel preemption exists in order to allow high-priority
> processes to interrupt the kernel if the kernel executes on relatively
> long code paths in order to improve latency times and process
> responsiveness.

Not only high priority processes. Every process can interrupt the kernel
the kernel can even interrupt itself.

> However, I am curious to know when and where the
> kernel gets preempted and at what code paths. I searched LXR for
> instances where preempt_schedule() gets called for instance but it
> seems it never gets explicitly called anywhere in the kernel (please
> CCIW). So, when exactly does the kernel get preempted? A pointer to
> the actual code path where that happens is appreciated.

Basically it get interrupted whenever it executes with interrupts disabled.
You know that interrupts are enables, if e.g.:
- the code is called by a user space system call, a workqueue or a kernel
thread
- the code calls mutex_lock or wait_event

You know that interrupts are disabled, if e.g.:
- the code is called by a timer
- after the code calls local_irq_disable, spin_lock_irqsave or spin_lock_irq

Sometimes, you have to read the code to find out whether interrupts are
enabled or disabled. It can be very important, because some things cannot be
done with interrupts enabled or disabled.

	-Michi
-- 
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com


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