LinuxQuestions.org
Visit Jeremy's Blog.
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
 
Thread Tools
Old 07-03-2008, 08:16 AM   #1
Sathya
Member
 
Registered: Sep 2007
Posts: 33
Thanked: 0
Question about FIFO


[Log in to get rid of this advertisement]
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
Sathya is offline     Reply With Quote
Old 07-04-2008, 04:56 PM   #2
harry edwards
Member
 
Registered: Nov 2007
Location: Lincolnshire, UK
Distribution: CentOS, Fedora, and Suse
Posts: 238
Thanked: 7
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?
harry edwards is offline     Reply With Quote
Old 07-05-2008, 01:33 AM   #3
Sathya
Member
 
Registered: Sep 2007
Posts: 33
Thanked: 0

Original Poster
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.
Sathya is offline     Reply With Quote
Old 07-05-2008, 06:11 PM   #4
ntubski
Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 697
Thanked: 50
You think the process will block if you use the O_NONBLOCK flag??
ntubski is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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


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


All times are GMT -5. The time now is 08:41 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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration