Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Jan 2010 11:38:50 +0100
From:      Giovanni Trematerra <giovanni.trematerra@gmail.com>
To:        freebsd-arch@freebsd.org
Cc:        Attilio Rao <attilio@freebsd.org>
Subject:   kthread interface
Message-ID:  <4e6cba831001280238x6a86e9f8vf5b7858b4bb82178@mail.gmail.com>

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



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