Re: Continuous acquisition latency and buffer overflow

From: Jonathan Wang <jtwang_at_MIT.EDU>

snip

>Also, as I will be doing continuous acquisition for a long time, I am 
>worried about the mmap buffer overflowing. I see that the demo program 
>mmap.c in comedilib/demo simply increments pointers in its mmap'ed 
>buffer to read values. However, this seems dangerous to me, since 
>eventually the pointers will increment past 2^32 and the buffer will 
>overflow. Could somebody clarify the way this works?

Jonathan,
I also worried about this, but you see that they take the modulo (%) of the
counter with the buffer length, so that the index into the buffer is always
within the range of the buffer.  It's obviously hard to read, but that handles
the case when your read wraps around much more simply that checking the bounds
of the index.

As far as your control question, I also want to do this.  My program does a lot
of processing, and I only want to be woken up at the end of a scan.  There is
some mention of a comedi callback, but it appears not to be documented except
possibly in the source.
Regards,
Eric Keller

>Thanks,
>Jonathan

Received on 2004-10-07Z12:23:17