Results 1 to 4 of 4
Hi :
Is there a way to figure out the following about a linux FIFO.
1. size - how much data in it at any given time.
2. capacity - ...
- 03-10-2008 #1Just Joined!
- Join Date
- Oct 2006
- Posts
- 22
Linux FIFO. Determining Size, Reaches capacity
Hi :
Is there a way to figure out the following about a linux FIFO.
1. size - how much data in it at any given time.
2. capacity - what is the max it can hold
What does the fifo do when it reaches its capacity? Suppose the reader isn't keeping up with the writer, can the writer figure this out and react. Will the writer slow down when it is full and only write at the rate that it is being read?
Thanks
Bandeg
- 03-10-2008 #2I am unaware of any obvious way to know this.1. size - how much data in it at any given time.
Unless specific steps are taken, the writer will wait until there is room, write the data, and continue its own processing. Which I gather is not what you want.What does the fifo do when it reaches its capacity?
Effectively, yes. The writer will wait until there is room for its data in the FIFO before continuing its processing.Will the writer slow down when it is full and only write at the rate that it is being read?
Yes. The writer can open the FIFO in non-blocking mode and then do its processing in a loop in which it does a select() before doing the write(), and only doing the write() if the select() said that the FIFO was ready to be written to.Suppose the reader isn't keeping up with the writer, can the writer figure this out and react.
For further info, do this at the command line:
If man pages are not installed on your system, google for this.Code:man 2 select
Hope this helps.Code:man select linux
--
Bill
Old age and treachery will overcome youth and skill.
- 03-11-2008 #3Just Joined!
- Join Date
- Oct 2006
- Posts
- 22
Thanks for the execellent info. One thing that I also can do is check the return from the write() to see if it wrote all the data. If not, can I consider the fifo full?
- 03-11-2008 #4That's a possibility, but I wouldn't count on it.Thanks for the execellent info. One thing that I also can do is check the return from the write() to see if it wrote all the data. If not, can I consider the fifo full?
If, when you get back from the select(), you do not get an indication that the FIFO may be written to, then you can consider the FIFO full. Otherwise, you should keep writing.
Your select() loop should keep looping until the select() indicates that no I/O can be done on any of the file descriptors of interest. Of course, if you run out of data to write to the FIFO, you should remove that file descriptor from the list of file descriptors of interest, until you have more data to write.--
Bill
Old age and treachery will overcome youth and skill.


Reply With Quote