From owner-freebsd-hackers Fri Feb 5 18:51:45 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id SAA14042 for freebsd-hackers-outgoing; Fri, 5 Feb 1999 18:51:45 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from smtp01.primenet.com (smtp01.primenet.com [206.165.6.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id SAA14037 for ; Fri, 5 Feb 1999 18:51:42 -0800 (PST) (envelope-from tlambert@usr02.primenet.com) Received: (from daemon@localhost) by smtp01.primenet.com (8.8.8/8.8.8) id TAA08958; Fri, 5 Feb 1999 19:51:41 -0700 (MST) Received: from usr02.primenet.com(206.165.6.202) via SMTP by smtp01.primenet.com, id smtpd008891; Fri Feb 5 19:51:39 1999 Received: (from tlambert@localhost) by usr02.primenet.com (8.8.5/8.8.5) id TAA28845; Fri, 5 Feb 1999 19:51:28 -0700 (MST) From: Terry Lambert Message-Id: <199902060251.TAA28845@usr02.primenet.com> Subject: Re: how process 0 becomes the swapper To: bf20761@binghamton.edu Date: Sat, 6 Feb 1999 02:51:28 +0000 (GMT) Cc: freebsd-hackers@FreeBSD.ORG In-Reply-To: from "zhihuizhang" at Feb 4, 99 12:23:52 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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