Re: real-time process

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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!

Yes, there is. But first, it skips only to the next frame and second, it
may even be desired!

As to why it's only until the next frame, notice that the ioctl
requesting notification is not inside the loop. That means the signals
are comming at constant rate. The next one will wake up the loop.

As to why it may be desired, if some signals come while it reads, it
wants to skip them (it's too slow to send all in time). So it does not
care for those signals.

-------------------------------------------------------------------------------
						 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/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux