<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="None">
  <name>Dataflow Programming</name>
  <metadata>
  <md:version>1.1</md:version>
  <md:created>2004/06/16 13:34:42 GMT-5</md:created>
  <md:revised>2004/07/16 14:52:09.843 GMT-5</md:revised>
  <md:authorlist>
      <md:author id="NationalInstruments">
      <md:firstname>National</md:firstname>
      
      <md:surname>Instruments</md:surname>
      <md:email>certification@ni.com</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="lizzardg">
      <md:firstname>Elizabeth</md:firstname>
      
      <md:surname>Gregory</md:surname>
      <md:email>lizzardg@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="mshiralkar05">
      <md:firstname>Malan</md:firstname>
      
      <md:surname>Shiralkar</md:surname>
      <md:email>mshiralkar05@hotmail.com</md:email>
    </md:maintainer>
    <md:maintainer id="harika">
      <md:firstname>Harika</md:firstname>
      
      <md:surname>Basana</md:surname>
      <md:email>ilsai@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="NationalInstruments">
      <md:firstname>National</md:firstname>
      
      <md:surname>Instruments</md:surname>
      <md:email>certification@ni.com</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>National Instruments</md:keyword>
    <md:keyword>LabVIEW</md:keyword>
    <md:keyword>Dataflow Programming</md:keyword>
  </md:keywordlist>

  <md:abstract>In this section, you will learn about dataflow programming.</md:abstract>
</metadata>
  
  <content>
    <para id="para1">
      LabVIEW follows a dataflow model for running VIs. A block
      diagram node executes when all its inputs are available. When a
      node completes execution, it supplies data to its output
      terminals and passes the output data to the next node in the
      dataflow path.
    </para>
    <para id="para2">
      Visual Basic, C++, JAVA, and most other text-based programming
      languages follow a control flow model of program execution. In
      control flow, the sequential order of program elements
      determines the execution order of a program.
    </para>
    <example id="ex1">
      <para id="para3">
	For a dataflow programming example, consider a <cnxn target="f1">block diagram</cnxn> that adds two numbers and
	then subtracts
	<m:math>
	  <m:cn>50.00</m:cn> </m:math> from the result of the
	addition. In this case, the block diagram executes from left
	to right, not because the objects are placed in that order,
	but because the <code>Subtract</code> function cannot execute
	until the <code>Add</code> function finishes executing and
	passes the data to the <code>Subtract</code>
	function. Remember that a node executes only when data are
	available at all of its input terminals, and it supplies data
	to its output terminals only when it finishes execution.
	<figure id="f1">
	  <media type="image/png" src="dataflow.png"/>
	</figure>
      </para>
    </example>
    <example id="ex2">
      <para id="para4">
	In the following <cnxn target="f2">example</cnxn>, consider
	which code segment would execute first-the <code>Add</code>,
	<code>Random Number</code>, or <code>Divide</code>
	function. You cannot know because inputs to the
	<code>Add</code> and <code>Divide</code> functions are
	available at the same time, and the <code>Random Number</code>
	function has no inputs. In a situation where one code segment
	must execute before another, and no data dependency exists
	between the functions, use other programming methods, such as
	error clusters, to force the order of execution. Refer to the
	<cnxn document="m12231">Error Handling</cnxn> section of Clusters for more information about error
	clusters.
	<figure id="f2">
	  <media type="image/png" src="dataflowno.png"/>
	</figure>
      </para>
    </example>
  </content>
  
</document>
