Re: [PATCH 1/2] kthread_create

Davide Libenzi
2004-01-05T05:06:12Z

On Mon, 5 Jan 2004, Rusty Russell wrote:

> In message <Pine.LNX.4.44.0401041501510.12666-100000@bigblue.dev.mdolabs.com> 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