LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 07-03-2008, 07:16 AM   #1
Sathya
Member
 
Registered: Sep 2007
Posts: 33

Rep: Reputation: 15
Question about FIFO


I have an application where there is a reader process that reads data from fifo and multiple writer processes that writes data into the fifo. Both read and write are non blocking.

Everything works fine until suddenly a situation like below happens:

Writer writes n bytes into the fifo but the reader returns saying no data to be read. This is very strange.

I also doubt that there is some kind of stack corruption inside the process memory but the process doesnt crash but it just continues doing its work. So my doubt is after that memory corruption, if the process reads from FIFO, it returns saying no data read until the process is restarted. After restarting everything works fine again.

Can there be a case where a corruption in process memory affect the FIFO also?

Please clarify
 
Old 07-04-2008, 03:56 PM   #2
harry edwards
Member
 
Registered: Nov 2007
Location: Lincolnshire, UK
Distribution: CentOS, Fedora, and Suse
Posts: 360

Rep: Reputation: 47
I believe FIFO queues may buffer input until the buffer gets above a certain size. Therefore, when read it appears the buffer is empty. The reason for this (I think) is speed as there would be a large overhead writing every chunk of data out instantly. You can flush the buffer after writing to force the data to be made available. Do you flush?
 
Old 07-05-2008, 12:33 AM   #3
Sathya
Member
 
Registered: Sep 2007
Posts: 33

Original Poster
Rep: Reputation: 15
The writer process opens fifo in O_WRONLY|O_NONBLOCK|O_SYNC. The O_SYNC flag takes care that the data is written to the underlying stream otherwise blocks the process. This is how i make sure that the data is written into the fifo, rather than flushing it.
 
Old 07-05-2008, 05:11 PM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 1,421

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
You think the process will block if you use the O_NONBLOCK flag??
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question on using select() function call with FIFO Sathya Programming 12 05-30-2008 09:33 AM
General question regarding FIFO Sathya Programming 1 05-23-2008 10:16 AM
Question about reading/writing into a Named Pipes(FIFO) Sathya Programming 21 05-05-2008 08:39 AM
fifo help !! matlin Linux - Newbie 1 02-21-2008 01:51 PM
FIFO question gauge73 Linux - Newbie 1 02-28-2003 11:39 PM


All times are GMT -5. The time now is 10:49 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration