X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FSelect.c;h=26870641bc02539b97e1f39d6107de2b16efce0a;hb=f7db2c30a659aae5fe59ba2be7ab72f8ca64f712;hp=da0e12469fbbb9b0e7c21c060a34048e025c515a;hpb=47e6674f14f0b414bbb3f37ffff8749302e0f4b2;p=ghc-hetmet.git diff --git a/ghc/rts/Select.c b/ghc/rts/Select.c index da0e124..2687064 100644 --- a/ghc/rts/Select.c +++ b/ghc/rts/Select.c @@ -1,5 +1,4 @@ /* ----------------------------------------------------------------------------- - * $Id: Select.c,v 1.27 2003/03/29 00:00:41 sof Exp $ * * (c) The GHC Team 1995-2002 * @@ -31,6 +30,10 @@ #include #include +#ifdef HAVE_UNISTD_H +#include +#endif + /* last timestamp */ nat timestamp = 0; @@ -64,7 +67,7 @@ wakeUpSleepingThreads(nat ticks) sleeping_queue = tso->link; tso->why_blocked = NotBlocked; tso->link = END_TSO_QUEUE; - IF_DEBUG(scheduler,belch("Waking up sleeping thread %d\n", tso->id)); + IF_DEBUG(scheduler,debugBelch("Waking up sleeping thread %d\n", tso->id)); PUSH_ON_RUN_QUEUE(tso); flag = rtsTrue; } @@ -101,11 +104,11 @@ awaitEvent(rtsBool wait) tv.tv_usec = 0; IF_DEBUG(scheduler, - belch("scheduler: checking for threads blocked on I/O"); + debugBelch("scheduler: checking for threads blocked on I/O"); if (wait) { - belch(" (waiting)"); + debugBelch(" (waiting)"); } - belch("\n"); + debugBelch("\n"); ); /* loop until we've woken up some threads. This loop is needed @@ -216,8 +219,6 @@ awaitEvent(rtsBool wait) unblock_all = rtsTrue; break; } else { - fprintf(stderr,"%d\n", errno); - fflush(stderr); perror("select"); barf("select failed"); } @@ -232,12 +233,14 @@ awaitEvent(rtsBool wait) * we could block for a long time before the signal is * serviced. */ +#if defined(RTS_USER_SIGNALS) if (signals_pending()) { RELEASE_LOCK(&sched_mutex); /* ToDo: kill */ startSignalHandlers(); ACQUIRE_LOCK(&sched_mutex); return; /* still hold the lock */ } +#endif /* we were interrupted, return to the scheduler immediately. */ @@ -293,7 +296,7 @@ awaitEvent(rtsBool wait) } if (ready) { - IF_DEBUG(scheduler,belch("Waking up blocked thread %d\n", tso->id)); + IF_DEBUG(scheduler,debugBelch("Waking up blocked thread %d\n", tso->id)); tso->why_blocked = NotBlocked; tso->link = END_TSO_QUEUE; PUSH_ON_RUN_QUEUE(tso); @@ -345,4 +348,20 @@ wakeBlockedWorkerThread() workerWakeupPending = rtsTrue; } } + +/* resetWorkerWakeupPipeAfterFork + * + * To be called right after a fork(). + * After the fork(), the worker wakeup pipe will be shared + * with the parent process, and that's something we don't want. + */ +void +resetWorkerWakeupPipeAfterFork() +{ + if(workerWakeupInited) { + close(workerWakeupPipe[0]); + close(workerWakeupPipe[1]); + } + workerWakeupInited = rtsFalse; +} #endif