LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   pipes - reading buffer less than PIPE_BUF is atomic operation? (https://www.linuxquestions.org/questions/programming-9/pipes-reading-buffer-less-than-pipe_buf-is-atomic-operation-605985/)

gal_netanel 12-11-2007 03:01 AM

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.

Hko 12-12-2007 04:19 AM

Quote:

Originally Posted by gal_netanel (Post 2986879)
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 (Post 2986879)
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.

gal_netanel 12-18-2007 12:28 AM

Quote:

Originally Posted by Hko (Post 2988084)
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.


All times are GMT -5. The time now is 12:31 AM.