Sponsored Content
Full Discussion: Two types of pipes?
Top Forums UNIX for Dummies Questions & Answers Two types of pipes? Post 88113 by blowtorch on Monday 31st of October 2005 08:35:52 PM
Old 10-31-2005
Quote:
Originally Posted by Perderabo
Your first type of pipe actually is a pipe. That is, it is created by the pipe() system call. That system call returns a pair of fd's in an array. You write stuff on fd[1] and read stuff on fd[0]. Pipes persist across both fork() and exec(). You can wind up with several processes writing to fd[1] or reading from fd[0] (not that multiple readers make that much sense). But all processes using the pipe are desended from the process that issued pipe() in the first place (I'm ignoring a very arcane exception here). Mostly though you have one process writing on fd[1] and another process reading from fd[0]. I just checked the Posix standard, and this is all that the standard officially mandates. Virually every modern version of unix implements an extention: writing on fd[0] and reading from fd[1]. This results in two independent data streams. This emulates the behavior of socketpair() and this extension arose on BSD when pipes were implemented as socket styles objects. (The first implementation was a as a screwy file system object.)

Your second style of pipe was originally called a "named pipe". It is politically incorrect to call them "named pipes" today. (Which is exactly why I call them "named pipes".) You are supposed to call them fifos today. (F. I. F. O == first in, first out). It is not possible for named pipes to be bi-directional like a socketpair() style pipe. There is a single data stream. Very often there will be a single reader and multiple writers. The processes need not be closely related to each other nor to the creator of the named pipe. Permission to read and write is controlled by file system permission. Unlike pipes, named pipes must be opened with open(). open() is expensive relative to pipe().

Which one is faster at transferring data depends on your kernel and how you built it. With HP-UX, for example, you can build a kernel that uses Streams-based pipes, but HP-UX does not support Streams-based fifos. This mostly affects non-standard features like using a zero length write to send a zero length message.
Oh yeah, --slap forehead--, this is basic IPC! Its just that was really getting confused with these over the last couple of days, and just had to find out what exactly the difference was performance-wise (I always use the '|' to link I/O of different processes).
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

backup types

can anyone explain me difference between tar and ufsdump commands.............and also i wd like to know the difference between incremental and differential backup......... thx in advance (1 Reply)
Discussion started by: girish_shukla
1 Replies

2. Filesystems, Disks and Memory

associated file types

I have a file of type .for extension .In a guui based unix environment like solaris if I double click on that file a specific program designed by me has to run which takes this file as the parameter and exceutes the program. Can anyone help me? (8 Replies)
Discussion started by: nhk_srd
8 Replies

3. Filesystems, Disks and Memory

PIPEs and Named PIPEs (FIFO) Buffer size

Hello! How I can increase or decrease predefined pipe buffer size? System FreeBSD 4.9 and RedHat Linux 9.0 Thanks! (1 Reply)
Discussion started by: Jus
1 Replies

4. UNIX for Dummies Questions & Answers

mime types

Hi, I am trying to launch an ogg movie from a pdf file which has been produced with pdflatex and \movie {\centerline{\includegraphics {grafiques_xerrades/un_manolo_amb_camera.pdf}}} {hlims_xerrades/XocCumuls.ogg} The switch "externalviewer" makes kpdf launch the default... (5 Replies)
Discussion started by: pau
5 Replies

5. What is on Your Mind?

What Types of Food Do You Like The Most?

On another simple topic, multiple choice answers OK ( you can pick more than one or suggest others - we will add your suggestions to the poll ). What Types of Food Do You Like The Most? (27 Replies)
Discussion started by: Neo
27 Replies

6. Homework & Coursework Questions

Help with using different types of GREP

1. The problem statement, all variables and given/known data: Hey there, I'm brand new to using Unix as I just started a course on it in my University, and I currently working through a worksheet which focuses on the many commands and methods of GREP (I'm working through the terminal command... (11 Replies)
Discussion started by: SilvarHawke
11 Replies

7. Shell Programming and Scripting

Cp -r except certain file types

the following excludes certain directories successfully cp -r probe/!(dir) /destination I want to exclude certain file types and tried unsuccessfully cp -r probe/!(*.avi) /destination (2 Replies)
Discussion started by: tmf
2 Replies

8. Programming

Are These All The Integer Types In C

Hello and Good day, I am currently studying C and I just finished learning about variables mainly those of integer type. I am wondering if the list below are all there is to integer variables and there are still more that i have to learn. Here are the list: Char Short int long long long... (3 Replies)
Discussion started by: split_func0
3 Replies
pipe(2) 							System Calls Manual							   pipe(2)

NAME
pipe() - create an interprocess channel SYNOPSIS
DESCRIPTION
creates an I/O mechanism called a pipe and returns two file descriptors, fildes[0] and fildes[1]. fildes[0] is opened for reading and fildes[1] is opened for writing. A read-only file descriptor fildes[0] accesses the data written to fildes[1] on a first-in-first-out (FIFO) basis. For details of the I/O behavior of pipes see read(2) and write(2). By default, HP-UX pipes are not STREAMS-based. It is possible to generate the kernel so that all pipes created on a system are STREAMS- based. This can only be done for HP-UX releases 10.0 and later. STREAMS-based FIFOs (created by or are not supported on HP-UX. To generate a kernel that supports STREAMS-based pipes: o STREAMS/UX must be installed. o The module and the driver must be included in the file. (When STREAMS/UX is installed, and are automatically added to the system file.) o The tunable parameter (see streampipes(5)) must be set to 1 in the file. (This is not automatically done when STREAMS/UX is installed.) o The kernel must be generated and the system rebooted. Once this is done, all pipes created by will be STREAMS-based. For more information, see EXAMPLES
The following example uses to implement the command string RETURN VALUE
returns one of the following values: Successful completion. Failure. is set to indicate the error. ERRORS
sets to one of the following error values if the corresponding condition is true. or more file descriptors are currently open. The system file table is full. The file system lacks sufficient space to create the pipe. Could not allocate resources for both Stream heads (STREAMS-based pipes only). SEE ALSO
sh(1), read(2), write(2), popen(3S), privileges(5), streampipes(5), streamio(7). STANDARDS CONFORMANCE
pipe(2)
All times are GMT -4. The time now is 01:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy