diff options
author | Simon Marlow <marlowsd@gmail.com> | 2008-11-14 12:10:22 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2008-11-14 12:10:22 +0000 |
commit | 58852522d1ba4fb647bf2e0a67745a808a7da0c6 (patch) | |
tree | a66a34b4ae595580f0ed3dc57b507e2e9b7a6f90 /rts/Capability.c | |
parent | a6e1fda4156b26666b04d901742ed3bb295cf4dd (diff) | |
download | haskell-58852522d1ba4fb647bf2e0a67745a808a7da0c6.tar.gz |
don't run sparks if there are other threads on this Capability
Diffstat (limited to 'rts/Capability.c')
-rw-r--r-- | rts/Capability.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/rts/Capability.c b/rts/Capability.c index 27a2d51eb4..8dddbc5d34 100644 --- a/rts/Capability.c +++ b/rts/Capability.c @@ -57,15 +57,18 @@ globalWorkToDo (void) StgClosure * findSpark (Capability *cap) { - /* use the normal Sparks.h interface (internally modified to enable - concurrent stealing) - and immediately turn the spark into a thread when successful - */ Capability *robbed; StgClosurePtr spark; rtsBool retry; nat i = 0; + if (!emptyRunQueue(cap)) { + // If there are other threads, don't try to run any new + // sparks: sparks might be speculative, we don't want to take + // resources away from the main computation. + return 0; + } + // first try to get a spark from our own pool. // We should be using reclaimSpark(), because it works without // needing any atomic instructions: |