3
我正在尝试查找自启动以来进程在内核例程中所占的时间百分比。问题是,我不知道我应该传递给函数的什么参数:do_posix_clock_monotonic_gettime()
在内核例程中查找进程时间占进程启动以来所用时间的百分比
我该怎么传递给它?
由于
我正在尝试查找自启动以来进程在内核例程中所占的时间百分比。问题是,我不知道我应该传递给函数的什么参数:do_posix_clock_monotonic_gettime()
在内核例程中查找进程时间占进程启动以来所用时间的百分比
我该怎么传递给它?
由于
在Linux 2.6.39,do_posix_clock_monotomic_gettime
在include/linux/time.h
定义为这样:
#define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts)
ktime_get_ts在kernel/time/timekeeping.c
实现。上面的注释说明了这个论点:
/**
* ktime_get_ts - get the monotonic clock in timespec 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 timespec format in the variable pointed to by @ts.
*/
好的,我正在尝试这个。我创建了一个timespec结构并用{0,0}初始化它,然后在我的模块中执行以下命令:int time = do_posix_clock_monotonic_gettime(ts.tv_sec),我希望它将时间放在timepec调用的tv_sec部分但是当我做文件时,它给出错误'void value not ignored,it should be'以及警告'传递'ktime_gets_ts'的参数1使得来自整型的指针没有强制转换。你知道我做错了什么吗? – sam
指针是输出参数,函数不返回任何值。以kernel/timer.c中的do_sysinfo为例:'struct timespec tp; ktime_get_ts(&tp);'。另外,我建议你在继续之前阅读一些关于指针的信息。 –