<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0068)http://www-106.ibm.com/developerworks/linux/library/l-rt4/index.html -->
<HTML xmlns:fo = "http://www.w3.org/1999/XSL/Format"><HEAD><TITLE>developerWorks: Linux | Open source projects : RunTime: Pipes in Linux, Windows 2000, and Windows XP</TITLE>
<META
content="This month Ed begins a series of investigations into operating system programming interfaces, starting with pipes. He has also added a new operating system to the lineup; Windows XP has recently released. In this installment, Ed will be working with pipes on Windows 2000 Advanced Server (with Service Pack 2 installed), Linux (based on Red Hat 7.1), and the newly released Windows XP professional. Share your thoughts on this article with the author and other readers in the discussion forum by clicking Discuss at the top or bottom of the article. "
name=ABSTRACT>
<META
content="This month Ed begins a series of investigations into operating system programming interfaces, starting with pipes. He has also added a new operating system to the lineup; Windows XP has recently released. In this installment, Ed will be working with pipes on Windows 2000 Advanced Server (with Service Pack 2 installed), Linux (based on Red Hat 7.1), and the newly released Windows XP professional. Share your thoughts on this article with the author and other readers in the discussion forum by clicking Discuss at the top or bottom of the article. "
name=DESCRIPTION>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="RunTime: Pipes in Linux, Windows 2000, and Windows XP "
name=TITLE>
<META content=http://www-105.ibm.com/developerworks/newcontent.nsf/dW_feedback/
name=OWNER>
<META content=Public name=SECURITY>
<META content=text/xhtml name=FORMAT>
<META content="Copyright (c) 2001 by IBM Corporation" name=COPYRIGHT>
<META content=index,follow name=ROBOTS>
<META content=us name=IBM.COUNTRY>
<META content=us name=DOCUMENTCOUNTRYCODE>
<META content=en name=DOCUMENTLANGUAGECODE>
<META
content="os program interface api operating system pipe UNIX Linux Windows 2000 Windows XP named pipe unnamed pipe performance thread runtime ed bradford"
name=keywords>
<META http-equiv=PICS-Label
content='(PICS-1.1 "http://www.rsac.org/ratingsv01.html" l gen true comment "RSACi North America Server" by "webmaster@mail.software.ibm.com" for "http://www.ibm.com/software" on "1997.08.13T17:59-0800" r (n 0 s 0 v 0 l 0))'>
<META http-equiv=Expires content=0>
<SCRIPT language=JavaScript
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/style.js"
type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/spinbox.js"
type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript type=text/javascript>
var forumURL = "http://www-105.ibm.com/developerworks/linux_df.nsf/AllViewTemplate?OpenForm&RestrictToCategory=1";
</SCRIPT>
<SCRIPT language=JavaScript
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/forumwindow.js"
type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript type=text/javascript>
var emailAbstract = "This month Ed begins a series of investigations into operating system programming interfaces, starting with pipes. He has also added a new operating system to the lineup; Windows XP has recently released. In this installment, Ed will be working with pipes on Windows 2000 Advanced Server (with Service Pack 2 installed), Linux (based on Red Hat 7.1), and the newly released Windows XP professional. Share your thoughts on this article with the author and other readers in the discussion forum by clicking Discuss at the top or bottom of the article. ";
</SCRIPT>
<SCRIPT language=JavaScript
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/grabtitle.js"
type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/emailfriend2.js"
type=text/javascript></SCRIPT>
<META content="MSHTML 5.50.4134.600" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=2 topMargin=2 marginwidth="2" marginheight="2">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD class=tbgc width=160><A
href="http://www-106.ibm.com/developerworks/cgi-bin/click.cgi?url=http://www.ibm.com/&origin=dwheader"><IMG
height=47 alt=IBM
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/ibm-logo.gif"
width=160 border=0></A></TD>
<TD class=tbg width=195><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/index.html#main"><IMG
height=1 alt="Skip to main content"
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=195 border=0></A></TD>
<TD class=tbgc vAlign=top align=right width="100%">
<TABLE cellSpacing=0 cellPadding=0 border=0>
<FORM id=form1 name=form1
action=http://www-109.ibm.com/cgi-bin/dWsearch.pl method=get>
<TBODY>
<TR>
<TD colSpan=6><IMG height=4 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=390 border=0></TD></TR>
<TR vAlign=center>
<TD class=dwsearch height=8><SELECT class=dwsearch
name=selScope><OPTION value=dW selected>All of dW<OPTION
value=dW>.................<OPTION value=dW>dW zones:<OPTION
value=javaZ> Java technology<OPTION
value=linuxZ> Linux<OPTION value=opensrcZ> Open
source<OPTION value=webservZ> Web services<OPTION
value=wirelessZ> Wireless<OPTION value=xmlZ> XML<OPTION
value=dW>.................<OPTION value=dW>dW special
topics:<OPTION value=securityZ> Security<OPTION
value=unicodeZ> Unicode<OPTION
value=usabilityZ> Usability<OPTION value=webarchZ> Web
arch.<OPTION value=dW>.................<OPTION
value=aW>alphaWorks<OPTION value=dW>.................<OPTION
value=dW>Product domains:<OPTION value=ibmofferZ> IBM
Developer<OPTION
value=ibmofferZ> Solutions<OPTION
value=WSDD> WebSphere<OPTION
value=WSDD> (WSDD)<OPTION
value=VADD> VisualAge for<OPTION
value=VADD> Java (VADD)<OPTION
value=dW>.................<OPTION value=all>All of
IBM</OPTION></SELECT></TD>
<TD class=small><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=5 border=0></TD>
<TD><INPUT class=dwsearch maxLength=100 size=15 name=UserRestriction
height="15"></FONT></TD>
<TD><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=5 border=0></TD>
<TD width=64><INPUT type=image height=23 alt="Search button"
width=64
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/search.gif"
value=Search border=0 name=Search></TD>
<TD vAlign=top><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=34 border=0></TD></TR>
<TR vAlign=top>
<TD class=dwsmall colSpan=6><A style="COLOR: #ffffff" target=_blank
href="http://www-109.ibm.com/redirectdWPS.htm">Advanced
search</A><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=1 border=0></TD></TR>
<TR>
<TD colSpan=6><IMG height=4 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=390 border=0></TD></TR></FORM></TBODY></TABLE></TD></TR>
<TR>
<TD class=hbg width=160 height=21> </TD>
<TD class=bbg vAlign=top colSpan=2 height=21> <A
class=mainlink
href="http://www-106.ibm.com/developerworks/cgi-bin/click.cgi?url=http://www.ibm.com/&origin=dwheader">IBM
home</A><SPAN class=divider> | </SPAN><A
class=mainlink
href="http://www-106.ibm.com/developerworks/cgi-bin/click.cgi?url=http://www.ibm.com/products/&origin=dwheader">Products
& services</A><SPAN class=divider> | </SPAN><A
class=mainlink
href="http://www-106.ibm.com/developerworks/cgi-bin/click.cgi?url=http://www.ibm.com/support/&origin=dwheader">Support
& downloads</A> <SPAN class=divider> | </SPAN><A
class=mainlink
href="http://www-106.ibm.com/developerworks/cgi-bin/click.cgi?url=http://www.ibm.com/account/&origin=dwheader">My
account</A> </TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR class=hil>
<TD width="100%" height=1><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=600></TD></TR>
<TR class=dwr1>
<TD width="100%" height=2><IMG height=2 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=600></TD></TR>
<TR class=dwg3>
<TD width="100%" height=1><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=600></TD></TR>
<TR class=bbg>
<TD width="100%" height=1><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=600></TD></TR>
<TR class=hil>
<TD width="100%" height=1><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=600></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR vAlign=top>
<TD width=5><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=5 border=0></TD>
<TD width="100%">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR vAlign=top>
<TD width="100%"><IMG height=4 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=2 border=0><BR><B><A
href="http://www-106.ibm.com/developerworks/">IBM developerWorks</A>
: <A href="http://www-106.ibm.com/developerworks/linux/">Linux</A> |
<A href="http://www-106.ibm.com/developerworks/opensource/">Open
source projects</A> : <A
href="http://www-105.ibm.com/developerworks/papers.nsf/dw/linux-papers-bynewest?OpenDocument&Count=500">Linux
articles</A> | <A
href="http://www-105.ibm.com/developerworks/papers.nsf/dw/opensource-papers-bynewest?OpenDocument&Count=500">Open
source projects articles</A></B> </TD>
<TD align=right width=136><A
href="http://www-106.ibm.com/developerworks/"><IMG height=24
alt=developerWorks
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/dwlogo-small.gif"
width=136 border=0></A> </TD>
<TD width=5><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=5 border=0></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><A
name=main></A>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR vAlign=top>
<TD colSpan=5><IMG height=15 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=5 border=0></TD></TR>
<TR vAlign=top>
<TD width=2><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=2 border=0></TD>
<TD><SPAN class=astitle>RunTime: </SPAN><SPAN class=atitle>Pipes in Linux,
Windows 2000, and Windows XP </SPAN></TD>
<TD width=8><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=8 border=0></TD>
<TD align=right width=180><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=180 border=0><BR><NOBR><A
href="javascript:void%20forumWindow()"><IMG height=26 alt=Discuss
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/icon-discuss.gif"
width=42 border=0></A> <A
href="ftp://www6.software.ibm.com/software/developer/library/l-rt4.pdf"><IMG
height=26 alt=250KBKB
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/icon-pdf.gif"
width=35 border=0></A> <A href="javascript:void%20newWindow()"><IMG
height=26 alt="e-mail it!"
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/icon-email.gif"
width=46 border=0></A> </NOBR></TD>
<TD width=6><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=6 border=0></TD></TR>
<TR vAlign=top>
<TD bgColor=#000000 colSpan=5><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=100 border=0></TD></TR>
<TR vAlign=top>
<TD bgColor=#ffffff colSpan=5><IMG height=8 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=100 border=0></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR vAlign=top>
<TD width=5><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=5 border=0></TD>
<TD width="100%">
<TABLE cellSpacing=0 cellPadding=0 width=168 align=right border=0>
<TBODY>
<TR>
<TD width=8><IMG height=21 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=5></TD>
<TD width=160>
<TABLE cellSpacing=0 cellPadding=0 width=160 border=0>
<TBODY>
<TR>
<TD width=160 bgColor=#000000 height=1><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD align=middle
background="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/bg-gold.gif"
height=5><B>Contents:</B></TD></TR>
<TR>
<TD width=160 bgColor=#666666 height=1><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 width=160 border=0>
<TBODY>
<TR>
<TD><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/index.html#1">Pipes</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/index.html#2">Windows
pipes</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/index.html#3">Linux
pipes</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/index.html#4">Pipe
speeds for a single threaded process</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/index.html#5">Pipe
speeds for a threaded process</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/index.html#6">Conclusion</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR><!--Standard links for every article-->
<TR>
<TD><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/index.html#resources">Resources</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/index.html#author1">About
the author</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/index.html#rating">Rate
this article</A></TD></TR>
<TR>
<TD><IMG height=10 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=160 border=0>
<TBODY>
<TR>
<TD width=160 bgColor=#000000 height=1><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD align=middle
background="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/bg-gold.gif"
height=5><B>Related content:</B></TD></TR>
<TR>
<TD width=160 bgColor=#666666 height=1><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 width=160 border=0>
<TBODY>
<TR>
<TD><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt2/index.html">Block
memory copy, Part 1</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt3/index.html">Block
memory copy, Part 2</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR></TBODY></TABLE></TD>
<TD><!--Related Zone content-->
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR><!--Related Zone Navigation content-->
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 width=160 border=0>
<TBODY>
<TR>
<TD width=160 bgColor=#000000 height=1><IMG height=1
alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD align=middle
background="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/bg-gold.gif"
height=5><A class=nav
href="http://www-106.ibm.com/developerworks/linux/"><B>Also
in the Linux zone:</B></A></TD></TR>
<TR>
<TD width=160 bgColor=#666666 height=1><IMG height=1
alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 width=160 border=0>
<TBODY>
<TR>
<TD><A
href="http://www-105.ibm.com/developerworks/education.nsf/dw/linux-onlinecourse-bynewest?OpenDocument&Count=500">Tutorials</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD><A
href="http://www-105.ibm.com/developerworks/tools.nsf/dw/linux-compilers-byname?OpenDocument&Count=500">Tools
and products</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD><A
href="http://www-105.ibm.com/developerworks/tools.nsf/dw/linux-code-bytitle?OpenDocument&Count=500">Code
and components</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD><A
href="http://www-105.ibm.com/developerworks/papers.nsf/dw/linux-papers-bynewest?OpenDocument&Count=10">Articles</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 width=160 border=0>
<TBODY>
<TR>
<TD width=160 bgColor=#000000 height=1><IMG height=1
alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD align=middle
background="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/bg-gold.gif"
height=5><A class=nav
href="http://www-124.ibm.com/developerworks/oss/"><B>Also
in the Open source projects zone:</B></A></TD></TR>
<TR>
<TD width=160 bgColor=#666666 height=1><IMG height=1
alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 width=160 border=0>
<TBODY>
<TR>
<TD><A
href="http://www-105.ibm.com/developerworks/education.nsf/dw/opensource-onlinecourse-bynewest?OpenDocument&Count=500">Tutorials</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD><A
href="http://www-105.ibm.com/developerworks/tools.nsf/dw/opensource-projects-byname?OpenDocument&Count=500">Projects
and patches</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD><A
href="http://www-105.ibm.com/developerworks/tools.nsf/dw/opensource-code-bytitle?OpenDocument&Count=500">Code
and components</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD><A
href="http://www-105.ibm.com/developerworks/papers.nsf/dw/opensource-papers-bynewest?OpenDocument&Count=10">Articles</A></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD height=1><IMG height=5 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=160 border=0>
<TBODY>
<TR>
<TD width=150 bgColor=#000000 colSpan=2 height=2><IMG height=2
alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR>
<TR>
<TD width=150 bgColor=#ffffff colSpan=2 height=2><IMG height=2
alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=160></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><SPAN
class=atitle2>High-performance programming techniques on Linux and Windows
</SPAN>
<P><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/index.html#author1">Dr.
Edward G. Bradford</A> (<A
href="mailto:egb@us.ibm.com">egb@us.ibm.com</A>)<BR>Senior programmer,
IBM<BR>October 2001</P>
<BLOCKQUOTE>This month Ed begins a series of investigations into
operating system programming interfaces, starting with pipes. He has
also added a new operating system to the lineup; Windows XP has recently
released. In this installment, Ed will be working with pipes on Windows
2000 Advanced Server (with Service Pack 2 installed), Linux (based on
Red Hat 7.1), and the newly released Windows XP professional. Share your
thoughts on this article with the author and other readers in the <A
href="javascript:void%20forumWindow()">discussion forum</A> by clicking
<B>Discuss</B> at the top or bottom of the article. </BLOCKQUOTE>
<P>Before we get started, please note that our nomenclature will be
slightly different now that there are two versions of Windows on the
market. I will refer to "Windows" when making no distinction between
Windows 2000 and Windows XP. When there is a distinction, I will use
"Windows 2000" or "Windows XP". </P>
<P><A name=1><SPAN class=atitle2>Pipes</SPAN></A><BR>A pipe is an
interprocess communication mechanism available on both Windows and Linux
(and UNIX). Pipes originally appeared in the Bell Laboratories version of
UNIX and have remained in all UNIXes and Linux since their inception. A
pipe is a stream of bytes accessed through normal IO interfaces. It is
created, and then written to or read from using whatever read or write IO
system calls are available on the operating system. In the UNIX and Linux
case, the IO calls are <CODE>read()</CODE> and <CODE>write()</CODE>. In
the Windows world, the APIs are <CODE>ReadFile()</CODE> and
<CODE>WriteFile()</CODE>. Windows pipes differ from Linux pipes in that a
single handle (analogous to a Linux file descriptor) supports
bi-directional IO. Linux pipes return two file descriptors to effect
bi-directional IO.</P>
<P><A name=2><SPAN class=atitle2>Windows pipes</SPAN></A><BR>Windows pipes
are more complicated than Linux pipes. Windows supports named and unnamed
pipes. The unnamed variety are simply named pipes where the interface
doesn't divulge the name. Windows supports asynchronous IO on pipes
whereby a single thread will not block on an IO call to a pipe. Different
IO interfaces are required to use the asynchronous IO feature. Windows
pipes are of two varieties: byte type and message type. The byte-type
pipes are similar to UNIX pipes and support byte streams. I won't be
investigating the message-type pipes in this article, although a complete
comparison would have to include them. Windows pipes are created with the
<CODE>CreateNamedPipe()</CODE> API. Once created, the
<CODE>OpenFile()</CODE> API is used to access the other end of the newly
created named pipe. Pipe names live in a flat name space. For example,
<CODE>\\.\pipe\anyname</CODE> would be a legitimate name for a Windows
named pipe. In C or C++ the name is expressed as:</P>
<P><CODE>char *pipeAdult = "\\\\.\\pipe\\anyname";</CODE> </P>
<P>Only the <I>anyname</I> part can be specified. To use a Windows pipe,
it must be created by one API, and opened with another. The example code
snippet shows how this is done.</P>
<P><A name=""><B>Creating a Windows named pipe</B></A>
<TABLE cellSpacing=0 cellPadding=5 width="100%" bgColor=#cccccc
border=1><TBODY>
<TR>
<TD><PRE><CODE>
        //
        // Create named pipe in Windows
        // nbytes -- block size from command line arguments.
        //
        int mult = 1;
        int x;
        x = mult*nbytes + 24;
        handleA = CreateNamedPipe(pipeAdult,
                                PIPE_ACCESS_DUPLEX,
                                PIPE_TYPE_BYTE,
                                2, // two connections
                                x, // input buffer size
                                x, // output buffer size
                                INFINITE, // timeout
                                NULL); // security
        if(handleA == INVALID_HANDLE_VALUE) {
                printf("CreateNamedPipe() FAILED: err=%d
", GetLastError());
                return 1;
        }
        handleB = CreateFile(pipeAdult,
                                GENERIC_READ|GENERIC_WRITE,
                                FILE_SHARE_READ|FILE_SHARE_WRITE,
                                NULL,
                                OPEN_EXISTING,
                                FILE_ATTRIBUTE_NORMAL,
                                NULL);
        if(handleB == INVALID_HANDLE_VALUE) {
                printf("CreateFile() FAILED: err=%d
", GetLastError());
                return 1;
        }
</CODE></PRE></TD></TR></TBODY></TABLE></P>
<P>The number 24 in the first executable line of code above was determined
experimentally. I found no mention of it anywhere in the Platform SDK. If
it is not present, the program doesn't work. Apparently, the pipe facility
requires a 24-byte header on each write to the pipe. </P>
<P><A name=3><SPAN class=atitle2>Linux pipes</SPAN></A><BR>Linux pipes are
simpler to create and use if, for no other reason, fewer parameters are
needed. To accomplish the same pipe creation task as Windows, Linux and
UNIX use the following snippet:</P>
<P><A name=""><B>Creating a Linux named pipe</B></A>
<TABLE cellSpacing=0 cellPadding=5 width="100%" bgColor=#cccccc
border=1><TBODY>
<TR>
<TD><PRE><CODE>
        int fd1[2];
        if(pipe(fd1)) {
                printf("pipe() FAILED: errno=%d
",errno);
                return 1;
        }
</CODE></PRE></TD></TR></TBODY></TABLE></P>
<P>Linux pipes have a limitation on the size of a write before it blocks.
The kernel level buffer dedicated to each pipe is exactly 4096 bytes big.
A write of more than 4K will block unless a reader empties the pipe. In
practice this is not much of a limitation because the read and write
actions are performed in different threads. </P>
<P><A name=4><SPAN class=atitle2>Pipe speeds for a single threaded
process</SPAN></A><BR>I wrote a program (pipespeed2.cpp) to test how fast
the operating system pipe code executes. It creates a pipe and writes and
reads data, all in a single thread. Because Linux can support only a 4K
write before the writer blocks, our test stopped at the 4K block size. The
bash shell script that generated our numbers was simple:</P>
<P><A name=""><B>Bash shell file for generating test results</B></A>
<TABLE cellSpacing=0 cellPadding=5 width="100%" bgColor=#cccccc
border=1><TBODY>
<TR>
<TD><PRE><CODE>
list="1 2 3 4 6 8 10 12 14 16 20 24 28 32 36 40 44 48 52 56 60 64 72 80 88"
list="$list 96 104 112 120 128 144 160 176 192 208 224 240 256 288 320 352"
list="$list 384 416 448 480 512 576 640 704 768 832 896 960 1024 1280 1536"
list="$list 1792 2048 2560 3k 3584 4k"
uname -s -r
for bytes in $list
do
case $bytes in
????|?k ) count=100k;;
?????|??k) count=100k;;
?|??|??? ) count=500k;;
esac
pipespeed2 $count $bytes
done
</CODE></PRE></TD></TR></TBODY></TABLE></P>
<P>The output of each run was saved to a file and edited with a text
editor to produce a text file easily imported into Microsoft Excel.</P>
<P><A name=21><SPAN class=atitle3>Compiling the
programs</SPAN></A><BR>Programs in this article are compiled with:
<UL>
<LI>Linux: gcc -O2 pipespeed2.cpp -o pipespeed2
<LI>Windows: cl -O2 pipespeed2.cpp </LI></UL>
<P>and</P>
<UL>
<LI>Linux: gcc -O2 pipespeed2t.cpp -lpthread -o pipespeed2t
<LI>Windows: cl -O2 pipespeed2t.cpp </LI></UL>
<P></P>
<P>Figure 1 shows the results for the Linux 2.4.2 kernel delivered with
Red Hat 7.1. </P>
<P><IMG height=584
alt="Results for the Linux 2.4.2 kernel delivered with Red Hat 7.1"
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/figure01.jpg"
width=730 border=0> </P>
<P>Figure 2 shows the same program compiled to run on Windows for Windows
2000 Advanced Server. Most of the non-essential services were disabled.
</P>
<P><IMG height=584
alt="Results for same program on Windows 2000 Advanced Server"
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/figure02.jpg"
width=730 border=0> </P>
<P>Figure 3 shows the results for the newly released Windows XP. </P>
<P><IMG height=584 alt="Results same program on for Windows XP"
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/figure03.jpg"
width=730 border=0> </P>
<P>Each test run consisted of three runs (the three series). As you can
see in the graphs, Linux pipes are considerably faster than the Windows
2000 namedpipes. The Windows XP named pipes are much slower than Windows
2000 named pipes. The version of Windows XP Professional under test is the
released "evaluation" version.</P>
<P><A name=5><SPAN class=atitle2>Pipe speeds for a threaded
process</SPAN></A><BR>The Windows 2000 graph shows signs of further
improvement if the block size is increased beyond 4K To test block sizes
greater than 4K an enhanced version of the pipespeed2.cpp program was
written. The new program creates a second thread. The first thread writes
the data, and the second thread reads the data. The purpose of the first
program was to understand the overhead associated with the code paths of
pipe support without the context switch overhead. It is an artificial
environment probably never used. </P>
<P>The enhanced version of pipespeed2.cpp is called pipespeed2t.cpp. Two
threads will necessarily context switch back and forth to transmit all the
data. Thus, the second program has an additional overhead of context
switching missing in the first. Timing is stopped only after all the data
has been sent and the second thread has terminated properly. </P>
<P>Figures 4, 5, and 6 show Linux, Windows 2000, and Windows XP
respectively. It is apparent that Windows XP has suffered a serious and
visible performance degradation in the named pipe facility. While Linux
easily outperforms Windows 2000, Windows 2000 easily outperforms Windows
XP. </P>
<P>Figure 4 shows the results for the threaded version of pipespeed2t.cpp
running on a Linux 2.4.2 kernel delivered with Red Hat 7.1. Its peak IO
rate is around 700 MB/sec. </P>
<P><IMG height=584
alt="Results for the threaded version of pipespeed2t.cpp running on a Linux 2.4.2 kernel delivered with Red Hat 7.1"
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/figure04.jpg"
width=730 border=0> </P>
<P>Figure 5 shows the threaded results for Windows 2000. Its peak IO rate
is near 500 MB/sec.</P>
<P><IMG height=584 alt="Threaded results for Windows 2000"
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/figure05.jpg"
width=730 border=0> </P>
<P>Both graphs show the same shape but Linux reaches a steady state at
near 100 MB/sec for very large block sizes. Windows 2000 reaches a steady
state for large block sizes also, but it is only at the 80 MB/sec rate.
</P>
<P>Figure 6 shows the threaded results for Windows XP Professional
(evaluation version). Its peak IO rate is only 120 MB/sec.</P>
<P><IMG height=584 alt="Threaded results for Windows XP"
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/figure06.jpg"
width=730 border=0> </P>
<P>Windows XP shows disappointing results along the full range of block
sizes. Perhaps one of the Microsoft experts in our <A
href="javascript:void%20forumWindow()">discussion forum</A> will add a
useful comment on how to improve our program and the performance of
Windows XP named pipes.</P>
<P>Information easily generated by simple programs can inform program
designers, software architects, and even system administrators about the
features of an operating system. Simplicity is required to avoid endless
debate over "realistic" scenarios. "Simplicity" should represent the way
people write programs. In this case I have done nothing special to improve
performance on any of the platforms.</P>
<P>The poor performance of Windows XP is perplexing. One possible
explanation might lie in the existence of a better solution for
transferring data -- sockets. I will be looking at sockets in a future
column. </P>
<P>Linux also supports named pipes. An early reviewer of these numbers
suggested I compare Linux named pipes with Windows named pipes to be fair.
I wrote another program that used named pipes on Linux. I found the
results for named and unnamed pipes on Linux indistinguishable. </P>
<P>Another distinction might the the "feature" of Windows pipes where
there is no fixed buffer size. For the first test we stopped at a 4K
buffer size in deference to the Linux buffer. Windows advocates might
suggest that the arbitrary buffer sizes associated with Windows named
pipes are a benefit. To demonstrate the arbitrary size of the Windows
named pipe buffers, we can simply run the single threaded program with
arbitrarily large block sizes. I did a run with pipespeed2.cpp on Windows
and specified a 256 MB buffer size. Windows obliged by swelling the buffer
size to hold 256 MB of data <I>before</I> the <CODE>ReadFile()</CODE> was
issued. The system slowed to a crawl and I didn't wait until the operation
completed. Whether this "feature" of Windows is useful or not is up to the
public. However, the swelling and contracting of internal buffers requires
page allocations and deallocations -- operations not generally associated
with simple streams of bytes. </P>
<P><A name=6><SPAN class=atitle2>Conclusion</SPAN></A><BR>We wrote two
programs to demonstrate good programming practices when using pipe
facilities on Windows and Linux. The first program <CODE><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/pipespeed2.cpp">pipespeed2.cpp</A>
</CODE>demonstrated the performance of the pipe facility code path using a
single thread to pass data into and out of the operating system. The
second program <CODE><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/pipespeed2t.cpp">pipespeed2t.cpp</A>
</CODE>used two threads to pass arbitrarily large amounts of data. The
second program is a more realistic representation of the normal usage of
pipe facilities.</P>
<P>Our results showed that Linux pipes are considerably faster than
Windows 2000 named pipes, and Windows 2000 named pipes are much faster
than Windows XP named pipes. </P>
<P><A name=resources><SPAN class=atitle2>Resources</SPAN></A>
<UL>
<LI>Participate in the <A
href="javascript:void%20forumWindow()">discussion forum</A> on this
article by clicking <B>Discuss</B> at the top or bottom of the article.
<LI>View listings of programs mentioned in this article:
<UL>
<LI><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/pipespeed2.cpp">pipespeed2.cpp</A>
<LI><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/pipespeed2t.cpp">pipespeed2t.cpp</A>
<LI><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/pipespeed2-sh.sh">pipespeed2-sh.sh</A>
<LI><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/pipespeed2t-sh.sh">pipespeed2t-sh.sh</A>
<LI><A
href="http://www-106.ibm.com/developerworks/linux/library/l-rt4/pipespeed2.xls">pipespeed2.xls</A>
</LI></UL>
<LI>Read Ed's previous RunTime columns on <I>developerWorks</I>:
<UL>
<LI><A
href="http://www-106.ibm.com/developerworks/library/l-rt1/">Introductory
column</A>
<LI><A
href="http://www-106.ibm.com/developerworks/library/l-rt2/">Block
memory copy</A>
<LI><A
href="http://www-106.ibm.com/developerworks/library/l-rt3/">Block
memory copy, Part 2</A> </LI></UL>
<LI>Read these related articles on <I>developerWorks</I>:
<UL>
<LI><A
href="http://www-106.ibm.com/developerworks/linux/library/l-flex.html">Operating
system flexibility</A>
<LI><A
href="http://www-106.ibm.com/developerworks/linux/library/linux-nt/index.html">Linux,
the server operating system</A> </LI></UL>
<LI>Browse <A
href="http://www-106.ibm.com/developerworks/linux/?article=lr">more
Linux resources</A> on <I>developerWorks</I>
<LI>Browse <A
href="http://www-124.ibm.com/developerworks/opensource/?article=osr">more
Open source resources</A> on <I>developerWorks</I>. </LI></UL>
<P></P>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><A name=author1><SPAN class=atitle2>About the
author</SPAN><BR>Ed currently manages Microsoft Premier Support for
IBM Software group and writes a weekly newsletter for Linux and
Windows 2000 Software Developers. Ed can be reached at <A
href="mailto:egb@us.ibm.com">egb@us.ibm.com</A>.
</TD></TR></TBODY></TABLE><BR clear=all><IMG height=10 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=100 border=0><BR>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR vAlign=top>
<TD align=right width="100%"><A
href="javascript:void%20forumWindow()"><IMG height=26 alt=Discuss
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/icon-discuss.gif"
width=42 border=0></A> <A
href="ftp://www6.software.ibm.com/software/developer/library/l-rt4.pdf"><IMG
height=26 alt=250KBKB
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/icon-pdf.gif"
width=35 border=0></A> <A href="javascript:void%20newWindow()"><IMG
height=26 alt="e-mail it!"
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/icon-email.gif"
width=46 border=0></A> </TD>
<TD width=5><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=5 border=0></TD></TR>
<TR vAlign=top>
<TD bgColor=#000000 colSpan=2><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=100 border=0></TD></TR>
<TR vAlign=top>
<TD bgColor=#ffffff colSpan=2><IMG height=8 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=100 border=0></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR vAlign=top>
<TD>
<FORM
action=http://www-105.ibm.com/developerworks/ratings.nsf/RateArticle?CreateDocument
method=post><INPUT type=hidden
value="RunTime: Pipes in Linux, Windows 2000, and Windows XP "
name=ArticleTitle> <INPUT type=hidden value="Linux, Open source"
name=Zone> <INPUT type=hidden
value=http://www-106.ibm.com/developerworks/thankyou/feedback-thankyou.html
name=RedirectURL> <A name=rating><B>What do you think of this
article?</B></A>
<TABLE cellSpacing=0 cellPadding=0 width=600 border=0>
<TBODY>
<TR>
<TD colSpan=5><IMG height=8 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=100 border=0></TD></TR>
<TR vAlign=top>
<TD width="16%"><INPUT type=radio value=5 name=Rating>Killer!
(5)</TD>
<TD width="20%"><INPUT type=radio value=4 name=Rating>Good
stuff (4)</TD>
<TD width="24%"><INPUT type=radio value=3 name=Rating>So-so;
not bad (3)</TD>
<TD width="22%"><INPUT type=radio value=2 name=Rating>Needs
work (2)</TD>
<TD width="18%"><INPUT type=radio value=1 name=Rating>Lame!
(1)</TD></TR></TBODY></TABLE><BR><B>Send us your comments or click
Discuss to share your comments with others.</B> <BR><TEXTAREA name=Comments rows=5 wrap=virtual cols=60></TEXTAREA>
<BR><BR><INPUT type=submit value="Submit feedback"> </FORM></TD></TR>
<TR vAlign=top>
<TD bgColor=#ffffff><IMG height=8 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=100 border=0></TD></TR></TBODY></TABLE></TD>
<TD width=1><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=1 border=0></TD></TR></TBODY></TABLE><!-- IBM FOOTER -->
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD><IMG height=1 alt=""
src="RunTime Pipes in Linux, Windows 2000, and Windows XP_files/c.gif"
width=1></TD></TR>
<TR vAlign=top>
<TD class=bbg height=21> <A class=mainlink
href="http://www-106.ibm.com/developerworks/cgi-bin/click.cgi?url=http://www.ibm.com/ibm/?origin=dwheader">About
IBM</A><SPAN class=divider> | </SPAN><A
class=mainlink
href="http://www-106.ibm.com/developerworks/cgi-bin/click.cgi?url=http://www.ibm.com/privacy/?origin=dwheader">Privacy</A><SPAN
class=divider> | </SPAN><A class=mainlink
href="http://www-106.ibm.com/developerworks/cgi-bin/click.cgi?url=http://www.ibm.com/legal/?origin=dwheader">Legal</A><SPAN
class=divider> | </SPAN><A class=mainlink
href="http://www-106.ibm.com/developerworks/cgi-bin/click.cgi?url=http://www.ibm.com/contact/?origin=dwheader">Contact</A></TD></TR></TBODY></TABLE><!-- END IBM FOOTER --></BODY></HTML>