From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 1 19:02:05 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 1ACB7EB8; Mon, 1 Apr 2013 19:02:05 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) by mx1.freebsd.org (Postfix) with ESMTP id ED6159CB; Mon, 1 Apr 2013 19:02:04 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 51D65B9B8; Mon, 1 Apr 2013 15:02:04 -0400 (EDT) From: John Baldwin To: freebsd-hackers@freebsd.org Subject: Re: preemptive kernel Date: Mon, 1 Apr 2013 14:33:23 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p25; KDE/4.5.5; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201304011433.23781.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 01 Apr 2013 15:02:04 -0400 (EDT) Cc: Adrian Chadd , vasanth rao naik sabavat X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2013 19:02:05 -0000 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