diff options
author | Simon Marlow <marlowsd@gmail.com> | 2011-08-03 13:41:33 +0100 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2011-08-05 09:21:49 +0100 |
commit | 78e6b615329dd8ea4527b499107048693c87f895 (patch) | |
tree | b3fa7cd7268087bcfe342a19145661390d35ab2c /rts/Capability.c | |
parent | af0a6aae3cc6ccc13319a9fbe0076e65374e9fe7 (diff) | |
download | haskell-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.
Diffstat (limited to 'rts/Capability.c')
-rw-r--r-- | rts/Capability.c | 12 |
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 |