In article <
d0ef790d-27c9-495a...@st3g2000pbc.googlegroups.com>,
You would first have to ensure the RT scheduling class is loaded
into the kernel (easiest way would be to momentarily run something
in the RT class, which will auto-load it). Then assign a RT pri
when creating the thread.
> If the kernel module that created it is killed, will the thread die
> automatically?
Kernel modules can't be killed. The kernel may ask a module to
unload (due to modunload(1M) command, or pressure on kernel memory)
but the module gets to say yes or no. If a module allows itself to
be unloaded whilst there are still threads accessing its code or data,
the kernel will panic/crash. A module would need to keep a record of
the threads it has started, and if it wants to unload, it would need
to ask them to exit and wait for them to do so before allowing itself
to unload. (It wasn't until sometime around Solaris 10 that a method
was provided to do this, so before that, modules that started up new
kernel threads could never unload as there was no safe way for them
to ensure those threads had terminated.)
I would suggest that instead of doing all this, you write a pseudo
driver (and not a STREAMS driver), and that you get the driver to run
a realtime thread by creating a realtime process which calls into
the driver with an ioctl, which will then be a realtime thread
running in your kernel code. You are then using all the standard
public kernel interfaces. I suggest you make sure your driver allows
the process to be killed, and allows itself to be unloaded - this
saves very many reboots during kernel module development, and
provides a clean way to shutdown your thread(s).
This is the way things like nfsd work - a tiny user process calls into
the kernel to create the kernel threads, and all the work is done
in those kernel threads after that, and the user process just hangs
around so it can be killed in order to shutdown those kernel threads.
BTW, why do you want a RT kernel thread? I would have to say that
mostly, the people who think they need to use RT are misguided.
> thanks
> -kamal