Date: Sun, 7 Feb 1999 15:15:37 -0500 (EST) From: zhihuizhang <bf20761@binghamton.edu> To: Terry Lambert <tlambert@primenet.com> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: how process 0 becomes the swapper Message-ID: <Pine.SOL.L3.93.990207143527.2915A-100000@bingsun2> In-Reply-To: <199902060251.TAA28845@usr02.primenet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 6 Feb 1999, Terry Lambert wrote: > > 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. > You email gives me another insight into the kernel process which I never think of. Thanks! It does not answer the question in my mind. I look at the source code again and consult the book by Maurice J. Bach (page 280). After some thought, I have come to the following conclusions: (1) Process 0 does not really exist in FreeBSD. It was the swapper somehow. But now proc0 acts only as a proc structure prototype used by fork(). The structure proc0 is never put onto the run queue (although it is put on the allproc queue). (2) The swapin is now done by scheduler() in vm_glue.c which never returns. It may sleep on the proc0 structure. This seems to be the only relation between process 0 and the swapper left from earlier Unix. (3) The swapout is driven by vm daemon. The main routine of it is vm_daemon(). Please comment on my conclusions. Thanks a lot. 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?Pine.SOL.L3.93.990207143527.2915A-100000>