Re: How do the COMEDI drivers control the timing under real time Linux?

On Thu, 20 Apr 2006, ¾¾ºä µÁºÈ wrote:

> Dear COMEDI users,
>
> I have recently come across the COMEDI project and trying to comprehend how 
> it works. My questions are as follows
> 1. How do the COMEDI drivers control the timing of sampling under real time 
> Linux?

For boards and/or drivers that support asynchronous acquisition, the 
comedi core installs an IRQ handler which has hard realtime priority.
  The handler communicates to client code that new samples have 
arrived via function callbacks.

For boards and/or drivers that do not support asynchronous acquisition, it 
is left up to the application code to call the synchronous acquisition 
functions in hard realtime context and to handle setting up the periodic 
loop.  Or this can be done automatically for client code using the 
comedi_rt_timer which emulates asynchronous commands.

> As far as I checked the source code, the only place where real time timer is 
> invoked is in comedi_rt_timer.o. However, COMEDI modules for data acquisition

comedi_rt_timer is used to emulate asynchronous acquisition using 
synchronous acquisition + a realtime OS.  It is not the only way to do RT 
acquisition, hence why you don't see it loaded (in fact, it is never used 
unless you decide to explicitly use it).  It is just a driver that makes 
it easier for all boards (especially ones that lack onboard timers or that 
have incomplete drivers) to do RT acq.

> boards (e.g. ni_pcimio.o) do not seem to be dependent on this module. 
> Modprobing DAQ modules does not load comedi_rt_timer.o, even under real timer 
> kernel (I am using RTAI 3.1). Is it that most of the DAQ modules use the 
> on-board timer to pace the sampling?

Yes, they use the DAQ card's on-board timer, unless you decide to use 
comedi_rt_timer which basically uses the PC motherboard's timer, 
ultimately to affect the same result (more or less).

> 2. If the COMEDI drivers are designed to use the real time API provided by 
> real time Linux, how do they switch to hard real time? By specifying TRIG_RT 
> when calling comedi_command?

You can grep the sources for TRIG_RT.  Basically the comedi core just asks 
the RTOS to install the driver's interrupt handler as a hard realtime IRQ 
handler.  This is only relevant to asynchronous acquisition, of course.

I hope this helps,

-Calin

Received on 2006-05-15Z19:12:41