[PATCH] wait4() WIFSTOPPED starvation fix #2/2

From: David Howells (dhowells@redhat.com)
Date: Fri Mar 15 2002 - 16:09:26 EST


Hi Linus,

This patch actually fixes the starvation bug in sys_wait4() by moving any
process which is serviced for stoppage to the end of the child list.

David

diff -uNr linux-256p1/kernel/exit.c-orig linux-wait-256p1/kernel/exit.c
--- linux-wait-256p1/kernel/exit.c-orig Fri Mar 15 19:05:47 2002
+++ linux-wait-256p1/kernel/exit.c Fri Mar 15 20:54:40 2002
@@ -592,6 +592,12 @@
                                 if (!(options & WUNTRACED) && !(p->ptrace & PT_PTRACED))
                                         continue;
                                 read_unlock(&tasklist_lock);
+
+ /* move to end of parent's list to avoid starvation */
+ write_lock_irq(&tasklist_lock);
+ list_del(&p->sibling);
+ list_add_tail(&p->sibling,&p->parent->children);
+ write_unlock_irq(&tasklist_lock);
                                 retval = ru ? getrusage(p, RUSAGE_BOTH, ru) : 0;
                                 if (!retval && stat_addr)
                                         retval = put_user((p->exit_code << 8) | 0x7f, stat_addr);
-
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/



This archive was generated by hypermail 2b29 : Fri Mar 15 2002 - 22:00:21 EST