|
bsp;
samp.min = min_diff;
samp.max = max_diff;
write (fd_fifo, &samp, sizeof(samp));
} while (1);
return 0;
}
pthread_t background_threadid;
void *background_thread(void *param)
{
hrtime_t next = clock_gethrtime(CLOCK_REALTIME);
while (1) {
hrtime_t t = gethrtime ();
next += bperiod;
/* the measurement task should preempt the following loop */
while (gethrtime() < t + bperiod * 2 / 3);
clock_nanosleep (CLOCK_REALTIME, TIMER_ABSTIME, hrt2ts(next), NULL);
}
}
int init_module(void)
{
pthread_attr_t attr;
struct sched_param sched_param;
int thread_status;
int fifo_status;
rtf_destroy(0);
fifo_status = rtf_create(0, fifo_size);
if (fifo_status) {
rtl_printf("RTLinux measurement test fail. fifo_status=%d\n",fifo_status);
return -1;
}
rtl_printf("RTLinux measurement module on CPU %d\n",rtl_getcpuid());
pthread_attr_init (&attr);
if (rtl_cpu_exists(1)) {
pthread_attr_setcpu_np(&attr, 1);
}
sched_param.sched_priority = 1;
pthread_attr_setschedparam (&attr, &sched_param);
rtl_printf("About to thread create\n");
上一页 [1] [2] [3] [4] [5] [6] [7] [8] 下一页 没有相关教程
|