- From: Frank Mori Hess <fmhess_at_users.sourceforge.net>
- Date: Thu, 7 Oct 2004 21:43:28 -0400
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday 07 October 2004 09:23 am, Eric Keller wrote: > 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. Well, you won't go off the end of the buffer, but it really isn't ideal the way it is coded (assuming you want to take data forever). When the "front" variable overflows, it will break from the loop. - -- Frank -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFBZfDA5vihyNWuA4URAsJCAJ0egeRF3W5ox3UY+tBOcOpqnu1IqQCfSxmp BTJagf6JxGjy0U4U6hz2sRA= =mHf7 -----END PGP SIGNATURE-----
Received on 2004-10-08Z00:43:28