Thanks Dave ! I was at an older version of VPP, but I do see these changes in v19.04 and they seem to be easy to retrofit. Thanks for the education.
Regards -Prashant On Tue, May 28, 2019 at 5:28 PM Dave Barach (dbarach) <[email protected]> wrote: > > Vlib_time_now(...) works reasonably hard to return the same time on all > worker threads: > > /* > * Note when we let go of the barrier. > * Workers can use this to derive a reasonably accurate > * time offset. See vlib_time_now(...) > */ > vm->time_last_barrier_release = vlib_time_now (vm); > > > always_inline f64 > vlib_time_now (vlib_main_t * vm) > { > return clib_time_now (&vm->clib_time) + vm->time_offset; > } > > /* > * 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); > } > > See also the "show clock" command. > > There should be no need to re-solve this problem yourself. > > Thanks... > > -----Original Message----- > From: [email protected] <[email protected]> On Behalf Of Prashant > Upadhyaya > Sent: Tuesday, May 28, 2019 7:48 AM > To: [email protected] > Subject: [vpp-dev] Regarding vlib_time_now > > Hi, > > I suppose vlib_time_now can return different times on different workers. > If I want to have some global notion of time between workers (and possibly > main thread), what would be the best way, please suggest. > > I thought of passing the vm of main thread for the above usecase, from > workers, while calling vlib_time_now but that seems like a spectacularly bad > idea as the code inside modifies some variables related to time inside the > vm (and therefore looks like one must pass the correct vm from the correct > thread) > > Is it ok to use a combination of os_cpu_clock_frequency() and > clib_cpu_time_now ? > > Regards > -Prashant
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#13160): https://lists.fd.io/g/vpp-dev/message/13160 Mute This Topic: https://lists.fd.io/mt/31820577/21656 Group Owner: [email protected] Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
