Linux Clock & Time
来源:互联网 发布:linux文件重命名 编辑:程序博客网 时间:2024/06/05 03:24
<span style="font-family:System;font-size:14px;">#include <stdio.h>#include <stdlib.h>#include <time.h>#include <string.h>static void clock_info(clockid_t clk_id){ int result = 0; struct timespec tsp; memset((void*)(&tsp), 0, sizeof(struct timespec)); result = clock_getres(clk_id, &tsp); printf("clock resolution, seconds is: %ld\n", (long)(tsp.tv_sec)); printf("clock resolution, nanoseconds is: %ld\n", (long)(tsp.tv_nsec)); memset((void*)(&tsp), 0, sizeof(struct timespec)); result = clock_gettime(clk_id, &tsp); printf("get time, seconds is: %ld\n", (long)(tsp.tv_sec)); printf("get time, nanoseconds is: %ld\n", (long)(tsp.tv_nsec));}int main(int argc, char** argv){int result = 0;struct timespec tsp; printf("CLOCK_REALTIME*****************************************************\n"); clock_info(CLOCK_REALTIME); printf("CLOCK_REALTIME_COARSE**********************************************\n"); clock_info(CLOCK_REALTIME_COARSE); printf("CLOCK_MONOTONIC****************************************************\n"); clock_info(CLOCK_MONOTONIC); printf("CLOCK_MONOTONIC_COARSE*********************************************\n"); clock_info(CLOCK_MONOTONIC_COARSE); printf("CLOCK_MONOTONIC_RAW************************************************\n"); clock_info(CLOCK_MONOTONIC_RAW); printf("CLOCK_BOOTTIME*****************************************************\n"); clock_info(CLOCK_BOOTTIME); printf("CLOCK_PROCESS_CPUTIME_ID*******************************************\n"); clock_info(CLOCK_PROCESS_CPUTIME_ID); printf("CLOCK_THREAD_CPUTIME_ID********************************************\n"); clock_info(CLOCK_THREAD_CPUTIME_ID);return 0;}</span>
<span style="font-family:System;font-size:14px;">Linux 终端下 man clock_gettime</span>
<span style="font-family:System;font-size:14px;">CLOCK_REALTIME System-wide clock that measures real (i.e., wall-clock) time. Setting this clock </span>
<span style="font-family:System;font-size:14px;">requires appropriate privileges. This clock is affected by discontinu‐ous jumps in the system time </span>
<span style="font-family:System;font-size:14px;">(e.g., if the system administrator manually changes the clock), and by the incremental adjustments </span>
<span style="font-family:System;font-size:14px;">performed by adjtime(3) and NTP.</span>
CLOCK_MONOTONIC
Clock that cannot be set and represents monotonic time since some unspecified starting
point. This clock is not affected by discontinuous jumps in the system time (e.g., if the system
administrator manually changes the clock), but is affected by the incremental adjustments performed
by adjtime(3) and NTP.
Reference Site:
http://www.it165.net/os/html/201309/6136.html
0 0
- Linux Clock & Time
- Linux Clock & Time
- linux中的wall clock time
- Real Time Clock Driver for Linux
- Real Time Clock (RTC) Drivers for Linux
- Real Time Clock (RTC) Drivers for Linux
- wall clock time(response time)
- time & clock(MSDN)
- Wall clock time
- clock time times
- Real-time clock alarm
- clock()与time()区别
- clock() / time() 函数
- 什么是wall clock time
- CPU vs Clock Time
- linux clock
- linux clock
- dsPIC33F之Real-Time Clock
- Dynamics CRM 2015/2016 Web API:Unbound Action 和 Bound Action
- 在Sql Server 2016中使用For Json子句把数据作为json格式导出
- 五大常用算法 --动态规划
- 堆和栈的区别,顺便介绍一下:全局区(静态区)、文字常量区、程序代码区
- C#冒泡排序BubbleSort
- Linux Clock & Time
- 男人总会对女人的外表失去兴趣
- 并发编程之基础问答篇
- nginx 连接 mongodb
- iOS不断旋转的UIBarButtonItem
- NSString 与 NSData 之间的互转 NSData 与 UIImage 之间互转 NSDate 与 NSString 之间的互转
- 使用极客标签二维码服务快速生成二维码
- java 调用js 方法库进行简单的数学表达式的运算
- asp.net mvc5 与图片