我需要找到系统时间,因为电源是在我的c代码中的linux机器上使用的。像' time ()‘和gettimeofday()这样的函数返回的是自纪元以来的时间,而不是通电以来的时间。如何查找开机后的时间或时钟滴答数?
提前感谢!
发布于 2013-07-18 23:50:34
请参阅:Wgat API do I call to get the System Time
请参阅中的sysinfo
sys/sysinfo.h
struct sysinfo {
long uptime; /* Seconds since boot */
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
unsigned long totalram; /* Total usable main memory size */
unsigned long freeram; /* Available memory size */
unsigned long sharedram; /* Amount of shared memory */
unsigned long bufferram; /* Memory used by buffers */
unsigned long totalswap; /* Total swap space size */
unsigned long freeswap; /* swap space still available */
unsigned short procs; /* Number of current processes */
unsigned long totalhigh; /* Total high memory size */
unsigned long freehigh; /* Available high memory size */
unsigned int mem_unit; /* Memory unit size in bytes */
char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding for libc5 */
};https://stackoverflow.com/questions/17728173
复制相似问题