打印本文 打印本文 关闭窗口 关闭窗口
Linux嵌入式实时操作系统开发与设计(七)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数5527  更新时间:2009/4/22 20:45:21  文章录入:mintao  责任编辑:mintao
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]  下一页

打印本文 打印本文 关闭窗口 关闭窗口