概述
#include
#include
#include
#include
#include
static void time_get(ktime_t *start);
static void time_get(ktime_t *start)
{
*start = ktime_get();
}
static int time_print(const char *name, ktime_t starttime)
{
ktime_t rettime;
s64 usecs64;
int usecs;
unsigned long my_s, my_us;
rettime = ktime_get();
usecs64 = ktime_to_us(ktime_sub(rettime, starttime));
usecs = usecs64;
my_s = usecs / USEC_PER_MSEC;
my_us = usecs % USEC_PER_MSEC;
if (usecs == 0)
usecs = 1;
printk("time: %ld.%03ld
", my_s, my_us);
return 0;
}
static int hello_init(void)
{
ktime_t my_time;
printk(KERN_ALERT "Hello, world ver=%s
", "1.0");
time_get(&my_time);
time_print(NULL, my_time);
mdelay(100);
time_print(NULL, my_time);
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world
");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("Dual BSD/GPL");
[80492.470000] Hello, world ver=1.0
[80492.480000] time: 0.000
[80492.580000] time: 102.299
最后
以上就是洁净墨镜为你收集整理的linux ktime set函数,ktime使用例子【原创】的全部内容,希望文章能够帮你解决linux ktime set函数,ktime使用例子【原创】所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复