Patch: CLONE_PPID (was kernel thread support - LWP's)

Tim Hockin (thockin@isunix.it.ilstu.edu)
Sat, 17 Jul 1999 18:43:37 -0500 (CDT)


Here is the first patch I threw together for CLONE_PPID support. This is
against 2.2.10.

Concept: a child should be able to create siblings (children of its
parent) if the parent lets it.

clone() now has two new flags:
CLONE_PPIDOK : resulting child may create siblings
CLONE_PPID : resulting child should be a sibling

PF_FLAGS has a new entry PF_PPIDOK, which is set by CLONE_PPIDOK

Oustanding issues:

* Parent should be notified when a child makes a new sibling - SIGNEWCHLD ?
* What of p_cptr, p_ysptr, p_osptr is task_struct - where are they dealt
with?
* If a task requests CLONE_PPID but does not have PF_PPIDOK - should we
fail clone() or silently ignore CLONE_PPID

Tim

diff -ruN clean-linux-2.2.10/include/linux/sched.h clone-linux-2.2.10/include/linux/sched.h
--- clean-linux-2.2.10/include/linux/sched.h Tue May 11 10:35:45 1999
+++ clone-linux-2.2.10/include/linux/sched.h Sat Jul 17 16:18:14 1999
@@ -34,6 +34,8 @@
#define CLONE_PID 0x00001000 /* set if pid shared */
#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing continue on the child too */
#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */
+#define CLONE_PPIDOK 0x00008000 /* set if the child should be able to create siblings */
+#define CLONE_PPID 0x00010000 /* set if we want to create a sibling, not a child */

/*
* These are the constant used to fake the fixed-point load-average
@@ -332,6 +334,7 @@

#define PF_USEDFPU 0x00100000 /* task used FPU this quantum (SMP) */
#define PF_DTRACE 0x00200000 /* delayed trace (used on m68k, i386) */
+#define PF_PPIDOK 0x00400000 /* task is allowed to use CLONE_PPID */

/*
* Limit the stack by to some sane default: root can always
diff -ruN clean-linux-2.2.10/kernel/fork.c clone-linux-2.2.10/kernel/fork.c
--- clean-linux-2.2.10/kernel/fork.c Mon Apr 12 12:44:26 1999
+++ clone-linux-2.2.10/kernel/fork.c Sat Jul 17 16:03:59 1999
@@ -523,6 +523,8 @@
new_flags &= ~(PF_PTRACED|PF_TRACESYS);
if (clone_flags & CLONE_VFORK)
new_flags |= PF_VFORK;
+ if (clone_flags & CLONE_PPIDOK)
+ new_flags |= PF_PPIDOK;
p->flags = new_flags;
}

@@ -587,7 +589,10 @@
p->next_run = p;
p->prev_run = p;

- p->p_pptr = p->p_opptr = current;
+ if (!(clone_flags & CLONE_PPID) || !(current->flags & PF_PPIDOK))
+ p->p_pptr = p->p_opptr = current;
+ else
+ p->p_pptr = p->p_opptr = current->p_opptr;
p->p_cptr = NULL;
init_waitqueue(&p->wait_chldexit);
p->vfork_sem = NULL;

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