Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Apr 2013 14:33:23 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-hackers@freebsd.org
Cc:        Adrian Chadd <adrian@freebsd.org>, vasanth rao naik sabavat <vasanth.raonaik@gmail.com>
Subject:   Re: preemptive kernel
Message-ID:  <201304011433.23781.jhb@freebsd.org>
In-Reply-To: <CAAuizBhhpkr28GUXVUCNb%2BTaRftW_BbErUMw-sFf=dePE944KA@mail.gmail.com>
References:  <CAAuizBgsev6ZgNEuwvB0oZ4U_kJuL1ujMfGR5yy2A6HUAkqQ=g@mail.gmail.com> <CAJ-Vmombz4DC5Ggocy7N5gQxG7xzsKvzK_x=Hn%2BimDLe3460jQ@mail.gmail.com> <CAAuizBhhpkr28GUXVUCNb%2BTaRftW_BbErUMw-sFf=dePE944KA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304011433.23781.jhb>