On Fri, Oct 18, 2002 at 12:29:14PM +0300, Momchil Velikov wrote: > >>>>> "Jan" == Jan Hudec <bulb@ucw.cz> writes: > > Jan> On Thu, Oct 17, 2002 at 03:39:21PM +0300, Momchil Velikov wrote: > Nagaraj> for( buff_index = i = 0; i < xfer_count; i++, buff_index = > Nagaraj> (buff_index+1)%MAX_BUFFERS ) { > >> > Nagaraj> sleep(1000); > >> > Nagaraj> read( buff_fd, (mbuff +buff_index*BUFF_SIZE), BUFF_SIZE ); > >> > Nagaraj> } > >> > >> First, the above code has a race condition, which can add up to 1000 sec (!) > >> latency per frame! > > Jan> Yes, there is. But first, it skips only to the next frame and > > I wouldn't call 1000 seconds "only". > > But, yes, not per frame, but per xfer_count frames. No. You still don't seem to realize, that a signal is emited each time one buffer is completed. And as the buffer is at most one frame, signals are sent at least at frame rate. That is some 1/18 or 1/25 second period or something like that. And that is actually the upper bound for time the sleep can sleep. I hope I have the right to call 1/18 second "only". ------------------------------------------------------------------------------- Jan 'Bulb' Hudec <bulb@ucw.cz> -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/