apps/examples/oneshot: A thought about how we might improve accuracy of long delays.

This commit is contained in:
Gregory Nutt 2016-08-15 12:54:05 -06:00
parent 0a6dd4a24e
commit 2ff22da39d

View File

@ -66,6 +66,16 @@
# define CONFIG_EXAMPLE_ONESHOT_SIGNO 13
#endif
/* For long delays that have to be broken into segments, some loss of
* precision is expected to to interrupt and context switch overhead. The
* inaccuracy will cause somewhat longer times than the time requisted due to
* this overhead. It might be possible to reduce this some by (1) make this
* task very high priority so that it runs in a more deterministic way, and
* (2) by subtracting a "fudge factor" to acount for the overhead.
*/
#define FUDGE_FACTOR 10
/****************************************************************************
* Private Functions
****************************************************************************/
@ -216,6 +226,17 @@ int oneshot_main(int argc, char *argv[])
start.ts.tv_nsec = ts.tv_nsec;
usecs -= maxus;
#if FUDGE_FACTOR > 0
if (usecs > FUDGE_FACTOR)
{
usecs -= FUDGE_FACTOR;
}
else
{
usecs = 0;
}
#endif
}
ret = ioctl(fd, OSIOC_START, (unsigned long)((uintptr_t)&start));