#include #include #include #include #define MY_EVENT 0x00000001ll #define MY_PRIORITY 99 static RT_TASK mainTask; int main(int argc, char** argv) { const double ONE_SEC = 1e9; const RTIME timeout = (RTIME)(5 * ONE_SEC); RT_EVENT event; unsigned long mask; RTIME start, end; int res; mlockall(MCL_CURRENT | MCL_FUTURE); rt_task_shadow(&mainTask, NULL, MY_PRIORITY, T_FPU); rt_task_set_mode(0, T_PRIMARY, NULL); rt_event_create(&event, NULL, 0, EV_PRIO); start = rt_timer_read(); res = rt_event_wait(&event, MY_EVENT, &mask, EV_ALL, rt_timer_ns2ticks(timeout)); end = rt_timer_read(); switch (res) { case -EINVAL: case -EIDRM: case -EWOULDBLOCK: case -EINTR: case -ETIMEDOUT: case -EPERM: printf("event: res = %d (%s)\n", res, strerror(-res)); break; default: printf("unknown event: res = %d\n", res); } printf("time - actual %g s, wanted %g s\n", rt_timer_ticks2ns(end - start)/ONE_SEC, timeout/ONE_SEC); rt_event_delete(&event); return 0; }