lkml.org 
[lkml]   [2003]   [Dec]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] kthread_create
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



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

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