[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: [rtl] FIFO writes & reads atomic?



James Cassidy wrote:
> 
> Thanks for the info Michael.
> 
> Since writes from a Linux process are not atomic, then does it follow
> that the rtl task which reads from that fifo must deal with possible
> short writes from the linux process?
<DELETED>

I pass data and commands over an RT fifo from a Linux process.
I do put the "bytes to follow" as the first 16 bits of each
command but have never seen a short write. I do two reads for
each packet, first, two bytes (the length) then the rest of the
data.  Maybe I am just dumb and lucky.  
My guess is that a short write will not occur
as long as there is space in the fifo's buffer.  I read from
both ends frequently and don't pass high bandwidth data.  So
it seems like you are correct, we should be doing what the libC
streams package does and re-reading on short reads but my 
application has yet to see a problem.  Looking at my code, I
see I log short reads as errors. So I would notice them if they
happened.

-- 
--Chris Albertson

  chris@topdog.logicon.com                Voice:  626-351-0089  X127
  Logicon RDA, Pasadena California          Fax:  626-351-0699
--- [rtl] ---
For more information on Real-Time Linux see:
http://www.rtlinux.org/