Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Feb 1999 02:51:28 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        bf20761@binghamton.edu
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: how process 0 becomes the swapper
Message-ID:  <199902060251.TAA28845@usr02.primenet.com>
In-Reply-To: <Pine.SOL.L3.93.990204113355.8750C-100000@bingsun2> from "zhihuizhang" at Feb 4, 99 12:23:52 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> I am wondering how the swapper code (I think it should be in swap_pager.c
> and vm_swap.c) is associated with the proc0.  Proc0 is created by hand in
> init_main.c and machdep.c.  Everything is setup there, including VM,
> signal, stack used for stack switch, etc. But the TSS is not fully setup.
> I mean the registers like %eip to indicate the code for process 0.
> 
> I maybe dumb to ask this. But a little hint may help me out.  Thanks.

In effect, a "kernel process" is like an NFS nfsiod.  It's the
equivalent of a system call that never returns, instead looping
in code in the kernel and only going away when it has to go to
sleep for some reason.

Because this is the case, it runs on the kernel stack and instruction
pointer, and therefore never needs to run on a user stack and
instruction pointer.

In practice, you should be able to call the exec code (not the system
call implementation, since a failure would attempt to return to a
non-existant user space) and create a user space process out of
nothing.

This is basically how the /sbin/init gets started from the kernel.


Kernel processes are used for doing things in the kernel that
require a process context, such as calling tsleep() in order to
wait until a page has been read off of disk.


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



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