lkml.org 
[lkml]   [2003]   [Jun]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] Add module_kernel_thread for threads that live in modules.
Date
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/

\
 
 \ /
  Last update: 2005-03-22 13:36    [W:0.057 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site