Commit 84a29fdd authored by simonmar's avatar simonmar
Browse files

[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.
parent e9f0f9d7
/* ---------------------------------------------------------------------------
* $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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment