]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
(Unsuccessfully) try and make the BB counter give the same
authorJulian Seward <jseward@acm.org>
Thu, 28 Oct 2004 09:51:12 +0000 (09:51 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 28 Oct 2004 09:51:12 +0000 (09:51 +0000)
results as what Lackey says.

git-svn-id: svn://svn.valgrind.org/vex/trunk@445

VEX/head20041019/coregrind/vg_main.c
VEX/head20041019/coregrind/vg_scheduler.c

index bdce3527a8ad1fedb6c92162ea2685a37b5bda7a..11877e8052f10a2bcdd1cde4ef103d79b0fefc1f 100644 (file)
@@ -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. */
index 77dc47aa1a5f5f2408be84e5315e327341976a48..66743301a195fa71d8f351f27b0b2d9c38c67554 100644 (file)
@@ -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;