Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Nov 1998 19:52:57 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        andy@psn.ie (Andy Doran)
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Kernel threads
Message-ID:  <199811231952.MAA25806@usr02.primenet.com>
In-Reply-To: <Pine.BSF.3.96.981123183648.291A-100000@gw.home> from "Andy Doran" at Nov 23, 98 06:44:36 pm

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



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