rthreads and wait

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

rthreads and wait

Ted Unangst-2
rthreads don't quite work with wait because the children end up scattered
into various lists.  this attempts to keep the various parent and sibling
relationships correct between processes.  it needs testing, even on non
rthread kernels.

Index: kern_exit.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_exit.c,v
retrieving revision 1.58
diff -u -r1.58 kern_exit.c
--- kern_exit.c 13 Dec 2005 07:38:40 -0000 1.58
+++ kern_exit.c 5 Jan 2006 04:12:56 -0000
@@ -463,6 +463,8 @@
  struct proc *p, *t;
  int status, error;
 
+ q = q->p_thrparent;
+
  if (SCARG(uap, pid) == 0)
  SCARG(uap, pid) = -q->p_pgid;
  if (SCARG(uap, options) &~ (WUNTRACED|WNOHANG|WALTSIG|WCONTINUED))
Index: kern_fork.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_fork.c,v
retrieving revision 1.81
diff -u -r1.81 kern_fork.c
--- kern_fork.c 22 Dec 2005 06:55:03 -0000 1.81
+++ kern_fork.c 5 Jan 2006 04:12:56 -0000
@@ -279,18 +279,19 @@
  if (flags & FORK_PPWAIT)
  p2->p_flag |= P_PPWAIT;
  LIST_INSERT_AFTER(p1, p2, p_pglist);
- p2->p_pptr = p1;
  if (flags & FORK_NOZOMBIE)
  p2->p_flag |= P_NOZOMBIE;
- LIST_INSERT_HEAD(&p1->p_children, p2, p_sibling);
+ LIST_INSERT_HEAD(&p1->p_thrparent->p_children, p2, p_sibling);
  LIST_INIT(&p2->p_children);
 
  if (flags & FORK_THREAD) {
  p2->p_flag |= P_THREAD;
  p2->p_thrparent = p1->p_thrparent;
+ p2->p_pptr = p1->p_thrparent->p_pptr;
  LIST_INSERT_HEAD(&p1->p_thrparent->p_thrchildren, p2, p_thrsib);
  } else {
  p2->p_thrparent = p2;
+ p2->p_pptr = p1->p_thrparent;
  }
 
  LIST_INIT(&p2->p_thrchildren);

--
die energie aus fleisch und blut        deine sprache und die ganze wut
deine gefuehle die du lebst             und dein herz fuehl wie es bebt
zeitbombe! sie tickt in dir    zeitbombe! sie explodiert in deinem kopf
                                                    - girls under glass

Reply | Threaded
Open this post in threaded view
|

Re: rthreads and wait

Ted Unangst-2
patch is broken, don't use.

On 1/4/06, Ted Unangst <[hidden email]> wrote:

> rthreads don't quite work with wait because the children end up scattered
> into various lists.  this attempts to keep the various parent and sibling
> relationships correct between processes.  it needs testing, even on non
> rthread kernels.
>
> Index: kern_exit.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/kern_exit.c,v
> retrieving revision 1.58
> diff -u -r1.58 kern_exit.c
> --- kern_exit.c 13 Dec 2005 07:38:40 -0000      1.58
> +++ kern_exit.c 5 Jan 2006 04:12:56 -0000
> @@ -463,6 +463,8 @@
>        struct proc *p, *t;
>        int status, error;
>
> +       q = q->p_thrparent;
> +
>        if (SCARG(uap, pid) == 0)
>                SCARG(uap, pid) = -q->p_pgid;
>        if (SCARG(uap, options) &~ (WUNTRACED|WNOHANG|WALTSIG|WCONTINUED))
> Index: kern_fork.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/kern_fork.c,v
> retrieving revision 1.81
> diff -u -r1.81 kern_fork.c
> --- kern_fork.c 22 Dec 2005 06:55:03 -0000      1.81
> +++ kern_fork.c 5 Jan 2006 04:12:56 -0000
> @@ -279,18 +279,19 @@
>        if (flags & FORK_PPWAIT)
>                p2->p_flag |= P_PPWAIT;
>        LIST_INSERT_AFTER(p1, p2, p_pglist);
> -       p2->p_pptr = p1;
>        if (flags & FORK_NOZOMBIE)
>                p2->p_flag |= P_NOZOMBIE;
> -       LIST_INSERT_HEAD(&p1->p_children, p2, p_sibling);
> +       LIST_INSERT_HEAD(&p1->p_thrparent->p_children, p2, p_sibling);
>        LIST_INIT(&p2->p_children);
>
>        if (flags & FORK_THREAD) {
>                p2->p_flag |= P_THREAD;
>                p2->p_thrparent = p1->p_thrparent;
> +               p2->p_pptr = p1->p_thrparent->p_pptr;
>                LIST_INSERT_HEAD(&p1->p_thrparent->p_thrchildren, p2, p_thrsib);
>        } else {
>                p2->p_thrparent = p2;
> +               p2->p_pptr = p1->p_thrparent;
>        }
>
>        LIST_INIT(&p2->p_thrchildren);
>
> --
> die energie aus fleisch und blut        deine sprache und die ganze wut
> deine gefuehle die du lebst             und dein herz fuehl wie es bebt
> zeitbombe! sie tickt in dir    zeitbombe! sie explodiert in deinem kopf
>                                                    - girls under glass