public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wait4() WIFSTOPPED starvation fix #2/2
@ 2002-03-15 21:09 David Howells
  0 siblings, 0 replies; only message in thread
From: David Howells @ 2002-03-15 21:09 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, mingo


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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-03-15 21:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-15 21:09 [PATCH] wait4() WIFSTOPPED starvation fix #2/2 David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox