Periodic thread with Linux

Ralf Corsepius corsepiu at faw.uni-ulm.de
Fri May 23 08:33:36 UTC 2003


Am Fre, 2003-05-23 um 09.53 schrieb Jack Cawkwell:
> This cannot be done under normal Linux. Linux is not real-time,
> so you cannot guarantee that the process or thread will be
> able to be scheduled to run at the time required. There are
> systems that use Linux combined with some real-time support,
> you may like to look at these if you want to have Linux and
> a small amount of real-time processing.
ACK, but ...

A 1ms period definitely is way to short for "normal Linux", but for
longer periods (say > 100ms) and if not needing strict real-time, you
can apply select(2), alarm(2), setitimer(2) etc.

If using pthreads, you alternatively can apply some mechanisms based on
pthread conditions (pthread_cond_t), eg. pthread_cond_timedwait(3)

If wanting to poll a device, you'd have to write a device driver and
integrate it into the Linux-kernel. But even there, a 1ms period imposes
pretty tough constraints. I don't recall the exact figure off-hand, but
AFAI recall the standard Linux kernel tick is at 50ms or similar?

Ralf





More information about the users mailing list