]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix yielding properly.
authorJulian Seward <jseward@acm.org>
Sat, 12 Mar 2005 15:16:31 +0000 (15:16 +0000)
committerJulian Seward <jseward@acm.org>
Sat, 12 Mar 2005 15:16:31 +0000 (15:16 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3301

coregrind/vg_scheduler.c

index 4d5a71bf1041bace0db1fcb19f430fba74c010e1..debf2cd2dc8f3d441a609a5aaac279f8b5618e76 100644 (file)
@@ -780,8 +780,14 @@ VgSchedReturnCode VG_(scheduler) ( ThreadId tid )
 
       case VEX_TRC_JMP_YIELD:
         /* Explicit yield, because this thread is in a spin-lock
-           or something.  Let another thread run ASAP. */
-        VG_(dispatch_ctr) = 1;
+           or something.  Only let the thread run for a short while
+            longer.  Because swapping to another thread is expensive,
+            we're prepared to let this thread eat a little more CPU
+            before swapping to another.  That means that short term
+            spins waiting for hardware to poke memory won't cause a
+            thread swap. */
+        if (VG_(dispatch_ctr) > 100) 
+            VG_(dispatch_ctr) = 100;
         break;
 
       case VG_TRC_INNER_COUNTERZERO: