From owner-freebsd-hackers Mon Nov 23 11:53:19 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA08547 for freebsd-hackers-outgoing; Mon, 23 Nov 1998 11:53:19 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from smtp02.primenet.com (smtp02.primenet.com [206.165.6.132]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id LAA08537 for ; Mon, 23 Nov 1998 11:53:09 -0800 (PST) (envelope-from tlambert@usr02.primenet.com) Received: (from daemon@localhost) by smtp02.primenet.com (8.8.8/8.8.8) id MAA18759; Mon, 23 Nov 1998 12:53:06 -0700 (MST) Received: from usr02.primenet.com(206.165.6.202) via SMTP by smtp02.primenet.com, id smtpd018726; Mon Nov 23 12:53:02 1998 Received: (from tlambert@localhost) by usr02.primenet.com (8.8.5/8.8.5) id MAA25806; Mon, 23 Nov 1998 12:52:58 -0700 (MST) From: Terry Lambert Message-Id: <199811231952.MAA25806@usr02.primenet.com> Subject: Re: Kernel threads To: andy@psn.ie (Andy Doran) Date: Mon, 23 Nov 1998 19:52:57 +0000 (GMT) Cc: freebsd-hackers@FreeBSD.ORG In-Reply-To: from "Andy Doran" at Nov 23, 98 06:44:36 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 > Hello all! > I'm porting the NetBSD RAIDframe driver to FreeBSD at the moment, and I > need a little help. Firstly, is there any way to dynamically create and > destroy kernel threads like kthreads in NetBSD? I could create them > statically but it would require a lot of changes to the code. Two other > things; it is possible to guarantee that a psuedo device is attached > only after all other psuedo devices? Also, do I have to modify the kernel > to guarantee that my device can do it's RAID array setup as soon as all > disklabels and partition tables have been read, or is there some sort > of hook for this? Kernel threads, or kernel processes? Do all the threads have the same pid, or do they have different pid's? If you look at the code in /sys/kern/init_main.c, you will see that it is relatively trivial to start kernel processes. If you need to make them go away, then you need to look at the code for the "exit" and/or "kill" system calls. At one point in time, I wrote a compressing VFS stacking layer that operated on a per file basis. It started a "helper" process to do the compression and decompression so as to "cache" an decompressed image for a while after it was no longer used before compressing it again (no, this code won't run in an unmodified FreeBSD because of the VFS stacking problems FreeBSD has). It starts the helper process, and, if load requires it, starts up several of them and shuts them down. I was actually thinking of doing nfsd and nfsiod like this at some point. So not only is it possible, it's relatively easy, and there's code to do it already in the kernel. 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