如何帮助网站吸引流量,自己做游戏需要学什么,网页搜索青骄第二课堂,flash如何制作网站linux 获取时间接口 我们在开发调试过程中#xff0c;可能遇到一些和调用时序相关的问题#xff0c;为了查看哪个步骤先调用#xff0c;哪个步骤后调用#xff0c;我们可以使用函数打印或者主动trace堆栈…但是有的时候我们需要排查2个接口调用的时间间隔#xff0c;我们可… linux 获取时间接口 我们在开发调试过程中可能遇到一些和调用时序相关的问题为了查看哪个步骤先调用哪个步骤后调用我们可以使用函数打印或者主动trace堆栈…但是有的时候我们需要排查2个接口调用的时间间隔我们可以使用记录接口调用时间点的方式来查看接口见调用的时间间隔比如网卡的power power 和 power down之间必须要有一定的时间间隔才能正常的power down成功。
1、系统时间获取接口
//include/linux/time64.h//将时间按照s和ns记录
struct timespec64 {time64_t tv_sec; /* seconds */long tv_nsec /* nanoseconds */
}
//kernel/time/timekeeping.c/*** ktime_get_ts64 - get the monotonic clock in timespec64 format* ts: pointer to timespec variable** The function calculates the monotonic clock from the realtime* clock and the wall_to_monotonic offset and stores the result* in normalized timespec64 format in the variable pointed to by ts.*/
void ktime_get_ts64(struct timespec64 *ts)
{struct timekeeper *tk tk_core.timekeeper;struct timespec64 tomono;unsigned int seq;u64 nsec;WARN_ON(timekeeping_suspended);do {seq read_seqcount_begin(tk_core.seq);ts-tv_sec tk-xtime_sec;nsec timekeeping_get_ns(tk-tkr_mono);tomono tk-wall_to_monotonic;} while (read_seqcount_retry(tk_core.seq, seq));ts-tv_sec tomono.tv_sec;ts-tv_nsec 0;timespec64_add_ns(ts, nsec tomono.tv_nsec);
}2、如何使用 int main void{struct timespec64 callTimer {0};ktime_get_ts64(callTimer);printf(tv_sec: %llu, tv_nsec: %llu\n, callTimer.tv_sec, callTimer.tv_nsec);return 0;}