Re: [PATCH 1/2] kthread_create

From: Davide Libenzi
Date: Sat Jan 03 2004 - 23:55:29 EST


On Sun, 4 Jan 2004, Rusty Russell wrote:

> In message <Pine.LNX.4.44.0401031021280.1678-100000@xxxxxxxxxxxxxxxxxxxxxxx> you write:
> > Rusty, I took a better look at the patch and I think we can have
> > per-kthread stuff w/out littering the task_struct and by making the thing
> > more robust.
>
> Except sharing data with a lock is perfectly robust.
>
> > We keep a global list_head protected by a global spinlock. We
> > define a structure that contain all the per-kthread stuff we need
> > (including a task_struct* to the kthread itself). When a kthread starts it
> > will add itself to the list, and when it will die it will remove itself
> > from the list.
>
> Yeah, I deliberately didn't implement this, because (1) it seems like
> a lot of complexity when using a lock and letting them share a single
> structure works fine and is even simpler, and (2) the thread can't
> just "do_exit()".
>
> You can get around (2) by having a permenant parent "kthread" thread
> which is a parent to all the kthreads (it'll get a SIGCHLD when
> someone does "do_exit()"). But the implementation was pretty ugly,
> since it involved having a communications mechanism with the kthread
> parent, which means you have the global ktm_message-like-thing for
> this...

You will lose in any case. What happens if the thread does do_exit() and
you do kthread_stop() after that?
With the patch I posted to you, the kthread_stop() will simply miss the
lookup and return -ENOENT.



- Davide


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/