LinuxQuestions.org
Visit the LQ Articles and Editorials section
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
 
Search this Thread
Old 12-11-2007, 03:01 AM   #1
gal_netanel
LQ Newbie
 
Registered: Jul 2007
Posts: 2

Rep: Reputation: 0
pipes - reading buffer less than PIPE_BUF is atomic operation?


Hi !

I read that writing to pipe buffer less that PIPE_BUFF made in atomic opreation. Does the same apply to reading from pipe ?

I want to use pipe with one writer and multiple reader and want to make sure that pipes does the work without that i need to use semaphore betweent the readers.

Thanks !
Gal.
 
Old 12-12-2007, 04:19 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
Quote:
Originally Posted by gal_netanel View Post
I read that writing to pipe buffer less that PIPE_BUFF made in atomic opreation. Does the same apply to reading from pipe ?
Yes. Though I am not 100% sure, but it would amaze me if reading from a pipe (less than PIP_BUFF) is not atomical.

Quote:
Originally Posted by gal_netanel View Post
I want to use pipe with one writer and multiple reader and want to make sure that pipes does the work without that i need to use semaphore betweent the readers.
Pipes are one-way and one-to-one only. So to have one writer and multiple readers you would have to create (and write to) as much pipes as there are reader-processes.

I'd recommend using a UNIX-domain socket (also called "filesystem socket" or "local socket") instead.

You can read about pipes and UNIX-domain socket in this PDF.
 
Old 12-18-2007, 12:28 AM   #3
gal_netanel
LQ Newbie
 
Registered: Jul 2007
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Hko View Post
Yes. Though I am not 100% sure, but it would amaze me if reading from a pipe (less than PIP_BUFF) is not atomical.


Pipes are one-way and one-to-one only. So to have one writer and multiple readers you would have to create (and write to) as much pipes as there are reader-processes.

I'd recommend using a UNIX-domain socket (also called "filesystem socket" or "local socket") instead.

You can read about pipes and UNIX-domain socket in this PDF.

Thank you very much Hko.
I found the pdf file very interesting.
Regards, Gal.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Atomic operation question PatrickNew Programming 4 05-12-2007 12:11 AM
reading closed pipes kev000 Programming 2 11-29-2006 01:45 PM
Sed gives output in pipes only when buffer is full jahvascriptmaniac Linux - Software 2 08-31-2006 05:57 PM
What is the difference between the free buffer and buffer in the buffer hash queue? Swagata Linux - Enterprise 0 05-25-2006 11:57 PM
Can PIPE_BUF constant in linux/limits.h be changes ? ayb Linux - Newbie 1 06-25-2004 10:48 AM


All times are GMT -5. The time now is 09:26 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 Google+: linuxquestions
Open Source Consulting | Domain Registration