From: simonmar Date: Tue, 5 Feb 2002 10:06:24 +0000 (+0000) Subject: [project @ 2002-02-05 10:06:24 by simonmar] X-Git-Tag: Approximately_9120_patches~153 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=84a29fdd257e9647acd2e5af91ee37f817b93fcb;hp=e9f0f9d7bcfca13776e7aa465b7ab539a5dace73;p=ghc-hetmet.git [project @ 2002-02-05 10:06:24 by simonmar] Fix bad bugs in deleteAllThreds: we were looping through the thread queues calling deleteThread() on each thread as we go, but calling deleteThread() has the side effect of removing the thread from the relevant queue, so we would end up breaking out of the loop after processing only a single thread. This may fix problems like "resurrectThreads: thread blocked in a strange way" seen after pressing ^C. Aside: we really shouldn't be using deleteThread() at all, since it doesn't give the thread a chance to clean up & release locks. To be well-behaved a program has to catch ^C itself at the moment. --- diff --git a/ghc/rts/Schedule.c b/ghc/rts/Schedule.c index ab008fd..d5e6936 100644 --- a/ghc/rts/Schedule.c +++ b/ghc/rts/Schedule.c @@ -1,5 +1,5 @@ /* --------------------------------------------------------------------------- - * $Id: Schedule.c,v 1.116 2002/02/04 20:56:53 sof Exp $ + * $Id: Schedule.c,v 1.117 2002/02/05 10:06:24 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * @@ -1452,15 +1452,18 @@ schedule( void ) void deleteAllThreads ( void ) { - StgTSO* t; + StgTSO* t, *next; IF_DEBUG(scheduler,sched_belch("deleting all threads")); - for (t = run_queue_hd; t != END_TSO_QUEUE; t = t->link) { + for (t = run_queue_hd; t != END_TSO_QUEUE; t = next) { + next = t->link; deleteThread(t); } - for (t = blocked_queue_hd; t != END_TSO_QUEUE; t = t->link) { + for (t = blocked_queue_hd; t != END_TSO_QUEUE; t = next) { + next = t->link; deleteThread(t); } - for (t = sleeping_queue; t != END_TSO_QUEUE; t = t->link) { + for (t = sleeping_queue; t != END_TSO_QUEUE; t = next) { + next = t->link; deleteThread(t); } run_queue_hd = run_queue_tl = END_TSO_QUEUE;