2002-06-22 10:36:55

by Thunder from the hill

[permalink] [raw]
Subject: [Q] change_parent() - would this work?

Hi,

My question is: would this work?

Index: thunder-2.5/include/linux/sched.h
===================================================================
RCS file: thunder-2.5/include/linux/sched.h,v
retrieving revision 1.2
diff -u -r1.2 thunder-2.5/include/linux/sched.h
--- thunder-2.5/include/linux/sched.h 22 Jun 2002 01:51:33 -0000 1.2
+++ thunder-2.5/include/linux/sched.h 22 Jun 2002 10:33:57 -0000
@@ -716,6 +716,7 @@

#define remove_parent(p) list_del_init(&(p)->sibling)
#define add_parent(p, parent) list_add_tail(&(p)->sibling,&(parent)->children)
+#define change_parent(p) list_move_tail(&(p)->sibling,&(parent)->children)

#define REMOVE_LINKS(p) do { \
list_del_init(&(p)->tasks); \
Index: thunder-2.5/kernel/exit.c
===================================================================
RCS file: thunder-2.5/kernel/exit.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 thunder-2.5/kernel/exit.c
--- thunder-2.5/kernel/exit.c 20 Jun 2002 22:53:49 -0000 1.1.1.1
+++ thunder-2.5/kernel/exit.c 22 Jun 2002 10:33:57 -0000
@@ -636,8 +636,7 @@

/* move to end of parent's list to avoid starvation */
write_lock_irq(&tasklist_lock);
- remove_parent(p);
- add_parent(p, p->parent);
+ change_parent(p, p->parent);
write_unlock_irq(&tasklist_lock);
retval = ru ? getrusage(p, RUSAGE_BOTH, ru) : 0;
if (!retval && stat_addr)

Regards,
Thunder
--
"You must cut down the mighties tree in the forest with - a herring!"
-- chief of the knights who to
recently said "NIH"


2002-06-25 09:24:28

by Brad Heilbrun

[permalink] [raw]
Subject: Re: [Q] change_parent() - would this work?

On Sat, Jun 22, 2002 at 04:36:53AM -0600, Thunder from the hill wrote:
> Hi,
>
> My question is: would this work?

I don't believe so...

> +#define change_parent(p) list_move_tail(&(p)->sibling,&(parent)->children)

On the above line change_parent takes one argument.

> + change_parent(p, p->parent);

Here, it takes two.

Otherwise it looks good, and removes a couple of assignments. Not sure
how useful it is though, is this done a lot?

--
Brad Heilbrun