summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2011-08-03 13:41:33 +0100
committerSimon Marlow <marlowsd@gmail.com>2011-08-05 09:21:49 +0100
commit78e6b615329dd8ea4527b499107048693c87f895 (patch)
treeb3fa7cd7268087bcfe342a19145661390d35ab2c
parentaf0a6aae3cc6ccc13319a9fbe0076e65374e9fe7 (diff)
downloadhaskell-78e6b615329dd8ea4527b499107048693c87f895.tar.gz
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.
-rw-r--r--rts/Capability.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/rts/Capability.c b/rts/Capability.c
index 91c5e2d98e..57c75e6875 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