MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / update_now

Function update_now

thread/thread.cpp:1160–1175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1158 volatile uint64_t now;
1159 static std::atomic<pthread_t> ts_updater(0);
1160 static inline uint64_t update_now()
1161 {
1162#if defined(__x86_64__) && defined(__linux__) && defined(ENABLE_MIMIC_VDSO)
1163 if (likely(__mimic_vdso_time_x86))
1164 return photon::now = __mimic_vdso_time_x86.get_now();
1165#endif
1166 struct timespec tv;
1167#ifdef CLOCK_BOOTTIME
1168 clock_gettime(CLOCK_BOOTTIME, &tv);
1169#else
1170 clock_gettime(CLOCK_MONOTONIC, &tv);
1171#endif
1172 auto _now = tv.tv_sec * 1000ul * 1000ul + tv.tv_nsec / 1000ul;
1173 now = _now; // can not ```return now = ...;``` in debug
1174 return _now; // mode because ```now``` is a volatile variable
1175 }
1176 __attribute__((always_inline))
1177 static inline uint32_t _rdtsc()
1178 {

Callers 4

if_update_nowFunction · 0.85
__update_nowFunction · 0.85
timestamp_updater_initFunction · 0.85
sleepq_perfFunction · 0.85

Calls 2

get_nowMethod · 0.80
likelyFunction · 0.50

Tested by 1

sleepq_perfFunction · 0.68