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
*
......@@ -321,7 +321,7 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS,
Capability *initialCapability )
{
StgTSO *t;
Capability *cap = initialCapability;
Capability *cap;
StgThreadReturnCode ret;
#if defined(GRAN)
rtsEvent *event;
......@@ -339,6 +339,8 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS,
StgTSOWhatNext prev_what_next;
// Pre-condition: sched_mutex is held.
// We might have a capability, passed in as initialCapability.
cap = initialCapability;
#if defined(RTS_SUPPORTS_THREADS)
//
......@@ -441,48 +443,36 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS,
prev = &main_threads;
for (m = main_threads; m != NULL; prev = &m->link, m = m->link) {
if (m->tso->what_next == ThreadComplete
|| m->tso->what_next == ThreadKilled)
{
if (m == mainThread)
{
if (m->tso->what_next == ThreadComplete)
{
if (m->ret)
{
// NOTE: return val is tso->sp[1] (see StgStartup.hc)
|| m->tso->what_next == ThreadKilled) {
if (m == mainThread) {
if (m->tso->what_next == ThreadComplete) {
if (m->ret) {
// NOTE: return val is tso->sp[1]
// (see StgStartup.hc)
*(m->ret) = (StgClosure *)m->tso->sp[1];
}
m->stat = Success;
}
else
{
if (m->ret)
{
} else {
if (m->ret) {
*(m->ret) = NULL;
}
if (was_interrupted)
{
if (was_interrupted) {
m->stat = Interrupted;
}
else
{
} else {
m->stat = Killed;
}
}
*prev = m->link;
#ifdef DEBUG
removeThreadLabel((StgWord)m->tso->id);
#endif
releaseCapability(cap);
return;
}
else
{
} else {
// The current OS thread can not handle the fact that
// the Haskell thread "m" has ended. "m" is bound;
// the scheduler loop in it's bound OS thread has to
// return, so let's pass our capability directly to
// the scheduler loop in its bound OS thread has to
// return, so let's pass the capability directly to
// that thread.
passCapability(&m->bound_thread_cond);
continue;
......@@ -536,10 +526,11 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS,
}
#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
* can wait indefinitely for something to happen.
*/
//
// Check whether any waiting threads need to be woken up. If the
// 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 defined(RTS_SUPPORTS_THREADS)
|| EMPTY_RUN_QUEUE()
......@@ -548,7 +539,7 @@ schedule( StgMainThread *mainThread USED_WHEN_RTS_SUPPORTS_THREADS,
{
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;
/*
......
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