Commit e42cc9fb authored by simonmar's avatar simonmar
Browse files

[project @ 2004-02-27 16:16:31 by simonmar]

cosmetic only
parent d262f6f5
/* --------------------------------------------------------------------------- /* ---------------------------------------------------------------------------
* $Id: Schedule.c,v 1.191 2004/02/27 15:58:54 simonmar Exp $ * $Id: Schedule.c,v 1.192 2004/02/27 16:16:31 simonmar Exp $
* *
* (c) The GHC Team, 1998-2003 * (c) The GHC Team, 1998-2003
* *
...@@ -321,7 +321,7 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS, ...@@ -321,7 +321,7 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS,
Capability *initialCapability ) Capability *initialCapability )
{ {
StgTSO *t; StgTSO *t;
Capability *cap = initialCapability; Capability *cap;
StgThreadReturnCode ret; StgThreadReturnCode ret;
#if defined(GRAN) #if defined(GRAN)
rtsEvent *event; rtsEvent *event;
...@@ -339,7 +339,9 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS, ...@@ -339,7 +339,9 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS,
StgTSOWhatNext prev_what_next; StgTSOWhatNext prev_what_next;
// Pre-condition: sched_mutex is held. // Pre-condition: sched_mutex is held.
// We might have a capability, passed in as initialCapability.
cap = initialCapability;
#if defined(RTS_SUPPORTS_THREADS) #if defined(RTS_SUPPORTS_THREADS)
// //
// in the threaded case, the capability is either passed in via the // in the threaded case, the capability is either passed in via the
...@@ -440,54 +442,42 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS, ...@@ -440,54 +442,42 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS,
StgMainThread *m, **prev; StgMainThread *m, **prev;
prev = &main_threads; prev = &main_threads;
for (m = main_threads; m != NULL; prev = &m->link, m = m->link) { for (m = main_threads; m != NULL; prev = &m->link, m = m->link) {
if (m->tso->what_next == ThreadComplete if (m->tso->what_next == ThreadComplete
|| m->tso->what_next == ThreadKilled) || m->tso->what_next == ThreadKilled) {
{ if (m == mainThread) {
if (m == mainThread) if (m->tso->what_next == ThreadComplete) {
{ if (m->ret) {
if (m->tso->what_next == ThreadComplete) // NOTE: return val is tso->sp[1]
{ // (see StgStartup.hc)
if (m->ret) *(m->ret) = (StgClosure *)m->tso->sp[1];
{ }
// NOTE: return val is tso->sp[1] (see StgStartup.hc) m->stat = Success;
*(m->ret) = (StgClosure *)m->tso->sp[1]; } else {
} if (m->ret) {
m->stat = Success; *(m->ret) = NULL;
} }
else if (was_interrupted) {
{ m->stat = Interrupted;
if (m->ret) } else {
{ m->stat = Killed;
*(m->ret) = NULL; }
} }
if (was_interrupted) *prev = m->link;
{
m->stat = Interrupted;
}
else
{
m->stat = Killed;
}
}
*prev = m->link;
#ifdef DEBUG #ifdef DEBUG
removeThreadLabel((StgWord)m->tso->id); removeThreadLabel((StgWord)m->tso->id);
#endif #endif
releaseCapability(cap); releaseCapability(cap);
return; return;
} } else {
else // The current OS thread can not handle the fact that
{ // the Haskell thread "m" has ended. "m" is bound;
// The current OS thread can not handle the fact that // the scheduler loop in its bound OS thread has to
// the Haskell thread "m" has ended. "m" is bound; // return, so let's pass the capability directly to
// the scheduler loop in it's bound OS thread has to // that thread.
// return, so let's pass our capability directly to passCapability(&m->bound_thread_cond);
// that thread. continue;
passCapability(&m->bound_thread_cond); }
continue; }
}
}
} }
} }
...@@ -536,19 +526,20 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS, ...@@ -536,19 +526,20 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS,
} }
#endif #endif
/* Check whether any waiting threads need to be woken up. If the //
* run queue is empty, and there are no other tasks running, we // Check whether any waiting threads need to be woken up. If the
* can wait indefinitely for something to happen. // run queue is empty, and there are no other tasks running, we
*/ // can wait indefinitely for something to happen.
if ( !EMPTY_QUEUE(blocked_queue_hd) || !EMPTY_QUEUE(sleeping_queue) //
if ( !EMPTY_QUEUE(blocked_queue_hd) || !EMPTY_QUEUE(sleeping_queue)
#if defined(RTS_SUPPORTS_THREADS) #if defined(RTS_SUPPORTS_THREADS)
|| EMPTY_RUN_QUEUE() || EMPTY_RUN_QUEUE()
#endif #endif
) )
{ {
awaitEvent( EMPTY_RUN_QUEUE() ); awaitEvent( EMPTY_RUN_QUEUE() );
} }
/* we can be interrupted while waiting for I/O... */ // we can be interrupted while waiting for I/O...
if (interrupted) continue; if (interrupted) continue;
/* /*
...@@ -635,7 +626,7 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS, ...@@ -635,7 +626,7 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS,
#if defined(RTS_SUPPORTS_THREADS) #if defined(RTS_SUPPORTS_THREADS)
if ( EMPTY_RUN_QUEUE() ) { if ( EMPTY_RUN_QUEUE() ) {
continue; // nothing to do continue; // nothing to do
} }
#endif #endif
......
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