Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Jun 2014 09:42:35 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-arch@freebsd.org
Cc:        Dheeraj Kandula <dkandula@gmail.com>
Subject:   Re: Basic Question about Kernel Processes in FreeBSD.
Message-ID:  <201406160942.35203.jhb@freebsd.org>
In-Reply-To: <CA%2BqNgxRzHSuBkB15JOhYiXn-rdBcCw7vBKUGgSieEe_h%2B6AtEQ@mail.gmail.com>
References:  <CA%2BqNgxRzHSuBkB15JOhYiXn-rdBcCw7vBKUGgSieEe_h%2B6AtEQ@mail.gmail.com>

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



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