[lkml]   [1998]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subject[Q] Creating multiple threads from a module? zombies?


I'm stuck with a problem I don't know how to solve ... if any
kernel guru is so kind? :)

The USB module, when loaded, spawns a thread. This thread sits
there idle doing nothing until it's told to poll a hub or listen to
changes from it. I have no problem creating this thread with
kernel_thread(,,CLONE_FS|CLONE_FILES|CLONE_SIGHAND). Easy. When the
module unloads it exits ok, etc ...

BUT when that thread detects a change in a hub, it spawns yet
another thread which will handle those changes. No problem calling
kernel_thread(,,0), but when the function exits the thread goes

Attending to what the docs on kernel_thread() say at

* This is the mechanism for creating a new kernel thread.
* NOTE! Only a kernel-only process(ie the swapper or direct descendants
* who haven't done an "execve()") should use this: it will work within
* a system call from a "real" process, but the process memory space will
* not be free'd until both the parent and the child have exited.
static inline pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
long retval;

__asm__ __volatile__(
"movl %%esp,%%esi\n\t"
"int $0x80\n\t" /* Linux/i386 system call */

It clearly seems I'm doing the second thing (call form a
"real" process within a syscall), so it even sounds logical what's

My question is: is there anyway to get rid of the zombies?
(when polling, the thread is created each three seconds to do the
polling, and that's a lot of zombie processes to care about).

Or better, what am I doing wrong? I used kernel_thread()
because I need to share the memory spaces ...

TIA! :)


Linux-USB! -
Inaky Perez Gonzalez -- PGP pubkey fingerprint - -- 8E 34 3A 62 64 99 E2 44 - -- AD 7B 30 D9 DD FF 3E 4C -
--------------------------------- -- ----------------------- -
The loneliness of the long distance runner .....

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

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