aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib/threads.h
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-02-19 17:05:30 -0500
committerDamjan Marion <dmarion@me.com>2019-02-20 16:27:47 +0000
commita4324a996f34902579338033110d27575a654c8e (patch)
treecdc4a58a8d055053cf8ef90b5ddf7d0fcd1a5af2 /src/vlib/threads.h
parent51a423dc2b0d4aad0bbd8f7e757d2ca49221ff83 (diff)
calculate per-thread time offset
The main thread squirrels away vlib_time_now (&vlib_global_main), worker threads use it to calculate an offset in f64 seconds from their own vlib_time_now(vm) value. We use that offset until the next barrier sync. Thanks to Damjan for the suggestion. Change-Id: If56cdfe68e5ad8ac3b0d0fc885dc3ba556cd1215 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vlib/threads.h')
-rw-r--r--src/vlib/threads.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/vlib/threads.h b/src/vlib/threads.h
index 0e9cba52103..95fcf3d83d7 100644
--- a/src/vlib/threads.h
+++ b/src/vlib/threads.h
@@ -422,6 +422,21 @@ vlib_worker_thread_barrier_check (void)
}
while (*vlib_worker_threads->wait_at_barrier)
;
+
+ /*
+ * Recompute the offset from thread-0 time.
+ * Note that vlib_time_now adds vm->time_offset, so
+ * clear it first. Save the resulting idea of "now", to
+ * see how well we're doing. See show_clock_command_fn(...)
+ */
+ {
+ f64 now;
+ vm->time_offset = 0.0;
+ now = vlib_time_now (vm);
+ vm->time_offset = vlib_global_main.time_last_barrier_release - now;
+ vm->time_last_barrier_release = vlib_time_now (vm);
+ }
+
if (CLIB_DEBUG > 0)
vm->parked_at_barrier = 0;
clib_atomic_fetch_add (vlib_worker_threads->workers_at_barrier, -1);