From: Julian Seward Date: Thu, 28 Oct 2004 09:51:12 +0000 (+0000) Subject: (Unsuccessfully) try and make the BB counter give the same X-Git-Tag: svn/VALGRIND_3_0_1^2~889 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1058d77d34d340256424d381cec22fa768556d2c;p=thirdparty%2Fvalgrind.git (Unsuccessfully) try and make the BB counter give the same results as what Lackey says. git-svn-id: svn://svn.valgrind.org/vex/trunk@445 --- diff --git a/VEX/head20041019/coregrind/vg_main.c b/VEX/head20041019/coregrind/vg_main.c index bdce3527a8..11877e8052 100644 --- a/VEX/head20041019/coregrind/vg_main.c +++ b/VEX/head20041019/coregrind/vg_main.c @@ -153,7 +153,7 @@ Char** VG_(client_envp); UInt VG_(dispatch_ctr); /* 64-bit counter for the number of basic blocks done. */ -ULong VG_(bbs_done); +ULong VG_(bbs_done) = 0; /* Tell the logging mechanism whether we are logging to a file descriptor or a socket descriptor. */ diff --git a/VEX/head20041019/coregrind/vg_scheduler.c b/VEX/head20041019/coregrind/vg_scheduler.c index 77dc47aa1a..66743301a1 100644 --- a/VEX/head20041019/coregrind/vg_scheduler.c +++ b/VEX/head20041019/coregrind/vg_scheduler.c @@ -321,6 +321,9 @@ static UInt run_thread_for_a_while ( ThreadId tid ) { volatile UInt trc = 0; + volatile Int dispatch_ctr_SAVED = VG_(dispatch_ctr); + volatile Int done_this_time; + vg_assert(VG_(is_valid_tid)(tid)); vg_assert(VG_(threads)[tid].status == VgTs_Runnable); vg_assert(!scheduler_jmpbuf_valid); @@ -348,6 +351,12 @@ UInt run_thread_for_a_while ( ThreadId tid ) vg_assert(!scheduler_jmpbuf_valid); save_thread_state ( tid ); + + done_this_time = (Int)dispatch_ctr_SAVED - (Int)VG_(dispatch_ctr) - 1; + + vg_assert(done_this_time >= 0); + VG_(bbs_done) += (ULong)done_this_time; + VGP_POPCC(VgpRun); return trc; } @@ -723,7 +732,6 @@ VgSchedReturnCode do_scheduler ( Int* exitcode, ThreadId* last_run_tid ) { ThreadId tid, tid_next; UInt trc; - UInt dispatch_ctr_SAVED; Int done_this_time, n_in_bounded_wait; Int n_exists, n_waiting_for_reaper; Addr trans_addr; @@ -843,9 +851,6 @@ VgSchedReturnCode do_scheduler ( Int* exitcode, ThreadId* last_run_tid ) */ VG_(dispatch_ctr) = VG_SCHEDULING_QUANTUM + 1; - /* ... and remember what we asked for. */ - dispatch_ctr_SAVED = VG_(dispatch_ctr); - /* paranoia ... */ vg_assert(VG_(threads)[tid].tid == tid); @@ -1039,10 +1044,6 @@ VgSchedReturnCode do_scheduler ( Int* exitcode, ThreadId* last_run_tid ) non-completely-trivial reason. First, update basic-block counters. */ - done_this_time = (Int)dispatch_ctr_SAVED - (Int)VG_(dispatch_ctr) - 1; - vg_assert(done_this_time > 0); - VG_(bbs_done) += (ULong)done_this_time; - if (0 && trc != VG_TRC_INNER_FASTMISS) VG_(message)(Vg_DebugMsg, "thread %d: completed %d bbs, trc %d", tid, done_this_time, (Int)trc ); @@ -1150,7 +1151,6 @@ void VG_(need_resched) ( ThreadId prefer ) thread over all others. Naturally, this could lead to starvation or other unfairness. */ - if (VG_(dispatch_ctr) > 10) VG_(dispatch_ctr) = 2; prefer_sched = prefer;