Each thread has its own vlib_main_t.
From: [email protected] <[email protected]> On Behalf Of Vamsi Krishna
Sent: Thursday, September 19, 2019 7:51 AM
To: [email protected]
Subject: Re: [vpp-dev] Can vlib_time_now be used in worker threads
Hi Damjan,
I was going through the following code which vlib_time_now calls internally.
This function takes 'c' as an input which is the timing context and
vlib_time_now passes a reference to global timing context in vlib_main.
If multiple threads call the function at the same time then it can result in a
race and wrong timestamp values.
Am I missing something. Please help me understand.
always_inline f64
clib_time_now_internal (clib_time_t * c, u64 n)
{
u64 l = c->last_cpu_time;
u64 t = c->total_cpu_time;
t += n - l;
c->total_cpu_time = t;
c->last_cpu_time = n;
if (PREDICT_FALSE
((c->last_cpu_time -
c->last_verify_cpu_time) >> c->log2_clocks_per_frequency_verify))
clib_time_verify_frequency (c);
return t * c->seconds_per_clock;
}
Thanks
Vamsi
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#14022): https://lists.fd.io/g/vpp-dev/message/14022
Mute This Topic: https://lists.fd.io/mt/34196878/21656
Group Owner: [email protected]
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-