我正在研究一个新的Linux调度程序,我需要hrtimers。 我读了如何实现它们在: http://lwn.net/Articles/167897/Hrtimers和clockid_t问题
我做了一个小程序,在使用前测试这些定时器和我有一些问题。
那小程序是这样的:
#include "linux/ktime.h"
#include "linux/hrtimer.h"
#include "linux/timer.h"
#include "linux/tick.h"
static void funcion_timers(unsigned long data) {
printk(" HOLA HA SALTADO EL TIMER y el dato es %lu \n", data);
}
int main() {
ktime_t kt;
int i;
struct hrtimer my_timer;
clockid_t reloj;
enum hrtimer_mode mode;
kt = ktime_set(0, 5000000);
reloj=CLOCK_MONOTONIC;
mode=HRTIMER_REL;
printk("EMPIEZA EL PROGRAMA");
hrtimer_init(&my_timer, reloj);
my_timer.function=&funcion_timers;
my_timer.data=3;
hrtimer_start(&my_timer, kt, mode);
for (i=0; i<10000; i++) { } //A kind of waste of time cause I had problem with sleep into the kernel
}
当我编译有人告诉我(我不是从shell复制,因为它是在西班牙XD):
HRTIMER_REL
没有被宣布为hrtimer_init
需要更多参数- 在
my_timer.function=&funcion_timers;
我有一个不兼容的指针类型:S struct hrtimer
没有一个成员叫data
为什么hrtimer_init需要的参数?我认为它被定义为:
*void hrtimer_init(struct hrtimer *timer, clockid_t which_clock);*
最后,我想我可能已经不知道如何clockid_t
作品;它是如何工作的? 我无法在互联网上找到太多关于它的信息。
非常感谢,:d 阿尔贝托
本教程已过时。从那以后,许多事情发生了变化例如[HRTIMER_REL](http://sourceware.org/ml/systemtap/2008-q1/msg00014.html) – 2011-12-15 13:36:40