[commit: ghc] master: small optimisation for the program in #5367: if the worker thread (78e6b61)
Simon Marlow
marlowsd at gmail.com
Fri Aug 5 10:21:59 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/78e6b615329dd8ea4527b499107048693c87f895
>---------------------------------------------------------------
commit 78e6b615329dd8ea4527b499107048693c87f895
Author: Simon Marlow <marlowsd at gmail.com>
Date: Wed Aug 3 13:41:33 2011 +0100
small optimisation for the program in #5367: if the worker thread
being woken already has its wakeup flag set, don't bother signalling
its condition variable again.
>---------------------------------------------------------------
rts/Capability.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/rts/Capability.c b/rts/Capability.c
index 91c5e2d..57c75e6 100644
--- a/rts/Capability.c
+++ b/rts/Capability.c
@@ -366,11 +366,13 @@ giveCapabilityToTask (Capability *cap USED_IF_DEBUG, Task *task)
cap->no, task->incall->tso ? "bound task" : "worker",
(void *)task->id);
ACQUIRE_LOCK(&task->lock);
- task->wakeup = rtsTrue;
- // the wakeup flag is needed because signalCondition() doesn't
- // flag the condition if the thread is already runniing, but we want
- // it to be sticky.
- signalCondition(&task->cond);
+ if (task->wakeup == rtsFalse) {
+ task->wakeup = rtsTrue;
+ // the wakeup flag is needed because signalCondition() doesn't
+ // flag the condition if the thread is already runniing, but we want
+ // it to be sticky.
+ signalCondition(&task->cond);
+ }
RELEASE_LOCK(&task->lock);
}
#endif
More information about the Cvs-ghc
mailing list