| MODULE_PARM(advance,"i");
pthread_t thread;
int fd_fifo;
void *thread_code(void *param)
{
hrtime_t expected;
hrtime_t diff;
hrtime_t now;
hrtime_t last_time = 0;
hrtime_t min_diff;
hrtime_t max_diff;
struct sample samp;
int i;
int cnt = 0;
int cpu_id = rtl_getcpuid();
rtl_printf ("Measurement task starts on CPU %d\n", cpu_id);
if (mode) {
int ret = rtl_setclockmode (CLOCK_REALTIME, RTL_CLOCK_MODE_PERIODIC, period);
if (ret != 0) {
conpr("Setting periodic mode failed\n");
mode = 0;
}
} else {
rtl_setclockmode (CLOCK_REALTIME, RTL_CLOCK_MODE_ONESHOT, 0);
}
expected = clock_gethrtime(CLOCK_REALTIME) + 2 * (hrtime_t) period;
fd_fifo = open("/dev/rtf0", O_NONBLOCK);
if (fd_fifo < 0) {
rtl_printf("/dev/rtf0 open returned %d\n", fd_fifo);
return (void *) -1;
}
if (advance) {
rtl_stop_interrupts(); /* Be careful with this! The task won''''t be preempted by anything else. This is probably only appropriate for small high-priority tasks. */
}
/* first cycle */
上一页 [1] [2] [3] [4] [5] [6] [7] [8] 下一页 |