Messages in this thread | | | From | Rusty Russell <> | Subject | Re: [PATCH] Add module_kernel_thread for threads that live in modules. | Date | Mon, 16 Jun 2003 16:50:33 +1000 |
| |
Hi Neil,
There are several problems with this patch. Ignoring the fact that you use __module_get. Firstly, you bump the module count permentantly while the thread is running: how does it ever get unloaded? Secondly, modprobe becomes your parent.
There have been ambitious attempts to do a nice "thread creation and stopping" interface before. Given the delicate logic involved in shutting threads down, I think this makes sense. Maybe something like:
/* Struct which identifies a kernel thread, handed to creator and thread. */ struct kthread { int pid; int should_die; /* Thread should exit when this is set. */
/* User supplied arg... */ void *arg; };
struct kthread *create_thread(int (*fn)(struct kthread*), void *arg, unsigned long flags, const char *namefmt, ...); void cleanup_thread(struct kthread *);
create_thread would use keventd to start the thread, and stop_thread would tell keventd to set should_die, wmb(), wake it up, and sys_wait() for it.
Thoughts? Rusty. -- Anyone who quotes me in their sig is an idiot. -- Rusty Russell. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |