From: Julian Seward Date: Sat, 12 Mar 2005 15:16:31 +0000 (+0000) Subject: Fix yielding properly. X-Git-Tag: svn/VALGRIND_3_0_0~1017 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f03dd1e3856f99a9ffeb2f3da290c7fba1589496;p=thirdparty%2Fvalgrind.git Fix yielding properly. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3301 --- diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c index 4d5a71bf10..debf2cd2dc 100644 --- a/coregrind/vg_scheduler.c +++ b/coregrind/vg_scheduler.c @@ -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: