kthread interface

Giovanni Trematerra giovanni.trematerra at gmail.com
Thu Jan 28 11:03:31 UTC 2010


Hi all,
There is a race in kthread_exit when all the threads of a kernel
process exit at same time. I came up with a quick and dirty patch that
resolve the issue at least in my test case.

http://www.trematerra.net/patches/kthread_exit.diff

Nonetheless I see space for improvement into kthread interface.
At present, with kproc_kthread_add you could have a kernel process
without a main thread and that seems to me only a way to logical
grouping threads and pretty useless.
I propose to remove kproc_kthread_add and don't let kthread_exit call
kproc_exit on the last exiting thread but demand user to handle
process termination.
If you need kernel threads but no reason to have a kernel process with
a main thread that acts as a coordinator you can attach them to proc0
by kthread_add passing NULL for (struct proc *) argument.
I attached a patch to better show my proposal.

http://www.trematerra.net/patches/kproc_kthread_add.diff

Note: the two patches are mutually exclusive

Thanks for your attention.

--
Gianni


More information about the freebsd-arch mailing list