Re: [PATCH 1/2] kthread_create

Davide Libenzi
2003-12-31T05:06:30Z

On Wed, 31 Dec 2003, Rusty Russell wrote:

> +struct kt_message
> +{
> + struct task_struct *from, *to;
> + void *info;
> +};
> +
> +static struct kt_message ktm;
> +
> +static void ktm_send(struct task_struct *to, void *info)
> +{
> + spin_lock(&ktm_lock);
> + ktm.to = to;
> + ktm.from = current;
> + ktm.info = info;
> + if (ktm.to)
> + wake_up_process(ktm.to);
> + spin_unlock(&ktm_lock);
> +}
> +
> +static struct kt_message ktm_receive(void)
> +{
> + struct kt_message m;
> +
> + for (;;) {
> + spin_lock(&ktm_lock);
> + if (ktm.to == current)
> + break;
> + current->state = TASK_INTERRUPTIBLE;
> + spin_unlock(&ktm_lock);
> + schedule();
> + }
> + m = ktm;
> + spin_unlock(&ktm_lock);
> + return m;
> +}

Wouldn't it be better to put a kt_message inside a tast_struct?

- Davide