Re: [PATCH 1/2] kthread_create

From: Davide Libenzi
Date: Mon Jan 05 2004 - 00:07:58 EST


On Mon, 5 Jan 2004, Rusty Russell wrote:

> In message <Pine.LNX.4.44.0401041501510.12666-100000@xxxxxxxxxxxxxxxxxxxxxxx> you write:
> > I can see two options:
> >
> > 1) We do not allow do_exit() from kthreads
> >
> > 2) We give kthread_exit()
> >
> > What do you think?
>
> Well, I've now got a patch which works without any global
> datastructures, but still allows the same semantics. Includes some
> fixes in the previous code, and test code.
>
> Also includes a longstanding fix in workqueue.c: we never get SIGCHLD
> if signal handler is SIG_IGN.
>
> I'm not sure it's neater, though. We don't have WIFEXITED() in the
> kernel, so lots of manual shifting, probably should add that
> somewhere.
>
> Thoughts?

Honestly I do not like playing with SIGCLD/waitpid for things that do not
concern real task exits. But I think it can be avoided, and actually I
don't know why I did not think about this before. We don't need to return
a struct task_struct* for kthread_create(). We can have:

struct kthread_struct {
struct task_struct *tsk;
int ret;
struct semaphore ack; /* Or completion if you like */
};

This structure is allocated in kthread_create() and propagated to the
kthread() void* data. Then they (the creator and the kthread) will have a
common ground to exchange acks w/out playing with SIGCLD/waitpid. Heh ?



- 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/