On 28.12.2017 17:55, Patrick Doyle wrote: > What are the current best practices for creating periodic threads with > real-time Linux? > > Do folks primarily use timerfd? > > Do folks primarily use POSIX timers and sigwait? In our company we are using clock_nanosleep on the monotonic clock, either absolute or relative. From my - not rigorous - observation this is the easiest to use with least overhead and jitter. As far as I remember timerfd was fine as well. Using POSIX timers involves another kernel thread, meaning both unnecessary context switches (on some platforms the latencies are not negligible) and funny effects if one is not careful to set the priority of this thread accordingly (the default is unusable). > On a somewhat related topic... how do folks stagger the startup of > periodic threads? For example, suppose one (high priority) thread > needs to run every 20ms, only takes 1ms to do its work, but _really_ > needs to run on that 20ms clock. Now suppose some other thread needs > 4ms out of every 20ms to accomplish it's work. This really depends on the particular application. If you can't afford these threads to preempt one another, precalculated absolute wakeup times are probably the easiest solution. Regards -- Stano -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html