LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 06-11-2013, 12:22 AM   #1
Deimon
LQ Newbie
 
Registered: Dec 2010
Posts: 7

Rep: Reputation: 0
Are read/write on pipes thread safe.


Hello,

I am using a pipe to communicate two threads and I am not sure on whether I must protect the read and write operation with a mutex or the kernel garantee that thsese operations are thread-safe.

Thank you in advance.
 
Old 06-11-2013, 12:45 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,798

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
you need to give us more detail. One single read and write operation on a pipe is safe, parallel reading and writing should be checked, but it depends on how did you compile your app.
 
1 members found this post helpful.
Old 06-11-2013, 02:47 AM   #3
Deimon
LQ Newbie
 
Registered: Dec 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Muliple writers with a mutex to protect data consistency and a single reader without mutex.
But if a single reader and single writer works I assume the above scenario is correct.

Thank you!
 
  


Reply

Tags
pipes, threads



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
python thread safety: printing from thread to redirected stdout - safe? BrianK Programming 2 10-11-2010 11:28 AM
Read Write access to a iso9660 filesystem..mount a .iso image as read write ceazar123 Linux - Newbie 16 09-01-2010 09:07 AM
[SOLVED] Named pipes - Problem with write() and read() MarijaS Programming 2 08-10-2010 08:48 AM
Multi-Thread/Process Pipes JanusPaul Programming 2 02-27-2005 02:52 PM
Confused about ntfs safe(?) read-write zonkers Linux - Newbie 7 05-16-2004 09:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration