preemptive kernel

John Baldwin jhb at freebsd.org
Mon Apr 1 19:02:05 UTC 2013


On Friday, March 22, 2013 4:10:16 pm vasanth rao naik sabavat wrote:
> Hi Adrian,
> 
> Just to clarify, is the kernel pre-emption involuntary?
> 
> Let say I have a kernel thread processing a huge list of entries, would
> this thread get involuntarily context switched out because of kernel
> preemption?
> 
> What is the time slice after which a kernel thread can involuntarily
> context switched out?
> 
> Could you please point to the file in the source code which handles the
> kernel pre-emption.

In-kernel preemption is driven by interrupts, not time slices.  If an 
interrupt arrives that awakens a higher priority thread (e.g. an interrupt 
thread), or if your thread awakens a thread that has higher priority (e.g. due 
to wakeup() or cv_signal()), then your thread will be preempted.

In general time-based preemptions are only done for user threads.

-- 
John Baldwin


More information about the freebsd-hackers mailing list