Realtime networked linux
Hello all,
I'm trying to develop a real-time controller for a
nano-positioning system using a linux box (SUSE 9.3, minimal
install, PII 333MHz). Any advice from people who have worked on
similar projects or pointers to information would be very much
appreciated.
There are three basic requirements:
1. The control loop will need to run at 1kHz (ideally 5kHz) and
must sample 4 A/Ds, compute a 10x10 matrix multiplication and
then write to 3 D/As (easy within 1ms). The jitter in this loop
should be less than 10%.
2. The data collected from the D/As must then be sent over the
network to a second computer for analysis (not real-time)
3. Finally, the controller needs to be able to take commands from
another machine on the network (also not real-time)
The main problem that I've found is that the time slice for the
linux kernel is just over 1ms - so if I allow the control loop to
give up the processor (i.e. usleep(1)) to deal with a network
request, then I'll miss the next sample.
The primary questions I've got are:
1. Is this workable on a linux platform or should I move to a
RTOS? If a RTOS is the way to go could anyone point me at a free,
easy to use one that might suit (i.e. has real-time network
interface)?
2. I've read that it's possible to increase the frequency of the
time slicing in linux and that the latest kernel 2.6 is actually
running at 250Hz. If I could increase this to 2-3kHz it might
solve the problem. Is there any info on how I might do this and
would it destroy the system?
3. Does calling send() or recv() require a context switch?
i.e. could I have a single-threaded program that calls send() and
recv() once per loop and never gives up the processor?
4. I've seen timing information for the new kernel 2.6 that says
it can do a kernel thread context switch in <20us. Could someone
point me at good info for the newest implementation of pthreads?
5. I've read that kernel 2.6 has some real-time support built
in. Does increasing a thread's priority to -20 (i.e. nice(-20))
do this or am I missing something?
Thanks for any and all help!
Colin
|