This message was posted on behalf of Intel Corporation
Thank you for your interest in the Intel Edison board.
Unfortunately, we cannot comment or debug your code.
However, Edison is not running a real time OS and so the desired time precision (ms) may not be possible.
Matha is right. Under load you might get 100ms error. Try f.i. running iperf simultaneously with your code.
With a preempt_rt version of the kernel you might achieve 100us or so.
Nevertheless it is strange that you measure less then 5ms, the latencies should be causing longer periods not shorter.
I have a piece of code that transmits data on fixed intervals. I use timerfd_create(CLOCK_REALTIME, 0) to create file descriptor containing timer events, then select() on the fd. This works for me (and even better on preempt_rt). If you're interested: hs_uart/main.c at master · htot/hs_uart · GitHub from line #147