Permalink
Browse files

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.
  • Loading branch information...
1 parent af0a6aa commit 78e6b615329dd8ea4527b499107048693c87f895 @simonmar simonmar committed Aug 3, 2011
Showing with 7 additions and 5 deletions.
  1. +7 −5 rts/Capability.c
View
@@ -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

0 comments on commit 78e6b61

Please sign in to comment.