From owner-freebsd-arch@FreeBSD.ORG Mon Jun 16 17:00:46 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A9DA6F1F for ; Mon, 16 Jun 2014 17:00:46 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 820DD26A3 for ; Mon, 16 Jun 2014 17:00:46 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id D1E13B984; Mon, 16 Jun 2014 13:00:43 -0400 (EDT) From: John Baldwin To: freebsd-arch@freebsd.org Subject: Re: Basic Question about Kernel Processes in FreeBSD. Date: Mon, 16 Jun 2014 09:42:35 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20140415; 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: <201406160942.35203.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 16 Jun 2014 13:00:43 -0400 (EDT) Cc: Dheeraj Kandula X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jun 2014 17:00:46 -0000 On Monday, June 16, 2014 6:45:47 am Dheeraj Kandula wrote: > Hey All, > When I was reading through the FreeBSD kernel code came across the > function kproc_create. This function creates a kernel process. Isn't it? > > But at some places in the code, there is mention that the address space is > shared with proc0. > > My Question: > Do all the kernel processes share the same address space. i.e. > even though they are multiple processes, they share the same kernel address > space. If so then why do we have kernel threads as threads are created in > the first place to share the address space of a process so that they are > light weight. > > Can someone shed some light on this. I am a bit confused about this. I > though that processes doesn't exist in kernel context and only user > processes existed. Yes, they share a single address space. There are other reasons you might want to have separate processes. The aio kproc's actually "borrow" user address spaces while doing I/O on behalf of a user process for example. You might also want kprocs so that things show up as processes in top, etc. There might also be other properties (like a cpuset set id) that you might want to use with kthreads (but those only work for processes for example). -- John Baldwin