<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2845929896695469094</id><updated>2024-09-08T08:17:01.194-07:00</updated><category term="interview"/><category term="Must read"/><category term="must_read"/><category term="data structure"/><category term="swiss trip"/><category term="puzzel"/><category term="PMP"/><category term="song"/><category term="***Most Imp***"/><category term="Tools"/><category term="books"/><category term="english"/><category term="good life"/><category term="good links"/><category term="hacking"/><category term="tcp"/><category term="Android"/><category term="Android_Mobile"/><category term="BW"/><category term="Big O Notation"/><category term="Locking"/><category term="Travel"/><category term="algorithm"/><category term="attack"/><category term="c interview"/><category term="confusion"/><category term="cool apps"/><category term="fun video"/><category term="linux"/><category term="network test tool"/><category term="personal"/><category term="programming book"/><category term="sorting"/><category term="trip"/><category term="tutorial video"/><category term="v v imp"/><title type='text'>Neeraj Gupta</title><subtitle type='html'>I usually just copy-paste whatever I want to access on internet.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>232</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-1929159060948326102</id><published>2015-06-07T21:02:00.001-07:00</published><updated>2015-06-07T21:13:28.456-07:00</updated><title type='text'>TCP Slow Start, Congestion Avoidance,              Fast Retransmit, and Fast Recovery Algorithms</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;pre style=&quot;font-size: 13.3333330154419px;&quot;&gt;&lt;span class=&quot;h2&quot; style=&quot;display: inline; font-size: 1em; font-weight: bold; line-height: 0pt;&quot;&gt;&lt;h2 style=&quot;display: inline; font-size: 1em; line-height: 0pt;&quot;&gt;
&lt;a class=&quot;selflink&quot; href=&quot;https://tools.ietf.org/html/rfc2001#section-1&quot; name=&quot;section-1&quot; style=&quot;color: black; text-decoration: none;&quot;&gt;1&lt;/a&gt;.  Slow Start&lt;/h2&gt;
&lt;/span&gt;

   Old TCPs would start a connection with the sender injecting multiple
   segments into the network, up to the window size advertised by the
   receiver.  While this is OK when the two hosts are on the same LAN,
   if there are routers and slower links between the sender and the
   receiver, problems can arise.  Some intermediate router must queue
   the packets, and it&#39;s possible for that router to run out of space.
   [&lt;a href=&quot;https://tools.ietf.org/html/rfc2001#ref-2&quot; title=&quot;&amp;quot;Congestion Avoidance and Control,&amp;quot;&quot;&gt;2&lt;/a&gt;] shows how this naive approach can reduce the throughput of a TCP
   connection drastically.



&lt;span class=&quot;grey&quot; style=&quot;color: #777777;&quot;&gt;Stevens                     Standards Track                     [Page 1]&lt;/span&gt;&lt;/pre&gt;
&lt;hr align=&quot;left&quot; class=&quot;noprint&quot; style=&quot;font-size: 13.3333330154419px; width: 96ex;&quot; /&gt;
&lt;pre class=&quot;newpage&quot; style=&quot;font-size: 13.3333330154419px; page-break-before: always;&quot;&gt;&lt;a class=&quot;invisible&quot; href=&quot;https://tools.ietf.org/html/rfc2001#page-2&quot; id=&quot;page-2&quot; name=&quot;page-2&quot; style=&quot;color: white; text-decoration: none;&quot;&gt; &lt;/a&gt;
&lt;span class=&quot;grey&quot; style=&quot;color: #777777;&quot;&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc2001&quot; style=&quot;color: #777777;&quot;&gt;RFC 2001&lt;/a&gt;                          TCP                       January 1997&lt;/span&gt;


   The algorithm to avoid this is called slow start.  It operates by
   observing that the rate at which new packets should be injected into
   the network is the rate at which the acknowledgments are returned by
   the other end.

   Slow start adds another window to the sender&#39;s TCP:  the congestion
   window, called &quot;cwnd&quot;.  When a new connection is established with a
   host on another network, the congestion window is initialized to one
   segment (i.e., the segment size announced by the other end, or the
   default, typically 536 or 512).  Each time an ACK is received, the
   congestion window is increased by one segment.  The sender can
   transmit up to the minimum of the congestion window and the
   advertised window.  The congestion window is flow control imposed by
   the sender, while the advertised window is flow control imposed by
   the receiver.  The former is based on the sender&#39;s assessment of
   perceived network congestion; the latter is related to the amount of
   available buffer space at the receiver for this connection.

   The sender starts by transmitting one segment and waiting for its
   ACK.  When that ACK is received, the congestion window is incremented
   from one to two, and two segments can be sent.  When each of those
   two segments is acknowledged, the congestion window is increased to
   four.  This provides an exponential growth, although it is not
   exactly exponential because the receiver may delay its ACKs,
   typically sending one ACK for every two segments that it receives.

   At some point the capacity of the internet can be reached, and an
   intermediate router will start discarding packets.  This tells the
   sender that its congestion window has gotten too large.

   Early implementations performed slow start only if the other end was
   on a different network.  Current implementations always perform slow
   start.

&lt;span class=&quot;h2&quot; style=&quot;display: inline; font-size: 1em; font-weight: bold; line-height: 0pt;&quot;&gt;&lt;h2 style=&quot;display: inline; font-size: 1em; line-height: 0pt;&quot;&gt;
&lt;a class=&quot;selflink&quot; href=&quot;https://tools.ietf.org/html/rfc2001#section-2&quot; name=&quot;section-2&quot; style=&quot;color: black; text-decoration: none;&quot;&gt;2&lt;/a&gt;.  Congestion Avoidance&lt;/h2&gt;
&lt;/span&gt;

   Congestion can occur when data arrives on a big pipe (a fast LAN) and
   gets sent out a smaller pipe (a slower WAN).  Congestion can also
   occur when multiple input streams arrive at a router whose output
   capacity is less than the sum of the inputs.  Congestion avoidance is
   a way to deal with lost packets.  It is described in [&lt;a href=&quot;https://tools.ietf.org/html/rfc2001#ref-2&quot; title=&quot;&amp;quot;Congestion Avoidance and Control,&amp;quot;&quot;&gt;2&lt;/a&gt;].

   The assumption of the algorithm is that packet loss caused by damage
   is very small (much less than 1%), therefore the loss of a packet
   signals congestion somewhere in the network between the source and
   destination.  There are two indications of packet loss:  a timeout
   occurring and the receipt of duplicate ACKs.




&lt;span class=&quot;grey&quot; style=&quot;color: #777777;&quot;&gt;Stevens                     Standards Track                     [Page 2]&lt;/span&gt;&lt;/pre&gt;
&lt;hr align=&quot;left&quot; class=&quot;noprint&quot; style=&quot;font-size: 13.3333330154419px; width: 96ex;&quot; /&gt;
&lt;pre class=&quot;newpage&quot; style=&quot;font-size: 13.3333330154419px; page-break-before: always;&quot;&gt;&lt;a class=&quot;invisible&quot; href=&quot;https://tools.ietf.org/html/rfc2001#page-3&quot; id=&quot;page-3&quot; name=&quot;page-3&quot; style=&quot;color: white; text-decoration: none;&quot;&gt; &lt;/a&gt;
&lt;span class=&quot;grey&quot; style=&quot;color: #777777;&quot;&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc2001&quot; style=&quot;color: #777777;&quot;&gt;RFC 2001&lt;/a&gt;                          TCP                       January 1997&lt;/span&gt;


   Congestion avoidance and slow start are independent algorithms with
   different objectives.  But when congestion occurs TCP must slow down
   its transmission rate of packets into the network, and then invoke
   slow start to get things going again.  In practice they are
   implemented together.

   Congestion avoidance and slow start require that two variables be
   maintained for each connection: a congestion window, cwnd, and a slow
   start threshold size, ssthresh.  The combined algorithm operates as
   follows:

   1.  Initialization for a given connection sets cwnd to one segment
       and ssthresh to 65535 bytes.

   2.  The TCP output routine never sends more than the minimum of cwnd
       and the receiver&#39;s advertised window.

   3.  When congestion occurs (indicated by a timeout or the reception
       of duplicate ACKs), one-half of the current window size (the
       minimum of cwnd and the receiver&#39;s advertised window, but at
       least two segments) is saved in ssthresh.  Additionally, if the
       congestion is indicated by a timeout, cwnd is set to one segment
       (i.e., slow start).

   4.  When new data is acknowledged by the other end, increase cwnd,
       but the way it increases depends on whether TCP is performing
       slow start or congestion avoidance.

      If cwnd is less than or equal to ssthresh, TCP is in slow start;
      otherwise TCP is performing congestion avoidance.  Slow start
      continues until TCP is halfway to where it was when congestion
      occurred (since it recorded half of the window size that caused
      the problem in step 2), and then congestion avoidance takes over.

      Slow start has cwnd begin at one segment, and be incremented by
      one segment every time an ACK is received.  As mentioned earlier,
      this opens the window exponentially:  send one segment, then two,
      then four, and so on.  Congestion avoidance dictates that cwnd be
      incremented by segsize*segsize/cwnd each time an ACK is received,
      where segsize is the segment size and cwnd is maintained in bytes.
      This is a linear growth of cwnd, compared to slow start&#39;s
      exponential growth.  &lt;b&gt;The increase in cwnd should be at most one
      segment each round-trip time (regardless how many ACKs are
      received in that RTT), whereas slow start increments cwnd by the
      number of ACKs received in a round-trip time.&lt;/b&gt;






&lt;span class=&quot;grey&quot; style=&quot;color: #777777;&quot;&gt;Stevens                     Standards Track                     [Page 3]&lt;/span&gt;&lt;/pre&gt;
&lt;hr align=&quot;left&quot; class=&quot;noprint&quot; style=&quot;font-size: 13.3333330154419px; width: 96ex;&quot; /&gt;
&lt;pre class=&quot;newpage&quot; style=&quot;font-size: 13.3333330154419px; page-break-before: always;&quot;&gt;&lt;a class=&quot;invisible&quot; href=&quot;https://tools.ietf.org/html/rfc2001#page-4&quot; id=&quot;page-4&quot; name=&quot;page-4&quot; style=&quot;color: white; text-decoration: none;&quot;&gt; &lt;/a&gt;
&lt;span class=&quot;grey&quot; style=&quot;color: #777777;&quot;&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc2001&quot; style=&quot;color: #777777;&quot;&gt;RFC 2001&lt;/a&gt;                          TCP                       January 1997&lt;/span&gt;


   Many implementations incorrectly add a small fraction of the segment
   size (typically the segment size divided by 8) during congestion
   avoidance.  This is wrong and should not be emulated in future
   releases.

&lt;span class=&quot;h2&quot; style=&quot;display: inline; font-size: 1em; font-weight: bold; line-height: 0pt;&quot;&gt;&lt;h2 style=&quot;display: inline; font-size: 1em; line-height: 0pt;&quot;&gt;
&lt;a class=&quot;selflink&quot; href=&quot;https://tools.ietf.org/html/rfc2001#section-3&quot; name=&quot;section-3&quot; style=&quot;color: black; text-decoration: none;&quot;&gt;3&lt;/a&gt;.  Fast Retransmit&lt;/h2&gt;
&lt;/span&gt;

   Modifications to the congestion avoidance algorithm were proposed in
   1990 [&lt;a href=&quot;https://tools.ietf.org/html/rfc2001#ref-3&quot; title=&quot;&amp;quot;Modified TCP Congestion Avoidance Algorithm,&amp;quot;&quot;&gt;3&lt;/a&gt;].  Before describing the change, realize that TCP may
   generate an immediate acknowledgment (a duplicate ACK) when an out-
   of-order segment is received (Section 4.2.2.21 of [&lt;a href=&quot;https://tools.ietf.org/html/rfc2001#ref-1&quot; title=&quot;&amp;quot;Requirements for Internet Hosts -- Communication Layers,&amp;quot;&quot;&gt;1&lt;/a&gt;], with a note
   that one reason for doing so was for the experimental fast-
   retransmit algorithm).  This duplicate ACK should not be delayed.
   The purpose of this duplicate ACK is to let the other end know that a
   segment was received out of order, and to tell it what sequence
   number is expected.

   Since TCP does not know whether a duplicate ACK is caused by a lost
   segment or just a reordering of segments, it waits for a small number
   of duplicate ACKs to be received.  It is assumed that if there is
   just a reordering of the segments, there will be only one or two
   duplicate ACKs before the reordered segment is processed, which will
   then generate a new ACK.  If three or more duplicate ACKs are
   received in a row, it is a strong indication that a segment has been
   lost.  TCP then performs a retransmission of what appears to be the
   missing segment, without waiting for a retransmission timer to
   expire.

&lt;span class=&quot;h2&quot; style=&quot;display: inline; font-size: 1em; font-weight: bold; line-height: 0pt;&quot;&gt;&lt;h2 style=&quot;display: inline; font-size: 1em; line-height: 0pt;&quot;&gt;
&lt;a class=&quot;selflink&quot; href=&quot;https://tools.ietf.org/html/rfc2001#section-4&quot; name=&quot;section-4&quot; style=&quot;color: black; text-decoration: none;&quot;&gt;4&lt;/a&gt;.  Fast Recovery&lt;/h2&gt;
&lt;/span&gt;

   After fast retransmit sends what appears to be the missing segment,
   congestion avoidance, but not slow start is performed.  This is the
   fast recovery algorithm.  It is an improvement that allows high
   throughput under moderate congestion, especially for large windows.

   The reason for not performing slow start in this case is that the
   receipt of the duplicate ACKs tells TCP more than just a packet has
   been lost.  Since the receiver can only generate the duplicate ACK
   when another segment is received, that segment has left the network
   and is in the receiver&#39;s buffer.  That is, there is still data
   flowing between the two ends, and TCP does not want to reduce the
   flow abruptly by going into slow start.

   The fast retransmit and fast recovery algorithms are usually
   implemented together as follows.






&lt;span class=&quot;grey&quot; style=&quot;color: #777777;&quot;&gt;Stevens                     Standards Track                     [Page 4]&lt;/span&gt;&lt;/pre&gt;
&lt;hr align=&quot;left&quot; class=&quot;noprint&quot; style=&quot;font-size: 13.3333330154419px; width: 96ex;&quot; /&gt;
&lt;pre class=&quot;newpage&quot; style=&quot;font-size: 13.3333330154419px; page-break-before: always;&quot;&gt;&lt;a class=&quot;invisible&quot; href=&quot;https://tools.ietf.org/html/rfc2001#page-5&quot; id=&quot;page-5&quot; name=&quot;page-5&quot; style=&quot;color: white; text-decoration: none;&quot;&gt; &lt;/a&gt;
&lt;span class=&quot;grey&quot; style=&quot;color: #777777;&quot;&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc2001&quot; style=&quot;color: #777777;&quot;&gt;RFC 2001&lt;/a&gt;                          TCP                       January 1997&lt;/span&gt;


   1.  When the third duplicate ACK in a row is received, set ssthresh
       to one-half the current congestion window, cwnd, but no less
       than two segments.  Retransmit the missing segment.  Set cwnd to
       ssthresh plus 3 times the segment size.  This inflates the
       congestion window by the number of segments that have left the
       network and which the other end has cached (3).

   2.  Each time another duplicate ACK arrives, increment cwnd by the
       segment size.  This inflates the congestion window for the
       additional segment that has left the network.  Transmit a
       packet, if allowed by the new value of cwnd.

   3.  When the next ACK arrives that acknowledges new data, set cwnd
       to ssthresh (the value set in step 1).  This ACK should be the
       acknowledgment of the retransmission from step 1, one round-trip
       time after the retransmission.  Additionally, this ACK should
       acknowledge all the intermediate segments sent between the lost
       packet and the receipt of the first duplicate ACK.  This step is
       congestion avoidance, since TCP is down to one-half the rate it
       was at when the packet was lost.

   The fast retransmit algorithm first appeared in the 4.3BSD Tahoe
   release, and it was followed by slow start.  The fast recovery
   algorithm appeared in the 4.3BSD Reno release.

&lt;span class=&quot;h2&quot; style=&quot;display: inline; font-size: 1em; font-weight: bold; line-height: 0pt;&quot;&gt;&lt;h2 style=&quot;display: inline; font-size: 1em; line-height: 0pt;&quot;&gt;
&lt;a class=&quot;selflink&quot; href=&quot;https://tools.ietf.org/html/rfc2001#section-5&quot; name=&quot;section-5&quot; style=&quot;color: black; text-decoration: none;&quot;&gt;5&lt;/a&gt;.  Security Considerations&lt;/h2&gt;
&lt;/span&gt;

   Security considerations are not discussed in this memo.&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/1929159060948326102/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2015/06/tcp-slow-start-congestion-avoidance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/1929159060948326102'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/1929159060948326102'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2015/06/tcp-slow-start-congestion-avoidance.html' title='TCP Slow Start, Congestion Avoidance,              Fast Retransmit, and Fast Recovery Algorithms'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-8418132085899526401</id><published>2015-05-26T06:47:00.000-07:00</published><updated>2015-05-26T06:47:22.448-07:00</updated><title type='text'>TCP : Fast Retransmit </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.3999996185303px; margin-bottom: 0.5em; margin-top: 0.5em;&quot;&gt;
&lt;b&gt;Fast Retransmit&lt;/b&gt;&amp;nbsp;is an enhancement to&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Transmission_Control_Protocol&quot; style=&quot;background: none; color: #0b0080; text-decoration: none;&quot; title=&quot;Transmission Control Protocol&quot;&gt;TCP&lt;/a&gt;&amp;nbsp;which reduces the time a sender waits before retransmitting a lost&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Protocol_data_unit&quot; style=&quot;background: none; color: #0b0080; text-decoration: none;&quot; title=&quot;Protocol data unit&quot;&gt;segment&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.3999996185303px; margin-bottom: 0.5em; margin-top: 0.5em;&quot;&gt;
A TCP sender uses a timer to recognize lost segments. If an acknowledgement is not received for a particular segment within a specified time (a function of the estimated&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Round-trip_delay_time&quot; style=&quot;background: none; color: #0b0080; text-decoration: none;&quot; title=&quot;Round-trip delay time&quot;&gt;Round-trip delay time&lt;/a&gt;), the sender will assume the segment was lost in the&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Computer_network&quot; style=&quot;background: none; color: #0b0080; text-decoration: none;&quot; title=&quot;Computer network&quot;&gt;network&lt;/a&gt;, and will retransmit the segment.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.3999996185303px; margin-bottom: 0.5em; margin-top: 0.5em;&quot;&gt;
Duplicate acknowledgement is the basis for the fast retransmit mechanism which works as follows: after receiving a packet (e.g. with sequence number 1), the receiver sends an acknowledgement by adding 1 to the sequence number (i.e., acknowledgement number 2) which means that the receiver receives the packet number 1 and it expects packet number 2 from the sender. Let&#39;s assume that three subsequent packets have been lost. In the meantime the receiver receives packet numbers 5 and 6. After receiving packet number 5, the receiver sends an acknowledgement, but still only for sequence number 2. When the receiver receives packet number 6, it sends yet another acknowledgement value of 2. Because the sender receives more than one acknowledgement with the same sequence number (2 in this example) this is called&amp;nbsp;&lt;i&gt;duplicate acknowledgement&lt;/i&gt;.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #252525; font-family: sans-serif; font-size: 14px; line-height: 22.3999996185303px; margin-bottom: 0.5em; margin-top: 0.5em;&quot;&gt;
The fast retransmit enhancement works as follows: if a TCP sender receives a specified number of acknowledgements which is usually set to three duplicate acknowledgements with the same acknowledge number (that is, a total of four acknowledgements with the same acknowledgement number), the sender can be reasonably confident that the segment with the next higher sequence number was dropped, and will not arrive out of order. The sender will then retransmit the packet that was presumed dropped before waiting for its timeout.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/8418132085899526401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2015/05/tcp-fast-retransmit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/8418132085899526401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/8418132085899526401'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2015/05/tcp-fast-retransmit.html' title='TCP : Fast Retransmit '/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-2448518101814996535</id><published>2015-05-25T21:16:00.000-07:00</published><updated>2015-05-25T21:16:25.435-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="data structure"/><title type='text'>LCM findFirstCommonAncestor</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;background-color: white; color: #444444; font-family: monospace; font-size: 13px; line-height: 20.7999992370605px; white-space: pre;&quot;&gt;TreeNode findFirstCommonAncestor(TreeNode root, int p, int q) {

    if (root == null) {
        return null;
    }

    if (root.value == p || root.value == q) {
 return root;
    }

    if (root.value &amp;gt; p &amp;amp;&amp;amp; root.value &amp;gt; q ) {
        return findFirstCommonAncestor(root.left, p, q);
    } 
    else if (root.value &amp;lt; p &amp;amp;&amp;amp; root.value &amp;lt; q ) {
        return findFirstCommonAncestor(root.right, p, q);
    } 
    else {
        return root;
    }
}&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/2448518101814996535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2015/05/lcm-findfirstcommonancestor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/2448518101814996535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/2448518101814996535'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2015/05/lcm-findfirstcommonancestor.html' title='LCM findFirstCommonAncestor'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-5316395666519747095</id><published>2015-05-24T20:51:00.002-07:00</published><updated>2015-05-24T20:51:23.163-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="data structure"/><title type='text'>Height of a Tree</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 align=&quot;right&quot; style=&quot;color: #575757; font-family: Georgia, &#39;Times New Roman&#39;, Times, Helvetica, Arial, serif; font-size: 1.7em; font-weight: lighter; letter-spacing: -0.05em;&quot;&gt;
&lt;a href=&quot;http://geeksquiz.com/&quot; style=&quot;color: #006600; text-decoration: none;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;GeeksQuiz&lt;/a&gt;&lt;/h2&gt;
&lt;br /&gt;
&lt;div class=&quot;clear&quot; style=&quot;-webkit-text-stroke-width: 0px; background-color: white; clear: both; color: black; font-family: Helvetica, Arial, Verdana, sans-serif; font-size: 10.8000001907349px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div id=&quot;menu&quot; style=&quot;-webkit-text-stroke-width: 0px; background: rgb(235, 247, 255); border-bottom-color: rgb(193, 228, 253); border-bottom-style: solid; border-bottom-width: 1px; border-top-color: rgb(193, 228, 253); border-top-style: solid; border-top-width: 1px; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 10.8000001907349px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 0px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; width: 842.390625px; word-spacing: 0px;&quot;&gt;
&lt;ul style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;li style=&quot;float: left; list-style-type: none; margin: 0px; padding: 0.7em 1em;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; text-decoration: none;&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;float: left; list-style-type: none; margin: 0px; padding: 0.7em 1em;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/fundamentals-of-algorithms/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; text-decoration: none;&quot;&gt;Algorithms&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;float: left; list-style-type: none; margin: 0px; padding: 0.7em 1em;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/data-structures/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; text-decoration: none;&quot;&gt;DS&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;float: left; list-style-type: none; margin: 0px; padding: 0.7em 1em;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/gate-corner/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; text-decoration: none;&quot;&gt;GATE&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;float: left; list-style-type: none; margin: 0px; padding: 0.7em 1em;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/about/interview-corner/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; text-decoration: none;&quot;&gt;Interview Corner&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;float: left; list-style-type: none; margin: 0px; padding: 0.7em 1em;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/forums/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; text-decoration: none;&quot;&gt;Q&amp;amp;A&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;float: left; list-style-type: none; margin: 0px; padding: 0.7em 1em;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/c/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; text-decoration: none;&quot;&gt;C&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;float: left; list-style-type: none; margin: 0px; padding: 0.7em 1em;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/c-plus-plus/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; text-decoration: none;&quot;&gt;C++&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;float: left; list-style-type: none; margin: 0px; padding: 0.7em 1em;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/java/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; text-decoration: none;&quot;&gt;Java&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;float: left; list-style-type: none; margin: 0px; padding: 0.7em 1em;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/books/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; text-decoration: none;&quot;&gt;Books&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;float: left; list-style-type: none; margin: 0px; padding: 0.7em 1em;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/contribute/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; text-decoration: none;&quot;&gt;Contribute&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;float: left; list-style-type: none; margin: 0px; padding: 0.7em 1em;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/contests/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; text-decoration: none;&quot;&gt;Contests&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;float: left; list-style-type: none; margin: 0px; padding: 0.7em 1em;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/jobs/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; text-decoration: none;&quot;&gt;Jobs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;clear&quot; style=&quot;clear: both;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;navmenu&quot; style=&quot;-webkit-text-stroke-width: 0px; background-color: white; color: black; font-family: Helvetica, Arial, Verdana, sans-serif; font-size: 10.8000001907349px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 0px 0px 1em; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px;&quot;&gt;
&lt;ul id=&quot;menu&quot; style=&quot;background: rgb(235, 247, 255); border-bottom-color: rgb(193, 228, 253); border-bottom-style: solid; border-bottom-width: 1px; border-top-color: rgb(193, 228, 253); border-top-style: solid; border-top-width: 1px; font-family: Arial, Helvetica, sans-serif; margin: 0px; padding: 0px; width: 842.390625px;&quot;&gt;
&lt;li class=&quot;cat-item cat-item-3&quot; style=&quot;display: inline;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/category/c-arrays/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; margin: 1px; padding: 5px 10px; text-decoration: none;&quot; title=&quot;Questions regarding Arrays&quot;&gt;Array&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li class=&quot;cat-item cat-item-17&quot; style=&quot;display: inline;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/category/bit-magic/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; margin: 1px; padding: 5px 10px; text-decoration: none;&quot; title=&quot;View all posts filed under Bit Magic&quot;&gt;Bit Magic&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li class=&quot;cat-item cat-item-14&quot; style=&quot;display: inline;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/category/c-puzzles/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; margin: 1px; padding: 5px 10px; text-decoration: none;&quot; title=&quot;View all posts filed under C/C++ Puzzles&quot;&gt;C/C++&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li class=&quot;cat-item cat-item-18&quot; style=&quot;display: inline;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/category/articles/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; margin: 1px; padding: 5px 10px; text-decoration: none;&quot; title=&quot;View all posts filed under Articles&quot;&gt;Articles&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li class=&quot;cat-item cat-item-67&quot; style=&quot;display: inline;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/category/gfact/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; margin: 1px; padding: 5px 10px; text-decoration: none;&quot; title=&quot;View all posts filed under GFacts&quot;&gt;GFacts&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li class=&quot;cat-item cat-item-8&quot; style=&quot;display: inline;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/category/linked-list/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; margin: 1px; padding: 5px 10px; text-decoration: none;&quot; title=&quot;Linked List problems&quot;&gt;Linked List&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li class=&quot;cat-item cat-item-66&quot; style=&quot;display: inline;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/category/multiple-choice-question/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; margin: 1px; padding: 5px 10px; text-decoration: none;&quot; title=&quot;View all posts filed under MCQ&quot;&gt;MCQ&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li class=&quot;cat-item cat-item-4&quot; style=&quot;display: inline;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/category/c-programs/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; margin: 1px; padding: 5px 10px; text-decoration: none;&quot; title=&quot;Miscellaneous&quot;&gt;Misc&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li class=&quot;cat-item cat-item-5&quot; style=&quot;display: inline;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/category/program-output/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; margin: 1px; padding: 5px 10px; text-decoration: none;&quot; title=&quot;View all posts filed under Output&quot;&gt;Output&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li class=&quot;cat-item cat-item-7&quot; style=&quot;display: inline;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/category/c-strings/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; margin: 1px; padding: 5px 10px; text-decoration: none;&quot; title=&quot;Questions related to strings&quot;&gt;String&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li class=&quot;cat-item cat-item-19&quot; style=&quot;display: inline;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/category/tree/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; margin: 1px; padding: 5px 10px; text-decoration: none;&quot; title=&quot;View all posts filed under Trees&quot;&gt;Tree&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li class=&quot;cat-item cat-item-19&quot; style=&quot;display: inline;&quot;&gt;&lt;a href=&quot;http://www.geeksforgeeks.org/category/graph/&quot; style=&quot;color: #25395f; font-size: 1.2em; font-weight: bold; margin: 1px; padding: 5px 10px; text-decoration: none;&quot; title=&quot;View all posts filed under Graph&quot;&gt;Graph&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;b style=&quot;background-color: white; font-family: Helvetica, Arial, Verdana, sans-serif; font-size: 10.8000001907349px;&quot;&gt;&lt;/b&gt;&lt;span style=&quot;background-color: white; font-family: Helvetica, Arial, Verdana, sans-serif; font-size: 10.8000001907349px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div id=&quot;content&quot; style=&quot;background-color: white; float: left; font-family: Helvetica, Arial, Verdana, sans-serif; font-size: 10.8000001907349px; width: 52em;&quot;&gt;
&lt;div class=&quot;post&quot; id=&quot;post&quot;&gt;
&lt;div class=&quot;post-info&quot; style=&quot;height: 2580.5px;&quot;&gt;
&lt;div class=&quot;post-title-info&quot; style=&quot;float: left; font-size: 1.1em; width: 440px;&quot;&gt;
&lt;h2 class=&quot;post-title&quot; style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, Times, Helvetica, Arial, serif; font-size: 1.7em; font-weight: 100; letter-spacing: -0.05em; margin: 0px auto 0.2em 0px;&quot;&gt;
Write a C Program to Find the Maximum Depth or Height of a Tree&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&quot;clear&quot; style=&quot;clear: both;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;post-content&quot; id=&quot;post-content&quot; style=&quot;font-size: 1.2em; line-height: 1.5em; padding: 0.1em 0px;&quot;&gt;
Maximum depth or height of the below tree is 3.&lt;br /&gt;&lt;span id=&quot;more-646&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;wp-caption aligncenter&quot; id=&quot;attachment_650&quot; style=&quot;background-color: #f3f3f3; border: 1px solid rgb(221, 221, 221); margin: 10px; padding-top: 4px; text-align: center; width: 269px;&quot;&gt;
&lt;img alt=&quot;Example Tree&quot; class=&quot;size-full wp-image-650&quot; height=&quot;156&quot; src=&quot;http://geeksforgeeks.org/wp-content/uploads/2009/06/tree122.gif&quot; style=&quot;border: 0px none; margin: 0px; padding: 0px;&quot; title=&quot;tree12&quot; width=&quot;259&quot; /&gt;&lt;div class=&quot;wp-caption-text&quot; style=&quot;font-size: 11px; line-height: 17px; padding: 0px 4px 5px;&quot;&gt;
Example Tree&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Recursively calculate height of left and right subtrees of a node and assign height to the node as max of the heights of two children plus 1. See below pseudo code and program for details.&lt;br /&gt;
&lt;strong&gt;Algorithm:&lt;/strong&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #f9f9f9; font-size: 1.1em;&quot;&gt; maxDepth()
1. If tree is empty then return 0
2. Else
     (a) Get the max depth of left subtree recursively  i.e., 
          call maxDepth( tree-&amp;gt;left-subtree)
     (a) Get the max depth of right subtree recursively  i.e., 
          call maxDepth( tree-&amp;gt;right-subtree)
     (c) Get the max of max depths of left and right 
          subtrees and add 1 to it for the current node.
         max_depth = max(max dept of left subtree,  
                             max depth of right subtree) 
                             + 1
     (d) Return max_depth
&lt;/pre&gt;
&lt;strong&gt;See the below diagram for more clarity about execution of the recursive function maxDepth() for above example tree.&lt;/strong&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #f9f9f9; font-size: 1.1em;&quot;&gt;            maxDepth(&#39;1&#39;) = max(maxDepth(&#39;2&#39;), maxDepth(&#39;3&#39;)) + 1
                               = 2 + 1
                                  /    \
                                /         \
                              /             \
                            /                 \
                          /                     \
               maxDepth(&#39;1&#39;)                  maxDepth(&#39;3&#39;) = 1
= max(maxDepth(&#39;4&#39;), maxDepth(&#39;5&#39;)) + 1
= 1 + 1   = 2         
                   /    \
                 /        \
               /            \
             /                \
           /                    \
 maxDepth(&#39;4&#39;) = 1     maxDepth(&#39;5&#39;) = 1
&lt;/pre&gt;
&lt;strong&gt;Implementation:&lt;/strong&gt;&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter nogutter  cpp&quot; id=&quot;highlighter_864440&quot; style=&quot;font-size: 1em !important; margin: 1em 0px !important; overflow-x: auto !important; overflow-y: hidden !important; position: relative !important; width: 561.59375px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; table-layout: auto !important; top: auto !important; vertical-align: baseline !important; width: 561px;&quot;&gt;&lt;tbody style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 561px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp preprocessor&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: gray !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;#include&lt;stdio .h=&quot;&quot;&gt;&lt;/stdio&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp preprocessor&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: gray !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;#include&lt;stdlib .h=&quot;&quot;&gt;&lt;/stdlib&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp comments&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;/* A binary tree node has data, pointer to left child &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp comments&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;and a pointer to right child */&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;struct&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;node &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp color1 bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: gray !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;data;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;struct&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;node* left;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;struct&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;node* right;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;};&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number14 index13 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp comments&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;/* Compute the &quot;maxDepth&quot; of a tree -- the number of &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number15 index14 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp comments&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;nodes along the longest path from the root node &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number16 index15 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp comments&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;down to the farthest leaf node.*/&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number17 index16 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp color1 bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: gray !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;maxDepth(&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;struct&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;node* node) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number18 index17 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number19 index18 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;if&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;(node==NULL) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number20 index19 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;return&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;0;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number21 index20 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;else&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number22 index21 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number23 index22 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp comments&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;/* compute the depth of each subtree */&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number24 index23 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp color1 bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: gray !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;lDepth = maxDepth(node-&amp;gt;left);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number25 index24 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp color1 bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: gray !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;rDepth = maxDepth(node-&amp;gt;right);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number26 index25 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number27 index26 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp comments&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;/* use the larger one */&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number28 index27 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;if&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;(lDepth &amp;gt; rDepth) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number29 index28 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;return&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;(lDepth+1);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number30 index29 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;else&lt;/code&gt; &lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;return&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;(rDepth+1);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number31 index30 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number32 index31 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number33 index32 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number34 index33 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp comments&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;/* Helper function that allocates a new node with the&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number35 index34 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp comments&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 130, 0) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;given data and NULL left and right pointers. */&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number36 index35 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;struct&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;node* newNode(&lt;/code&gt;&lt;code class=&quot;cpp color1 bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: gray !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;data) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number37 index36 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number38 index37 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;struct&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;node* node = (&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;struct&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;node*)&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number39 index38 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp functions bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(255, 20, 147) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;malloc&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;sizeof&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;struct&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;node));&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number40 index39 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;node-&amp;gt;data = data;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number41 index40 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;node-&amp;gt;left = NULL;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number42 index41 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;node-&amp;gt;right = NULL;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number43 index42 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number44 index43 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;return&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;(node);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number45 index44 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number46 index45 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number47 index46 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp color1 bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: gray !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;main()&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number48 index47 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number49 index48 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;struct&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;node *root = newNode(1);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number50 index49 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number51 index50 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;root-&amp;gt;left = newNode(2);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number52 index51 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;root-&amp;gt;right = newNode(3);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number53 index52 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;root-&amp;gt;left-&amp;gt;left = newNode(4);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number54 index53 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;root-&amp;gt;left-&amp;gt;right = newNode(5); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number55 index54 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number56 index55 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp functions bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(255, 20, 147) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;printf&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;cpp string&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: blue !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&quot;Hight of tree is %d&quot;&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;, maxDepth(root));&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number57 index56 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number58 index57 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp functions bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(255, 20, 147) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;getchar&lt;/code&gt;&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;();&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number59 index58 alt2&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp spaces&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;cpp keyword bold&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;return&lt;/code&gt; &lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;0;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number60 index59 alt1&quot; style=&quot;-webkit-box-shadow: none !important; background-attachment: initial !important; background-clip: initial !important; background-image: none !important; background-origin: initial !important; background-position: initial !important; background-repeat: initial !important; background-size: initial !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; float: none !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 0em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;cpp plain&quot; style=&quot;-webkit-box-shadow: none !important; background: none !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; box-shadow: none !important; box-sizing: content-box !important; direction: ltr !important; display: inline !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 1em !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;strong&gt;&lt;br /&gt;Time Complexity:&amp;nbsp;&lt;/strong&gt;O(n) (Please see our post&amp;nbsp;&lt;a href=&quot;http://geeksforgeeks.org/?p=618&quot; style=&quot;color: #006600; text-decoration: none;&quot;&gt;Tree Traversal&amp;nbsp;&lt;/a&gt;for details)&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/5316395666519747095/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2015/05/height-of-tree.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/5316395666519747095'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/5316395666519747095'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2015/05/height-of-tree.html' title='Height of a Tree'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-92151196657277971</id><published>2013-11-19T23:21:00.000-08:00</published><updated>2013-11-19T23:21:24.570-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="interview"/><title type='text'>Interview Question at narus</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
1. What is virtual memory and advantage and disadvantage of virtual memory&lt;br /&gt;
2. &amp;nbsp;how compiler manage scoping of static variable&lt;br /&gt;
3. difference between macro and const variable&lt;br /&gt;
4. network buffers : linux&lt;br /&gt;
5. how watchdog run how do find that some CPU is locked&lt;br /&gt;
6. who restrict size of virtual memory&lt;br /&gt;
7. what is kernal memory size , can it be virtual&lt;br /&gt;
8. static gloabl and same static local variable in function is possible&lt;br /&gt;
9. what is volatile&lt;br /&gt;
10. fork what all it do&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/92151196657277971/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/interview-question-at-narus.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/92151196657277971'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/92151196657277971'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/interview-question-at-narus.html' title='Interview Question at narus'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-2031202251099955341</id><published>2013-11-19T23:16:00.003-08:00</published><updated>2013-11-19T23:17:02.245-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="***Most Imp***"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><title type='text'>Linux kernal flow : v imp</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;content-header&quot; style=&quot;background-color: white; color: #4d4d4d; font-family: Tahoma, Verdana, Arial, Helvetica, &#39;Bitstream Vera Sans&#39;, sans-serif; font-size: 12px; line-height: 17.1875px;&quot;&gt;
&lt;h1 class=&quot;title&quot; style=&quot;clear: both; font-weight: normal; line-height: 1.3em; margin: 0px;&quot;&gt;
kernel_flow&lt;/h1&gt;
&lt;/div&gt;
&lt;div id=&quot;content-area&quot; style=&quot;background-color: white; color: #4d4d4d; font-family: Tahoma, Verdana, Arial, Helvetica, &#39;Bitstream Vera Sans&#39;, sans-serif; font-size: 12px; line-height: 17.1875px;&quot;&gt;
&lt;div class=&quot;node clear-block&quot; id=&quot;node-5282&quot;&gt;
&lt;div class=&quot;meta&quot;&gt;
&lt;span class=&quot;submitted&quot; style=&quot;font-size: 0.83em;&quot;&gt;By Linux Foundatio... - November 19, 2009 - 10:23am&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;terms terms-inline&quot; style=&quot;display: inline;&quot;&gt;
&lt;ul class=&quot;links inline&quot; style=&quot;border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; display: inline; float: right; font-variant: small-caps; margin: 0px 0px 20px; padding: 0px 0px 6px; width: 670px;&quot;&gt;
&lt;li class=&quot;taxonomy_term_41 first last&quot; style=&quot;display: inline; list-style-type: none; margin: 0px; padding: 0px 0.7em;&quot;&gt;&lt;a href=&quot;http://www.linuxfoundation.org/tags/networking&quot; rel=&quot;tag&quot; style=&quot;color: #336699; padding-bottom: 2px; padding-top: 2px;&quot; title=&quot;&quot;&gt;networking&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
by&amp;nbsp;&lt;a href=&quot;http://www.linuxfoundation.org/users/Vdcappel&quot; style=&quot;color: #336699;&quot; title=&quot;Vdcappel&quot;&gt;Arnout Vandecappelle&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://www.mind.be/&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://www.mind.be&quot;&gt;Mind&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow&quot;&gt;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow&lt;/a&gt;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a class=&quot;image&quot; href=&quot;http://www.linuxfoundation.org/images/thumb/1/1c/Network_data_flow_through_kernel.png/100px-Network_data_flow_through_kernel.png&quot; style=&quot;color: #336699;&quot; title=&quot;Network data flow through kernel.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;56&quot; src=&quot;http://www.linuxfoundation.org/images/thumb/1/1c/Network_data_flow_through_kernel.png/100px-Network_data_flow_through_kernel.png&quot; style=&quot;border: 0px;&quot; width=&quot;100&quot; /&gt;&lt;/a&gt;&amp;nbsp;This article describes the control flow (and the associated data buffering) of the Linux networking kernel. The picture on the left gives an overview of the flow.&amp;nbsp;&lt;a class=&quot;internal&quot; href=&quot;http://www.linuxfoundation.org/images/1/1c/Network_data_flow_through_kernel.png&quot; style=&quot;color: #336699;&quot; title=&quot;Network data flow through kernel.png&quot;&gt;Open it&lt;/a&gt;&amp;nbsp;in a separate window and use it as a reference for the explanation below.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
This article is based on the 2.6.20 kernel. Please feel free to update for newer kernels.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a class=&quot;external text&quot; href=&quot;http://gicl.cs.drexel.edu/people/sevy/network/Linux_network_stack_walkthrough.html&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://gicl.cs.drexel.edu/people/sevy/network/Linux_network_stack_walkthrough.html&quot;&gt;Another article&lt;/a&gt;&amp;nbsp;gives a similar description based on a 2.4.20 kernel. Unfortunately, that one is not on a Wiki so it can&#39;t be updated...&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;br clear=&quot;all&quot; /&gt;&lt;/div&gt;
&lt;table class=&quot;toc&quot; id=&quot;toc&quot; style=&quot;border-collapse: collapse; margin: 1em 0px;&quot; summary=&quot;Contents&quot;&gt;&lt;tbody style=&quot;border-top-style: none;&quot;&gt;
&lt;tr&gt;&lt;td&gt;&lt;h2 style=&quot;font-size: 1.3em; line-height: 1.3em; margin-bottom: 0.667em; margin-top: 0.667em;&quot;&gt;
Contents&lt;/h2&gt;
&lt;ul style=&quot;margin: 1em 0px; padding-left: 2em;&quot;&gt;
&lt;li class=&quot;toclevel-1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow#Preliminaries&quot; style=&quot;color: #336699;&quot;&gt;1 Preliminaries&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow#Transmission_path&quot; style=&quot;color: #336699;&quot;&gt;2 Transmission path&lt;/a&gt;&lt;ul style=&quot;margin: 0px; padding-left: 2em;&quot;&gt;
&lt;li class=&quot;toclevel-2&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow#Layer_5:_Session_layer_.28sockets_and_files.29&quot; style=&quot;color: #336699;&quot;&gt;2.1 Layer 5: Session layer (sockets and files)&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow#Layer_4:_Transport_layer_.28TCP.29&quot; style=&quot;color: #336699;&quot;&gt;2.2 Layer 4: Transport layer (TCP)&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow#Layer_3:_Network_layer_.28IPv4.29&quot; style=&quot;color: #336699;&quot;&gt;2.3 Layer 3: Network layer (IPv4)&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow#Layer_2:_Link_layer_.28e.g._Ethernet.29&quot; style=&quot;color: #336699;&quot;&gt;2.4 Layer 2: Link layer (e.g. Ethernet)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow#Receive_flow&quot; style=&quot;color: #336699;&quot;&gt;3 Receive flow&lt;/a&gt;&lt;ul style=&quot;margin: 0px; padding-left: 2em;&quot;&gt;
&lt;li class=&quot;toclevel-2&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow#Layer_2:_Link_layer_.28e.g._Ethernet.29_2&quot; style=&quot;color: #336699;&quot;&gt;3.1 Layer 2: Link layer (e.g. Ethernet)&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow#Layer_3:_Network_layer_.28IPv4.2C_ARP.29&quot; style=&quot;color: #336699;&quot;&gt;3.2 Layer 3: Network layer (IPv4, ARP)&lt;/a&gt;&lt;ul style=&quot;margin: 0px; padding-left: 2em;&quot;&gt;
&lt;li class=&quot;toclevel-3&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow#ARP&quot; style=&quot;color: #336699;&quot;&gt;3.2.1 ARP&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-3&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow#IPv4&quot; style=&quot;color: #336699;&quot;&gt;3.2.2 IPv4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow#Layer_4:_Transport_layer_.28TCP.29_2&quot; style=&quot;color: #336699;&quot;&gt;3.3 Layer 4: Transport layer (TCP)&lt;/a&gt;&lt;/li&gt;
&lt;li class=&quot;toclevel-2&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow#Layer_5:_Session_layer_.28sockets_and_files.29_2&quot; style=&quot;color: #336699;&quot;&gt;3.4 Layer 5: Session layer (sockets and files)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;Preliminaries&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h1 style=&quot;font-weight: normal; line-height: 1.3em; margin-bottom: 0.5em; margin-top: 0px;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;Preliminaries&quot;&gt;Preliminaries&lt;/a&gt;&lt;/h1&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;Preliminaries&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;Preliminaries&quot;&gt;
&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
Refer to&amp;nbsp;&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/network_overview&quot; style=&quot;color: #336699;&quot; title=&quot;Network Overview&quot;&gt;Net:Network Overview&lt;/a&gt;&amp;nbsp;for an overview of all aspects of the networking kernel: routing, neighbour discovery, NAPI, filtering, ...&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
The network data (including headers etc.) is managed through the&amp;nbsp;&lt;a href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/sk_buff&quot; style=&quot;color: #336699;&quot; title=&quot;SK Buff&quot;&gt;sk_buff&lt;/a&gt;&amp;nbsp;data structure. This minimizes copying overhead when going through the networking layers. A basic understanding of sk_buff is required to understand the networking kernel.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
The kernel as a whole makes heavy use of virtual methods. These are recorded as function pointers in data structures. In&amp;nbsp;&lt;a class=&quot;internal&quot; href=&quot;http://www.linuxfoundation.org/images/1/1c/Network_data_flow_through_kernel.png&quot; style=&quot;color: #336699;&quot; title=&quot;Network data flow through kernel.png&quot;&gt;the figure&lt;/a&gt;&amp;nbsp;these are indicated with diamonds. This article never shows all possible implementations for these virtual methods, just the main ones.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
This article only discusses TCP over IPv4 over Ethernet connections. Of course, many combinations of the different networking layers are possible, as well as tunnelling, bridging, etc.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;Transmission_path&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h1 style=&quot;font-weight: normal; line-height: 1.3em; margin-bottom: 0.5em; margin-top: 0px;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;Transmission_path&quot;&gt;Transmission path&lt;/a&gt;&lt;/h1&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;Transmission_path&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;Transmission_path&quot;&gt;
&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;_Session_layer_.28sockets_and_files.29&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;h2 style=&quot;font-size: 1.3em; line-height: 1.3em; margin-bottom: 0.667em; margin-top: 0.667em;&quot;&gt;
Layer 5: Session layer (sockets and files)&lt;/h2&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
There are three system calls that can send data over the network:&lt;/div&gt;
&lt;ul style=&quot;margin: 1em 0px; padding-left: 2em;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;write (memory data to a file descriptor)&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;sendto (memory data to a socket)&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;sendmsg (a composite message to a socket)&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
All of these eventually end up in __sock_sendmsg(), which does security_sock_sendmsg() to check permissions and then forwards the message to the next layer using the socket&#39;s sendmsg virtual method.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;_Transport_layer_.28TCP.29&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;font-size: 1.3em; line-height: 1.3em; margin-bottom: 0.667em; margin-top: 0.667em;&quot;&gt;
Layer 4: Transport layer (TCP)&lt;/h2&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/tcp.c#L661&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/tcp.c#L661&quot;&gt;tcp_sendmsg&lt;/a&gt;: for each segment in the message&lt;/div&gt;
&lt;ol style=&quot;margin: 1em 0px; padding-left: 2em;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;find an sk_buff with space available (use the one at the end if space left, otherwise allocate and append a new one)&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;copy data from user space to sk_buff data space (kernel space, probably DMA-able space) using skb_add_data().&lt;ul style=&quot;list-style-type: disc; margin: 0px; padding-left: 2em;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;The buffer space is pre-allocated for each socket. If the buffer runs out of space, communication stalls: the data remains in user space until buffer space becomes available again (or the call returns with an error immediately if it was non-blocking).&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;The size of allocated sk_buff space is equal to the MSS (Maximum Segment Size) + headroom (MSS may change during connection, and is modified by user options).&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Segmentation (or coalescing of individual writes) happens at this level. Whatever ends up in the same sk_buff will become a single TCP segment. Still, the segments can be fragmented further at IP level.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;The TCP queue is activated; packets are sent with&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/tcp_output.c#L389&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/tcp_output.c#L389&quot;&gt;tcp_transmit_skb()&lt;/a&gt;&amp;nbsp;(called multiple times if there are more active buffers).&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/tcp_output.c#L389&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/tcp_output.c#L389&quot;&gt;tcp_transmit_skb()&lt;/a&gt;&amp;nbsp;builds the TCP header (the allocation of the sk_buff has left space for it). It clones the skb in order to pass control to the network layer. The network layer is called through the queue_xmit virtual function of the socket&#39;s address family (inet_connection_sock-&amp;gt;icsk_af_ops).&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;_Network_layer_.28IPv4.29&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;font-size: 1.3em; line-height: 1.3em; margin-bottom: 0.667em; margin-top: 0.667em;&quot;&gt;
Layer 3: Network layer (IPv4)&lt;/h2&gt;
&lt;ol style=&quot;margin: 1em 0px; padding-left: 2em;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_output.c#L284&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_output.c#L284&quot;&gt;ip_queue_xmit()&lt;/a&gt;&amp;nbsp;does routing (if necessary), creates the IPv4 header&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;nf_hook() is called in several places to perform network filtering (firewall, NAT, ...). This hook may modify the datagram or discard it.&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;The routing decision results in a destination (dst_entry) object. This destination models the receiving IP address of the datagram. The dst_entry&#39;s output virtual method is called to perform actual output.&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;The sk_buff is passed on to&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_output.c#L270&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_output.c#L270&quot;&gt;ip_output()&lt;/a&gt;&amp;nbsp;(or another output mechansim, e.g. in case of tunneling).&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_output.c#L270&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_output.c#L270&quot;&gt;ip_output()&lt;/a&gt;&amp;nbsp;does post-routing filtering,&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_output.c#L202&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_output.c#L202&quot;&gt;re-outputs it on a new destination if necessary due to netfiltering&lt;/a&gt;,&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_output.c#L415&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_output.c#L415&quot;&gt;fragments the datagram into packets if necessary&lt;/a&gt;, and finally&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_output.c#L164&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_output.c#L164&quot;&gt;sends it to the output device&lt;/a&gt;.&lt;ul style=&quot;list-style-type: disc; margin: 0px; padding-left: 2em;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Fragmentation tries to reuse existing fragment buffers, if possible. This happens when forwarding an already fragmented incoming IP packet. The fragment buffers are special sk_buff objects, pointing in the same data space (no copy required).&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;If no fragment buffers are available, new sk_buff objects with new data space are allocated, and the data is copied.&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Note that TCP already makes sure the packets are smaller than MTU, so normally fragmentation is not required.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Device-specific output is again through a virtual method call, to output of the dst_entry&#39;s neighbour data structure. This usually is&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1421&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1421&quot;&gt;dev_queue_xmit&lt;/a&gt;. There is some optimisation for packets with a known destination (hh_cache).&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;_Link_layer_.28e.g._Ethernet.29&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;font-size: 1.3em; line-height: 1.3em; margin-bottom: 0.667em; margin-top: 0.667em;&quot;&gt;
Layer 2: Link layer (e.g. Ethernet)&lt;/h2&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
The main function of the kernel at the link layer is scheduling the packets to be sent out. For this purpose, Linux uses the queueing discipline (struct Qdisc) abstraction. For detailed information, see&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lartc.org/howto/lartc.qdisc.html&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lartc.org/howto/lartc.qdisc.html&quot;&gt;Chapter 9 (Queueing Disciplines for Bandwidth Management)&lt;/a&gt;&amp;nbsp;of&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lartc.org/howto/index.html&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lartc.org/howto/index.html&quot;&gt;the Linux Advanced Routing &amp;amp; Traffic Control HOWTO&lt;/a&gt;&amp;nbsp;and Documentation//networking/multiqueue.txt.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1421&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1421&quot;&gt;dev_queue_xmit&lt;/a&gt;&amp;nbsp;puts the sk_buff on the device queue using the qdisc-&amp;gt;enqueue virtual method.&lt;/div&gt;
&lt;ul style=&quot;margin: 1em 0px; padding-left: 2em;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;If necessary (when the device doesn&#39;t support scattered data) the data is linearised into the sk_buff. This requires copying.&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Devices which don&#39;t have a Qdisc (e.g. loopback) go directly to&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1343&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1343&quot;&gt;dev_hard_start_xmit()&lt;/a&gt;.&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Several Qdisc scheduling policies exist. The basic and most used one is pfifo_fast, which has three priorities.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
The device output queue is immediately triggered with&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/include/net/pkt_sched.h#L223&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/include/net/pkt_sched.h#L223&quot;&gt;qdisc_run()&lt;/a&gt;. It calls&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/sched/sch_generic.c#L91&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/sched/sch_generic.c#L91&quot;&gt;qdisc_restart()&lt;/a&gt;, which takes an skb from the queue using the qdisc-&amp;gt;dequeue virtual method. Specific queueing disciplines may delay sending by not returning any skb, and setting up a qdisc_watchdog_timer() instead. When the timer expires,&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/include/linux/netdevice.h#L635&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/include/linux/netdevice.h#L635&quot;&gt;netif_schedule()&lt;/a&gt;&amp;nbsp;is called to start transmission.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
Eventually, the sk_buff is sent with&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1343&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1343&quot;&gt;dev_hard_start_xmit()&lt;/a&gt;&amp;nbsp;and removed from the Qdisc. If sending fails, the skb is re-queued.&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/include/linux/netdevice.h#L635&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/include/linux/netdevice.h#L635&quot;&gt;netif_schedule()&lt;/a&gt;&amp;nbsp;is called to schedule a retry.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/include/linux/netdevice.h#L635&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/include/linux/netdevice.h#L635&quot;&gt;netif_schedule()&lt;/a&gt;&amp;nbsp;raises a software interrupt, which causes&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1644&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1644&quot;&gt;net_tx_action()&lt;/a&gt;&amp;nbsp;to be called when the NET_TX_SOFTIRQ is ran by ksoftirqd. net_tx_action() calls qdisc_run() for each device with an active queue.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1343&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1343&quot;&gt;dev_hard_start_xmit()&lt;/a&gt;&amp;nbsp;calls the hard_start_xmit virtual method for the net_device. But first, it calls dev_queue_xmit_nit(), which checks if a packet handler has been registered for the ETH_P_ALL protocol. This is used for tcpdump.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
The device driver&#39;s hard_start_xmit function will generate one or more commands to the network device for scheduling transfer of the buffer. After a while, the network device replies that it&#39;s done. This triggers freeing of the sk_buff. If the sk_buff is freed from interrupt context,&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/include/linux/netdevice.h#L679&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/include/linux/netdevice.h#L679&quot;&gt;dev_kfree_skb_irq()&lt;/a&gt;&amp;nbsp;is used. This delays the actual freeing until the next NET_TX_SOFTIRQ run, by putting the skb on the softnet_data completion_queue. This avoids doing frees from interrupt context.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;Receive_flow&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h1 style=&quot;font-weight: normal; line-height: 1.3em; margin-bottom: 0.5em; margin-top: 0px;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;Receive_flow&quot;&gt;Receive flow&lt;/a&gt;&lt;/h1&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;Receive_flow&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;Receive_flow&quot;&gt;
&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;_Link_layer_.28e.g._Ethernet.29_2&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;h2 style=&quot;font-size: 1.3em; line-height: 1.3em; margin-bottom: 0.667em; margin-top: 0.667em;&quot;&gt;
Layer 2: Link layer (e.g. Ethernet)&lt;/h2&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
The network device pre-allocates a number of sk_buffs for reception. How many, is configured per device. Usually, the addresses to the data space in these sk_buffs are configured directly as DMA area for the device. The device interrupt handler takes the sk_buff and performs reception handling on it. Before NAPI, this was done using netif_rx(). In NAPI, it is done in two phases.&lt;/div&gt;
&lt;ol style=&quot;margin: 1em 0px; padding-left: 2em;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;From the interrupt handler, the device driver just calls&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/include/linux/netdevice.h#L858&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/include/linux/netdevice.h#L858&quot;&gt;netif_rx_schedule()&lt;/a&gt;&amp;nbsp;and returns from interrupt. netif_rx_schedule() adds the device to sofnet_data&#39;s poll_list and raises the NET_RX_SOFTIRQ software interrupt.&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;ksoftirqd runs&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1904&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1904&quot;&gt;net_rx_action()&lt;/a&gt;, which calls the device&#39;s poll virtual method. The poll method does device-specific buffer management, calls netif_receive_skb() for each sk_buff, allocates new sk_buffs as required, and terminates with netif_rx_complete().&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1764&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1764&quot;&gt;netif_receive_skb()&lt;/a&gt;&amp;nbsp;finds out how to pass the sk_buff to upper layers.&lt;/div&gt;
&lt;ol style=&quot;margin: 1em 0px; padding-left: 2em;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/include/linux/netpoll.h#L49&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/include/linux/netpoll.h#L49&quot;&gt;netpoll_rx()&lt;/a&gt;&amp;nbsp;is called, to support the&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://people.redhat.com/~jmoyer/netpoll-linux_kongress-2005.pdf&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://people.redhat.com/~jmoyer/netpoll-linux_kongress-2005.pdf&quot;&gt;Netpoll API&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Call packet handlers for ETH_P_ALL protocol (for tcpdump)&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Call handle_ing() for ingress queueing&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Call handle_bridge() for bridging&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Call handle_macvlan() for virtual LAN&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;Call the packet handler registered for the L3 protocol specified by the packet.&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
The packet handlers are called with the&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1690&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/core/dev.c#L1690&quot;&gt;deliver_skb()&lt;/a&gt;&amp;nbsp;function, which calls the protocol&#39;s func virtual method to handle the packet.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;_Network_layer_.28IPv4.2C_ARP.29&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;font-size: 1.3em; line-height: 1.3em; margin-bottom: 0.667em; margin-top: 0.667em;&quot;&gt;
Layer 3: Network layer (IPv4, ARP)&lt;/h2&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;ARP&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h3 style=&quot;font-size: 1.3em; line-height: 1.3em; margin-bottom: 0.769em; margin-top: 0.769em;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;ARP&quot;&gt;ARP&lt;/a&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;ARP&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;ARP&quot;&gt;
&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
ARP packets are handled with&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/arp.c#L930&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/arp.c#L930&quot;&gt;arp_rcv()&lt;/a&gt;. It processes the ARP information, stores it in the neighbour cache, and sends a reply if required. In the latter case, a new sk_buff (with new data space) is allocated for the reply.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;IPv4&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h3 style=&quot;font-size: 1.3em; line-height: 1.3em; margin-bottom: 0.769em; margin-top: 0.769em;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;IPv4&quot;&gt;IPv4&lt;/a&gt;&lt;/h3&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;IPv4&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;IPv4&quot;&gt;
&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
IPv4 packets are handled with&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_input.c#L373&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_input.c#L373&quot;&gt;ip_rcv()&lt;/a&gt;. It parses headers, checks for validity, sends an ICMP reply or error message if required. It also looks up the destination address using&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/route.c#L2090&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/route.c#L2090&quot;&gt;ip_route_input()&lt;/a&gt;. The destination&#39;s input virtual method is called with the sk_buff.&lt;/div&gt;
&lt;ul style=&quot;margin: 1em 0px; padding-left: 2em;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ipmr.c#L1338&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ipmr.c#L1338&quot;&gt;ip_mr_input()&lt;/a&gt;&amp;nbsp;is called for multicast addresses. The packet may be forwarded using ip_mr_forward(), and it may be delivered locally using ip_local_delivery().&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_forward.c#L56&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_forward.c#L56&quot;&gt;ip_forward()&lt;/a&gt;&amp;nbsp;is called for packets with a different destination for which we have a route. It directly calls the neighbour&#39;s output virtual method.&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_input.c#L263&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/ip_input.c#L263&quot;&gt;ip_local_deliver()&lt;/a&gt;&amp;nbsp;is called if this machine is the destination of the packet. Datagram fragments are collected here.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
ip_local_deliver() delivers to any raw sockets for this connection first, using raw_local_deliver(). Then, it calls the L4 protocol handler for the protocol specified in the datagram. The L4 protocol is called even if a raw socket exists.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
Throughout, xfrm4_policy_check calls are included to support IPSec.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;_Transport_layer_.28TCP.29_2&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;font-size: 1.3em; line-height: 1.3em; margin-bottom: 0.667em; margin-top: 0.667em;&quot;&gt;
Layer 4: Transport layer (TCP)&lt;/h2&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
The net_protocol handler for TCP is&amp;nbsp;&lt;a class=&quot;external text&quot; href=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/tcp_ipv4.c#L1611&quot; rel=&quot;nofollow&quot; style=&quot;color: #336699;&quot; title=&quot;http://lxr.linux.no/linux+v2.6.20/net/ipv4/tcp_ipv4.c#L1611&quot;&gt;tcp_v4_rcv()&lt;/a&gt;. Most of the code here deals with the protocol processing in TCP, for setting up connections, performing flow control, etc.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
A received TCP packet may include an acknowledgement of a previously sent packet, which may trigger further sending of packets (tcp_data_snd_check()) or of acknowledgements (tcp_ack_snd_check()).&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
Passing the incoming packet to an upper layer is done in tcp_rcv_established() and tcp_data_queue(). These functions maintain the tcp connection&#39;s out_of_order_queue, and the socket&#39;s sk_receive_queue and sk_async_wait_queue. If a user process is already waiting for data to arrive, the data is immediately copied to user space using skb_copy_datagram_iovec(). Otherwise, the sk_buff is appended to one of the socket&#39;s queues and will be copied later.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
Finally, the receive functions call the socket&#39;s sk_data_ready virtual method to signal that data is available. This wakes up waiting processes.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; name=&quot;_Session_layer_.28sockets_and_files.29_2&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;font-size: 1.3em; line-height: 1.3em; margin-bottom: 0.667em; margin-top: 0.667em;&quot;&gt;
Layer 5: Session layer (sockets and files)&lt;/h2&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
There are three system calls that can receive data from the network:&lt;/div&gt;
&lt;ul style=&quot;margin: 1em 0px; padding-left: 2em;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;read (memory data from a file descriptor)&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;recvfrom (memory data from a socket)&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;recvmsg (a composite message from a socket)&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
All of these eventually end up in __sock_recvmsg(), which does security_sock_recvmsg() to check permissions and then requests the message to the next layer using the socket&#39;s recvmsg virtual method. This is often sock_common_recvmsg(), which calls the recvmsg virtual method of the socket&#39;s protocol.&lt;/div&gt;
&lt;div style=&quot;font-size: 1.08em; line-height: 1.53em; margin-bottom: 1em; margin-top: 1em;&quot;&gt;
tcp_recvmsg() either copies data from the socket&#39;s queue using skb_copy_datagram_iovec(), or waits for data to arrive using sk_wait_data(). The latter blocks and is woken up by the layer 4 processing.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;groups&quot;&gt;
Groups:&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/2031202251099955341/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/linux-kernal-flow-v-imp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/2031202251099955341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/2031202251099955341'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/linux-kernal-flow-v-imp.html' title='Linux kernal flow : v imp'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-933834079997556570</id><published>2013-11-19T23:14:00.001-08:00</published><updated>2013-11-19T23:17:22.556-08:00</updated><title type='text'>Networking in the Linux Kernel</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;level1&quot; style=&quot;background-color: #557788; font-family: sans-serif; font-size: 14px; line-height: 21.59375px; margin: 0px; padding: 0px;&quot;&gt;
&lt;div style=&quot;margin-bottom: 0.75em; padding: 0px;&quot;&gt;
&lt;br /&gt;
&lt;a href=&quot;http://wiki.openwrt.org/doc/networking/praxis&quot;&gt;http://wiki.openwrt.org/doc/networking/praxis&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Above we read merely about the theory of networking, about the basic ideas, about communication protocols and standards. Now, let us see, how all of this is being handled by the Linux Kernel 2.6:&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.75em; padding: 0px;&quot;&gt;
Everything related is found under&amp;nbsp;&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;&lt;a class=&quot;urlextern&quot; href=&quot;http://lxr.free-electrons.com/source/net/&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; background-image: url(http://wiki.openwrt.org/lib/tpl/ameoto/images/urlextern.png); background-position: 0% 50%; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 18px;&quot; title=&quot;http://lxr.free-electrons.com/source/net/&quot;&gt;/net/&lt;/a&gt;&lt;/code&gt;. But drivers, for the network devices, are of course found&amp;nbsp;&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;&lt;a class=&quot;urlextern&quot; href=&quot;http://lxr.free-electrons.com/source/drivers&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; background-image: url(http://wiki.openwrt.org/lib/tpl/ameoto/images/urlextern.png); background-position: 0% 50%; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 18px;&quot; title=&quot;http://lxr.free-electrons.com/source/drivers&quot;&gt;/drivers/&lt;/a&gt;&lt;/code&gt;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.75em; padding: 0px;&quot;&gt;
&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;NOTE&lt;/em&gt;&lt;/strong&gt;:&lt;/div&gt;
&lt;ol style=&quot;margin: 0px 0px 0.75em 2em; padding: 0px;&quot;&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
The Linux kernel is only one component of the operating system&lt;/div&gt;
&lt;ol style=&quot;margin: 0px 0px 0.75em 1em; padding: 0px;&quot;&gt;
&lt;li class=&quot;level2&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
it does require libraries itself (we at OpenWrt use the µCLibC, see →&lt;a class=&quot;wikilink1&quot; href=&quot;http://wiki.openwrt.org/doc/devel/links.software.libraries&quot; style=&quot;margin: 0px; padding: 0px;&quot; title=&quot;doc:devel:links.software.libraries&quot;&gt;links.software.libraries&lt;/a&gt;)&amp;nbsp;&lt;a class=&quot;urlextern&quot; href=&quot;http://man.cat-v.org/unix_8th/3/&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; background-image: url(http://wiki.openwrt.org/lib/tpl/ameoto/images/urlextern.png); background-position: 0% 50%; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 18px;&quot; title=&quot;http://man.cat-v.org/unix_8th/3/&quot;&gt;Section: 3 - C library functions&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level2&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
it is very modular and there are many modules&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level2&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
it does require applications to provide features to end users (these run in userspace)&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;margin-bottom: 0.75em; padding: 0px;&quot;&gt;
The main interface between the kernel and userspace is the set of&amp;nbsp;&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;system calls&lt;/code&gt;. There are about&amp;nbsp;&lt;img alt=&quot;FIXME&quot; class=&quot;middle&quot; src=&quot;http://wiki.openwrt.org/lib/images/smileys/fixme.gif&quot; style=&quot;margin: 0px; max-width: 100%; padding: 0px;&quot; /&gt;&amp;nbsp;&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;system calls&lt;/code&gt;. Network related&amp;nbsp;&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;system calls&lt;/code&gt;&amp;nbsp;include:&lt;/div&gt;
&lt;ul style=&quot;margin: 0px 0px 0.75em 2em; padding: 0px;&quot;&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;&lt;/code&gt;&amp;nbsp;writes to socket&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;h2 style=&quot;background-color: #557788; font-family: sans-serif; line-height: 21.59375px; margin: 1em 0px 0.5em; padding: 0px;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; id=&quot;network.data.flow.through.the.linux.kernel&quot; name=&quot;network.data.flow.through.the.linux.kernel&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;Network Data Flow through the Linux Kernel&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;level2&quot; style=&quot;background-color: #557788; font-family: sans-serif; font-size: 14px; line-height: 21.59375px; margin: 0px; padding: 0px;&quot;&gt;
&lt;ul style=&quot;margin: 0px 0px 0.75em 2em; padding: 0px;&quot;&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;a class=&quot;urlextern&quot; href=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; background-image: url(http://wiki.openwrt.org/lib/tpl/ameoto/images/urlextern.png); background-position: 0% 50%; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 18px;&quot; title=&quot;http://www.linuxfoundation.org/collaborate/workgroups/networking/kernel_flow&quot;&gt;Kernel Flow&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;margin-bottom: 0.75em; padding: 0px;&quot;&gt;
&lt;a class=&quot;media&quot; href=&quot;http://wiki.openwrt.org/lib/exe/fetch.php?media=http%3A%2F%2Fwww.linuxfoundation.org%2Fimages%2F1%2F1c%2FNetwork_data_flow_through_kernel.png&quot; style=&quot;margin: 0px; padding: 0px;&quot; title=&quot;http://www.linuxfoundation.org/images/1/1c/Network_data_flow_through_kernel.png&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;media&quot; src=&quot;http://wiki.openwrt.org/lib/exe/fetch.php?w=900&amp;amp;media=http%3A%2F%2Fwww.linuxfoundation.org%2Fimages%2F1%2F1c%2FNetwork_data_flow_through_kernel.png&quot; style=&quot;margin: 0px; max-width: 100%; padding: 0px;&quot; width=&quot;900&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;ul style=&quot;margin: 0px 0px 0.75em 2em; padding: 0px;&quot;&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;a class=&quot;urlextern&quot; href=&quot;http://gicl.cs.drexel.edu/people/sevy/network/Linux_network_stack_walkthrough.html&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; background-image: url(http://wiki.openwrt.org/lib/tpl/ameoto/images/urlextern.png); background-position: 0% 50%; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 18px;&quot; title=&quot;http://gicl.cs.drexel.edu/people/sevy/network/Linux_network_stack_walkthrough.html&quot;&gt;Linux Network Stack Walkthrough (Linux Kernel 2.4.20)&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;a class=&quot;urlextern&quot; href=&quot;http://www.google.com/search?q=Network+Data+Flow+through+the+Linux+Kernel&amp;amp;btnG=Search&amp;amp;hl=en&amp;amp;gbv=1&amp;amp;sei=Bv1dT4XfA_Da4QSM5ZG6Dw&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; background-image: url(http://wiki.openwrt.org/lib/tpl/ameoto/images/urlextern.png); background-position: 0% 50%; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 18px;&quot; title=&quot;http://www.google.com/search?q=Network+Data+Flow+through+the+Linux+Kernel&amp;amp;btnG=Search&amp;amp;hl=en&amp;amp;gbv=1&amp;amp;sei=Bv1dT4XfA_Da4QSM5ZG6Dw&quot;&gt;google.com: &quot;Network Data Flow through the Linux Kernel&quot;&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;h3 style=&quot;background-color: #557788; font-family: sans-serif; line-height: 21.59375px; margin: 1em 0px 0.5em; padding: 0px;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; id=&quot;packet.handling&quot; name=&quot;packet.handling&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;Packet Handling&lt;/a&gt;&lt;/h3&gt;
&lt;div class=&quot;level3&quot; style=&quot;background-color: #557788; font-family: sans-serif; font-size: 14px; line-height: 21.59375px; margin: 0px; padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;h4 style=&quot;background-color: #557788; font-family: sans-serif; font-size: 14px; line-height: 21.59375px; margin: 1em 0px 0.5em; padding: 0px;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; id=&quot;tx.transmission&quot; name=&quot;tx.transmission&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;TX Transmission&lt;/a&gt;&lt;/h4&gt;
&lt;div class=&quot;level4&quot; style=&quot;background-color: #557788; font-family: sans-serif; font-size: 14px; line-height: 21.59375px; margin: 0px; padding: 0px;&quot;&gt;
&lt;ol style=&quot;margin: 0px 0px 0.75em 2em; padding: 0px;&quot;&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
Queue No.1: The application process does a&amp;nbsp;&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;write()&lt;/code&gt;&amp;nbsp;on a&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;socket&lt;/em&gt;&amp;nbsp;and all the data is copied from the process space into the&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;send socket buffer&lt;/em&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
Queue No.2: The data goes through the&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;TCP/IP stack&lt;/em&gt;&amp;nbsp;and the packets are put (&lt;a class=&quot;interwiki iw_wp&quot; href=&quot;http://en.wikipedia.org/wiki/Evaluation%20strategy#Call_by_reference&quot; style=&quot;background-color: transparent; background-image: url(http://wiki.openwrt.org/lib/images/interwiki/wp.gif); background-position: 0px 1px; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 16px;&quot; title=&quot;http://en.wikipedia.org/wiki/Evaluation strategy#Call_by_reference&quot;&gt;Evaluation strategy#Call_by_reference&lt;/a&gt;) into the NIC&#39;s&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;egress buffer&lt;/em&gt;&amp;nbsp;(here works the packet scheduler)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
Queue No.3: After a packet gets dequeued, the transmission procedure of the driver is called, and it is copied into the&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;tx_ring&lt;/em&gt;, a ring buffer the driver shares with the NIC&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;h4 style=&quot;background-color: #557788; font-family: sans-serif; font-size: 14px; line-height: 21.59375px; margin: 1em 0px 0.5em; padding: 0px;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; id=&quot;rx.reception&quot; name=&quot;rx.reception&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;RX Reception&lt;/a&gt;&lt;/h4&gt;
&lt;div class=&quot;level4&quot; style=&quot;background-color: #557788; font-family: sans-serif; font-size: 14px; line-height: 21.59375px; margin: 0px; padding: 0px;&quot;&gt;
&lt;ol style=&quot;margin: 0px 0px 0.75em 2em; padding: 0px;&quot;&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
Queue No.1: The hardware (NIC) puts all incoming network packets into the&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;rx_ring&lt;/em&gt;, a ring buffer the driver shares with the NIC&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
Queue No.2: The&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;IRQ handler&lt;/em&gt;&amp;nbsp;of the driver takes the packet from the&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;rx_ring&lt;/em&gt;, puts it (by (&lt;a class=&quot;interwiki iw_wp&quot; href=&quot;http://en.wikipedia.org/wiki/Evaluation%20strategy#Call_by_reference&quot; style=&quot;background-color: transparent; background-image: url(http://wiki.openwrt.org/lib/images/interwiki/wp.gif); background-position: 0px 1px; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 16px;&quot; title=&quot;http://en.wikipedia.org/wiki/Evaluation strategy#Call_by_reference&quot;&gt;Evaluation strategy#Call_by_reference&lt;/a&gt;)) in the&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;ingress buffer&lt;/em&gt;&amp;nbsp;(aka&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;backlog queue&lt;/em&gt;) and schedules a SoftIRQ (in former days, every incoming packet triggered an IRQ, since Kernel&amp;nbsp;&lt;img alt=&quot;FIXME&quot; class=&quot;middle&quot; src=&quot;http://wiki.openwrt.org/lib/images/smileys/fixme.gif&quot; style=&quot;margin: 0px; padding: 0px;&quot; /&gt;&amp;nbsp;this is solved by polling instead)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
Queue No.3: is the the&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;receive socket buffer&lt;/em&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;h4 style=&quot;background-color: #557788; font-family: sans-serif; font-size: 14px; line-height: 21.59375px; margin: 1em 0px 0.5em; padding: 0px;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; id=&quot;typical.queue.lengths&quot; name=&quot;typical.queue.lengths&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;Typical queue lengths&lt;/a&gt;&lt;/h4&gt;
&lt;div class=&quot;level4&quot; style=&quot;background-color: #557788; font-family: sans-serif; font-size: 14px; line-height: 21.59375px; margin: 0px; padding: 0px;&quot;&gt;
&lt;ul style=&quot;margin: 0px 0px 0.75em 2em; padding: 0px;&quot;&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
The&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;socket buffers&lt;/em&gt;&amp;nbsp;can be set by the application (&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;set_sockopt()&lt;/code&gt;)&lt;/div&gt;
&lt;ul style=&quot;margin: 0px 0px 0.75em 1em; padding: 0px;&quot;&gt;
&lt;li class=&quot;level2&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;cat /proc/sys/net/core/rmem_default&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;cat /proc/sys/net/core/wmem_default&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
The default queuing discipline is a FIFO queue. Default length is 100 packets (ether_setup(): dev→queue_len, drivers/net/net_init.c)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
The&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;tx_ring&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;rx_ring&lt;/em&gt;&amp;nbsp;are driver dependent (e.g. the e1000 driver set these lengths to 80 packets)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
The&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;backlog queue&lt;/em&gt;&amp;nbsp;is 300 packets in size (&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;/proc/sys/net/core/netdev_max_backlog&lt;/code&gt;). Once it is full, it waits for being totally empty to allow again an enqueue() (netif_rx(), net/core/dev.c).&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;h5 style=&quot;background-color: #557788; font-family: sans-serif; line-height: 21.59375px; margin: 1em 0px 0.5em; padding: 0px;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; id=&quot;proc&quot; name=&quot;proc&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;/proc&lt;/a&gt;&lt;/h5&gt;
&lt;div class=&quot;level5&quot; style=&quot;background-color: #557788; font-family: sans-serif; font-size: 14px; line-height: 21.59375px; margin: 0px; padding: 0px;&quot;&gt;
&lt;div style=&quot;margin-bottom: 0.75em; padding: 0px;&quot;&gt;
&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;/proc&lt;/code&gt;&amp;nbsp;is the POSIX complient mount point for the&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;Virtual Filesystem&lt;/em&gt;&amp;nbsp;for the processes.&lt;/div&gt;
&lt;ul style=&quot;margin: 0px 0px 0.75em 2em; padding: 0px;&quot;&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;/proc/cpuinfo&lt;/code&gt;: processor information&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;/proc/meminfo&lt;/code&gt;: memory status&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;/proc/version&lt;/code&gt;: kernel version and build information&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;/proc/cmdline&lt;/code&gt;: kernel command line&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;/proc/&lt;pid&gt;/environ&lt;/pid&gt;&lt;/code&gt;: calling environment&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div class=&quot;li&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;
&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;/proc/&lt;pid&gt;/cmdline&lt;/pid&gt;&lt;/code&gt;: process command line&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;margin-bottom: 0.75em; padding: 0px;&quot;&gt;
See&amp;nbsp;&lt;a class=&quot;interwiki iw_wp&quot; href=&quot;http://en.wikipedia.org/wiki/Procfs&quot; style=&quot;background-color: transparent; background-image: url(http://wiki.openwrt.org/lib/images/interwiki/wp.gif); background-position: 0px 1px; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 16px;&quot; title=&quot;http://en.wikipedia.org/wiki/Procfs&quot;&gt;Procfs&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a class=&quot;urlextern&quot; href=&quot;http://www.comptechdoc.org/os/linux/howlinuxworks/linux_hlproc.html&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; background-image: url(http://wiki.openwrt.org/lib/tpl/ameoto/images/urlextern.png); background-position: 0% 50%; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 18px;&quot; title=&quot;http://www.comptechdoc.org/os/linux/howlinuxworks/linux_hlproc.html&quot;&gt;http://www.comptechdoc.org/os/linux/howlinuxworks/linux_hlproc.html&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a class=&quot;urlextern&quot; href=&quot;http://www.mjmwired.net/kernel/Documentation/filesystems/proc.txt&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; background-image: url(http://wiki.openwrt.org/lib/tpl/ameoto/images/urlextern.png); background-position: 0% 50%; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 18px;&quot; title=&quot;http://www.mjmwired.net/kernel/Documentation/filesystems/proc.txt&quot;&gt;proc.txt&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.75em; padding: 0px;&quot;&gt;
See →&amp;nbsp;&lt;a class=&quot;urlextern&quot; href=&quot;http://gettys.wordpress.com/2010/11/29/home-router-puzzle-piece-one-fun-with-your-switch/&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; background-image: url(http://wiki.openwrt.org/lib/tpl/ameoto/images/urlextern.png); background-position: 0% 50%; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 18px;&quot; title=&quot;http://gettys.wordpress.com/2010/11/29/home-router-puzzle-piece-one-fun-with-your-switch/&quot;&gt;http://gettys.wordpress.com/2010/11/29/home-router-puzzle-piece-one-fun-with-your-switch/&lt;/a&gt;&amp;nbsp;for some &quot;fun&quot; with all the queues.&lt;/div&gt;
&lt;/div&gt;
&lt;h5 style=&quot;background-color: #557788; font-family: sans-serif; line-height: 21.59375px; margin: 1em 0px 0.5em; padding: 0px;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; id=&quot;transmitting&quot; name=&quot;transmitting&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;Transmitting&lt;/a&gt;&lt;/h5&gt;
&lt;div class=&quot;level5&quot; style=&quot;background-color: #557788; font-family: sans-serif; font-size: 14px; line-height: 21.59375px; margin: 0px; padding: 0px;&quot;&gt;
&lt;div style=&quot;margin-bottom: 0.75em; padding: 0px;&quot;&gt;
So you can install hardware capable of Ethernet (usually a network card or more precisely an Ethernet card) on two&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;hosts&lt;/em&gt;, connect them with a standardized cable, like a&amp;nbsp;&lt;a class=&quot;interwiki iw_wp&quot; href=&quot;http://en.wikipedia.org/wiki/Category%205%20cable&quot; style=&quot;background-color: transparent; background-image: url(http://wiki.openwrt.org/lib/images/interwiki/wp.gif); background-position: 0px 1px; background-repeat: no-repeat no-repeat; margin: 0px; padding: 0px 0px 0px 16px;&quot; title=&quot;http://en.wikipedia.org/wiki/Category 5 cable&quot;&gt;Category 5 cable&lt;/a&gt;&amp;nbsp;and communicate with one another over Ethernet as far as your software supports Ethernet&amp;nbsp;&lt;img alt=&quot;;-)&quot; class=&quot;middle&quot; src=&quot;http://wiki.openwrt.org/lib/images/smileys/icon_wink.gif&quot; style=&quot;margin: 0px; max-width: 100%; padding: 0px;&quot; /&gt;&amp;nbsp;Sooner or later the sausage will get to the Ethernet thingy of the network stack, this will prepare the data conforming to the Ethernet standard, then will deliver the frames to the network card drivers and this will make the hardware, the network card, transmit the data.&lt;/div&gt;
&lt;/div&gt;
&lt;h5 style=&quot;background-color: #557788; font-family: sans-serif; line-height: 21.59375px; margin: 1em 0px 0.5em; padding: 0px;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=2845929896695469094&quot; id=&quot;receiving&quot; name=&quot;receiving&quot; style=&quot;margin: 0px; padding: 0px;&quot;&gt;Receiving&lt;/a&gt;&lt;/h5&gt;
&lt;div class=&quot;level5&quot; style=&quot;background-color: #557788; font-family: sans-serif; font-size: 14px; line-height: 21.59375px; margin: 0px; padding: 0px;&quot;&gt;
&lt;div style=&quot;margin-bottom: 0.75em; padding: 0px;&quot;&gt;
The NIC on the other side will receive the signal, relay it to the&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;Ethernet thingy&lt;/em&gt;&amp;nbsp;of the&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;network stack&lt;/em&gt;, this will create one huge data out of the Ethernet frames and relay it to the software.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.75em; padding: 0px;&quot;&gt;
When a packet is enqueued on an interface with&amp;nbsp;&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;dev queue xmit&lt;/code&gt;&amp;nbsp;(in&amp;nbsp;&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;net/core/dev.c&lt;/code&gt;), the&amp;nbsp;&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;enqueue&lt;/code&gt;&amp;nbsp;operation of the packet scheduler is triggered and&amp;nbsp;&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;qdisc wakeup&lt;/code&gt;&amp;nbsp;is being called (in&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;net/pkt_sched.h&lt;/code&gt;) to send the packet on that device.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.75em; padding: 0px;&quot;&gt;
A transmit queue is associated with each device. When a network packet is ready for transmission, the &quot;networking code&quot; will call the driver&#39;s&amp;nbsp;&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;hard_start_xmit()&lt;/code&gt;-function to let it know, a packet is waiting. The driver will then put that packet into the&amp;nbsp;&lt;code style=&quot;margin: 0px 0px 0.75em; padding: 0px; white-space: pre;&quot;&gt;transmit queue&lt;/code&gt;&amp;nbsp;of the hardware.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0.75em; padding: 0px;&quot;&gt;
You find the sources for the whole&amp;nbsp;&lt;em style=&quot;margin: 0px; padding: 0px;&quot;&gt;TCP/IP protocol suite&lt;/em&gt;&amp;nbsp;implementation&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/933834079997556570/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/networking-in-linux-kernel.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/933834079997556570'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/933834079997556570'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/networking-in-linux-kernel.html' title='Networking in the Linux Kernel'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-2247530021567893406</id><published>2013-11-18T03:15:00.003-08:00</published><updated>2013-11-18T03:15:37.159-08:00</updated><title type='text'>Zero Copy I: User-Mode Perspective</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;content-header&quot; style=&quot;background-color: white; font-family: Arial, sans-serif; margin-bottom: 10px;&quot;&gt;
&lt;h1 class=&quot;title&quot; style=&quot;font-size: 1.4em; margin: 0px;&quot;&gt;
Zero Copy I: User-Mode Perspective&lt;/h1&gt;
&lt;/div&gt;
&lt;div id=&quot;content-area&quot; style=&quot;background-color: white; font-family: Arial, sans-serif; padding-bottom: 20px;&quot;&gt;
&lt;div class=&quot;node node-type-xmlnode&quot; id=&quot;node-6345&quot; style=&quot;margin: 1em;&quot;&gt;
&lt;div class=&quot;node-inner&quot;&gt;
&lt;div id=&quot;facebook-like&quot; style=&quot;float: right; height: 55px; position: relative; z-index: 100;&quot;&gt;
&lt;div class=&quot;fb-like fb_edge_widget_with_comment fb_iframe_widget&quot; data-href=&quot;http://www.linuxjournal.com//article/6345&quot; data-send=&quot;false&quot; data-show-faces=&quot;false&quot; data-width=&quot;250&quot; fb-xfbml-state=&quot;rendered&quot; style=&quot;display: inline-block; position: relative;&quot;&gt;
&lt;span style=&quot;display: inline-block; height: 28px; position: relative; text-align: justify; width: 250px;&quot;&gt;&lt;iframe class=&quot;fb_ltr&quot; id=&quot;f6501c374&quot; name=&quot;f272078aac&quot; scrolling=&quot;no&quot; src=&quot;http://www.facebook.com/plugins/like.php?api_key=406458029406839&amp;amp;channel_url=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D28%23cb%3Df16efc240%26domain%3Dwww.linuxjournal.com%26origin%3Dhttp%253A%252F%252Fwww.linuxjournal.com%252Ff175e1a418%26relation%3Dparent.parent&amp;amp;colorscheme=light&amp;amp;extended_social_context=false&amp;amp;href=http%3A%2F%2Fwww.linuxjournal.com%2F%2Farticle%2F6345&amp;amp;layout=standard&amp;amp;locale=en_US&amp;amp;node_type=link&amp;amp;sdk=joey&amp;amp;send=false&amp;amp;show_faces=false&amp;amp;width=250&quot; style=&quot;border-style: none; height: 28px; overflow: hidden; position: absolute; width: 250px;&quot; title=&quot;Like this content on Facebook.&quot;&gt;&lt;/iframe&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;issue&quot; style=&quot;background-color: #cccccc; border: 2px solid rgb(153, 153, 153); clear: right; float: right; margin: 10px; padding: 10px;&quot;&gt;
&lt;div class=&quot;issue-cover&quot;&gt;
&lt;a href=&quot;http://www.linuxjournal.com/issue/105&quot; style=&quot;color: #003366; font-weight: bold; margin-bottom: 0px; text-align: center; text-decoration: none;&quot;&gt;&lt;img alt=&quot;Issue 105&quot; src=&quot;http://www.linuxjournal.com/files/linuxjournal.com/linuxjournal/issues/105/cover105.small.jpg&quot; style=&quot;border: 0px; margin: 0px auto;&quot; title=&quot;Issue 105&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: bold; text-align: center;&quot;&gt;
&lt;a href=&quot;http://www.linuxjournal.com/issue/105&quot; style=&quot;color: #003366; margin-bottom: 0px; text-decoration: none;&quot;&gt;From Issue #105&lt;br /&gt;January 2003&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;meta&quot; style=&quot;font-size: 0.9em; margin-top: 0.1em;&quot;&gt;
&lt;div class=&quot;submitted&quot;&gt;
Jan 01, 2003  &amp;nbsp;By&amp;nbsp;&lt;a href=&quot;http://www.linuxjournal.com/user/801134&quot; style=&quot;color: #003366; text-decoration: none;&quot; title=&quot;View user profile.&quot;&gt;Dragan Stancevic&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;terms terms-inline&quot; style=&quot;margin-top: 5px;&quot;&gt;
&amp;nbsp;in&lt;ul class=&quot;links inline&quot; style=&quot;display: inline; list-style-position: inside; margin: 0px; padding: 0px;&quot;&gt;
&lt;li class=&quot;taxonomy_term_21 first last&quot; style=&quot;display: inline; list-style-type: none; padding: 0px 0.5em;&quot;&gt;&lt;a href=&quot;http://www.linuxjournal.com/tag/sysadmin&quot; rel=&quot;tag&quot; style=&quot;color: #666666; text-decoration: none;&quot; title=&quot;&quot;&gt;SysAdmin&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;abstract&quot; style=&quot;font-size: 0.9em; font-style: italic; margin: 1em 0px;&quot;&gt;
Explaining what is zero-copy functionality for Linux, why it&#39;s useful and where it needs work.&lt;/div&gt;
&lt;div class=&quot;content&quot; style=&quot;font-family: Georgia, serif; line-height: 1.3em; margin: 5px 0px 20px;&quot;&gt;
&lt;div class=&quot;article&quot; lang=&quot;en&quot;&gt;
&lt;div class=&quot;simplesect&quot; lang=&quot;en&quot;&gt;
&lt;div class=&quot;titlepage&quot;&gt;
&lt;a href=&quot;&quot; name=&quot;N0xa50890.0xb44d80&quot; style=&quot;color: #003366; font-weight: bold;&quot;&gt;&lt;/a&gt;&lt;/div&gt;
By now almost everyone has heard of so-called zero-copy functionality under Linux, but I often run into people who don&#39;t have a full understanding of the subject. Because of this, I decided to write a few articles that dig into the matter a bit deeper, in the hope of unraveling this useful feature. In this article, we take a look at zero copy from a user-mode application point of view, so gory kernel-level details are omitted intentionally.&lt;/div&gt;
&lt;div class=&quot;simplesect&quot; lang=&quot;en&quot;&gt;
&lt;div class=&quot;titlepage&quot;&gt;
&lt;a href=&quot;&quot; name=&quot;N0xa50890.0xb44e88&quot; style=&quot;color: #003366; font-weight: bold;&quot;&gt;&lt;/a&gt;What Is Zero-Copy?&lt;/div&gt;
To better understand the solution to a problem, we first need to understand the problem itself. Let&#39;s look at what is involved in the simple procedure of a network server dæmon serving data stored in a file to a client over the network. Here&#39;s some sample code:&lt;br /&gt;
&lt;pre class=&quot;programlisting&quot; style=&quot;color: #336699; overflow: auto;&quot;&gt;read(file, tmp_buf, len);
write(socket, tmp_buf, len);
&lt;/pre&gt;
Looks simple enough; you would think there is not much overhead with only those two system calls. In reality, this couldn&#39;t be further from the truth. Behind those two calls, the data has been copied at least four times, and almost as many user/kernel context switches have been performed. (Actually this process is much more complicated, but I wanted to keep it simple). To get a better idea of the process involved, take a look at Figure 1. The top side shows context switches, and the bottom side shows copy operations.&lt;br /&gt;
&lt;div class=&quot;mediaobject&quot;&gt;
&lt;img src=&quot;http://www.linuxjournal.com/files/linuxjournal.com/linuxjournal/articles/063/6345/6345f1.jpg&quot; style=&quot;border: 0px;&quot; /&gt;&lt;div class=&quot;caption&quot;&gt;
Figure 1. Copying in Two Sample System Calls&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Step one: the read system call causes a context switch from user mode to kernel mode. The first copy is performed by the DMA engine, which reads file contents from the disk and stores them into a kernel address space buffer.&lt;br /&gt;
Step two: data is copied from the kernel buffer into the user buffer, and the read system call returns. The return from the call caused a context switch from kernel back to user mode. Now the data is stored in the user address space buffer, and it can begin its way down again.&lt;br /&gt;
Step three: the write system call causes a context switch from user mode to kernel mode. A third copy is performed to put the data into a kernel address space buffer again. This time, though, the data is put into a different buffer, a buffer that is associated with sockets specifically.&lt;br /&gt;
Step four: the write system call returns, creating our fourth context switch. Independently and asynchronously, a fourth copy happens as the DMA engine passes the data from the kernel buffer to the protocol engine. You are probably asking yourself, “What do you mean independently and asynchronously? Wasn&#39;t the data transmitted before the call returned?” Call return, in fact, doesn&#39;t guarantee transmission; it doesn&#39;t even guarantee the start of the transmission. It simply means the Ethernet driver had free descriptors in its queue and has accepted our data for transmission. There could be numerous packets queued before ours. Unless the driver/hardware implements priority rings or queues, data is transmitted on a first-in-first-out basis. (The forked DMA copy in Figure 1 illustrates the fact that the last copy can be delayed).&lt;br /&gt;
As you can see, a lot of data duplication is not really necessary to hold things up. Some of the duplication could be eliminated to decrease overhead and increase performance. As a driver developer, I work with hardware that has some pretty advanced features. Some hardware can bypass the main memory altogether and transmit data directly to another device. This feature eliminates a copy in the system memory and is a nice thing to have, but not all hardware supports it. There is also the issue of the data from the disk having to be repackaged for the network, which introduces some complications. To eliminate overhead, we could start by eliminating some of the copying between the kernel and user buffers.&lt;br /&gt;
One way to eliminate a copy is to skip calling read and instead call mmap. For example:&lt;br /&gt;
&lt;pre class=&quot;programlisting&quot; style=&quot;color: #336699; overflow: auto;&quot;&gt;tmp_buf = mmap(file, len);
write(socket, tmp_buf, len);
&lt;/pre&gt;
To get a better idea of the process involved, take a look at Figure 2. Context switches remain the same.&lt;br /&gt;
&lt;div class=&quot;mediaobject&quot;&gt;
&lt;img src=&quot;http://www.linuxjournal.com/files/linuxjournal.com/linuxjournal/articles/063/6345/6345f2.jpg&quot; style=&quot;border: 0px;&quot; /&gt;&lt;div class=&quot;caption&quot;&gt;
Figure 2. Calling mmap&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Step one: the mmap system call causes the file contents to be copied into a kernel buffer by the DMA engine. The buffer is shared then with the user process, without any copy being performed between the kernel and user memory spaces.&lt;br /&gt;
Step two: the write system call causes the kernel to copy the data from the original kernel buffers into the kernel buffers associated with sockets.&lt;br /&gt;
Step three: the third copy happens as the DMA engine passes the data from the kernel socket buffers to the protocol engine.&lt;br /&gt;
By using mmap instead of read, we&#39;ve cut in half the amount of data the kernel has to copy. This yields reasonably good results when a lot of data is being transmitted. However, this improvement doesn&#39;t come without a price; there are hidden pitfalls when using the mmap+write method. You will fall into one of them when you memory map a file and then call write while another process truncates the same file. Your write system call will be interrupted by the bus error signal SIGBUS, because you performed a bad memory access. The default behavior for that signal is to kill the process and dump core—not the most desirable operation for a network server. There are two ways to get around this problem.&lt;br /&gt;
The first way is to install a signal handler for the SIGBUS signal, and then simply call return in the handler. By doing this the write system call returns with the number of bytes it wrote before it got interrupted and the errno set to success. Let me point out that this would be a bad solution, one that treats the symptoms and not the cause of the problem. Because SIGBUS signals that something has gone seriously wrong with the process, I would discourage using this as a solution.&lt;br /&gt;
The second solution involves file leasing (which is called “opportunistic locking” in Microsoft Windows) from the kernel. This is the correct way to fix this problem. By using leasing on the file descriptor, you take a lease with the kernel on a particular file. You then can request a read/write lease from the kernel. When another process tries to truncate the file you are transmitting, the kernel sends you a real-time signal, the RT_SIGNAL_LEASE signal. It tells you the kernel is breaking your write or read lease on that file. Your write call is interrupted before your program accesses an invalid address and gets killed by the SIGBUS signal. The return value of the write call is the number of bytes written before the interruption, and the errno will be set to success. Here is some sample code that shows how to get a lease from the kernel:&lt;br /&gt;
&lt;pre class=&quot;programlisting&quot; style=&quot;color: #336699; overflow: auto;&quot;&gt;if(fcntl(fd, F_SETSIG, RT_SIGNAL_LEASE) == -1) {
    perror(&quot;kernel lease set signal&quot;);
    return -1;
}
/* l_type can be F_RDLCK F_WRLCK */
if(fcntl(fd, F_SETLEASE, l_type)){
    perror(&quot;kernel lease set type&quot;);
    return -1;
}
&lt;/pre&gt;
You should get your lease before mmaping the file, and break your lease after you are done. This is achieved by calli&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;titlepage&quot;&gt;
Sendfile&lt;/div&gt;
In kernel version 2.1, the sendfile system call was introduced to simplify the transmission of data over the network and between two local files. Introduction of sendfile not only reduces data copying, it also reduces context switches. Use it like this:&lt;br /&gt;
&lt;pre class=&quot;programlisting&quot; style=&quot;color: #336699; overflow: auto;&quot;&gt;sendfile(socket, file, len);
&lt;/pre&gt;
To get a better idea of the process involved, take a look at Figure 3.&lt;br /&gt;
&lt;div class=&quot;mediaobject&quot;&gt;
&lt;img src=&quot;http://www.linuxjournal.com/files/linuxjournal.com/linuxjournal/articles/063/6345/6345f3.jpg&quot; style=&quot;border: 0px;&quot; /&gt;&lt;div class=&quot;caption&quot;&gt;
Figure 3. Replacing Read and Write with Sendfile&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Step one: the sendfile system call causes the file contents to be copied into a kernel buffer by the DMA engine. Then the data is copied by the kernel into the kernel buffer associated with sockets.&lt;br /&gt;
Step two: the third copy happens as the DMA engine passes the data from the kernel socket buffers to the protocol engine.&lt;br /&gt;
You are probably wondering what happens if another process truncates the file we are transmitting with the sendfile system call. If we don&#39;t register any signal handlers, the sendfile call simply returns with the number of bytes it transferred before it got interrupted, and the errno will be set to success.&lt;br /&gt;
If we get a lease from the kernel on the file before we call sendfile, however, the behavior and the return status are exactly the same. We also get the RT_SIGNAL_LEASE signal before the sendfile call returns.&lt;br /&gt;
So far, we have been able to avoid having the kernel make several copies, but we are still left with one copy. Can that be avoided too? Absolutely, with a little help from the hardware. To eliminate all the data duplication done by the kernel, we need a network interface that supports gather operations. This simply means that data awaiting transmission doesn&#39;t need to be in consecutive memory; it can be scattered through various memory locations. In kernel version 2.4, the socket buffer descriptor was modified to accommodate those requirements—what is known as zero copy under Linux. This approach not only reduces multiple context switches, it also eliminates data duplication done by the processor. For user-level applications nothing has changed, so the code still looks like this:&lt;br /&gt;
&lt;pre class=&quot;programlisting&quot; style=&quot;color: #336699; overflow: auto;&quot;&gt;sendfile(socket, file, len);
&lt;/pre&gt;
To get a better idea of the process involved, take a look at Figure 4.&lt;br /&gt;
&lt;div class=&quot;mediaobject&quot;&gt;
&lt;img src=&quot;http://www.linuxjournal.com/files/linuxjournal.com/linuxjournal/articles/063/6345/6345f4.jpg&quot; style=&quot;border: 0px;&quot; /&gt;&lt;div class=&quot;caption&quot;&gt;
Figure 4. Hardware that supports gather can assemble data from multiple memory locations, eliminating another copy.&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Step one: the sendfile system call causes the file contents to be copied into a kernel buffer by the DMA engine.&lt;br /&gt;
Step two: no data is copied into the socket buffer. Instead, only descriptors with information about the whereabouts and length of the data are appended to the socket buffer. The DMA engine passes data directly from the kernel buffer to the protocol engine, thus eliminating the remaining final copy.&lt;br /&gt;
Because data still is actually copied from the disk to the memory and from the memory to the wire, some might argue this is not a true zero copy. This is zero copy from the operating system standpoint, though, because the data is not duplicated between kernel buffers. When using zero copy, other performance benefits can be had besides copy avoidance, such as fewer context switches, less CPU data cache pollution and no CPU checksum calculations.&lt;br /&gt;
Now that we know what zero copy is, let&#39;s put theory into practice and write some code. You can download the full source code from&lt;a href=&quot;http://www.xalien.org/articles/source/sfl-src.tgz&quot; style=&quot;color: #003366; font-weight: bold; text-decoration: none;&quot;&gt;www.xalien.org/articles/source/sfl-src.tgz&lt;/a&gt;. To unpack the source code, type&lt;b&gt;tar -zxvf sfl-src.tgz&lt;/b&gt;&amp;nbsp;at the prompt. To compile the code and create the random data file data.bin, run&amp;nbsp;&lt;b&gt;make&lt;/b&gt;.&lt;br /&gt;
Looking at the code starting with header files:&lt;br /&gt;
&lt;pre class=&quot;programlisting&quot; style=&quot;color: #336699; overflow: auto;&quot;&gt;/* sfl.c sendfile example program
Dragan Stancevic &amp;lt;
header name                 function / variable
-------------------------------------------------*/
#include &lt;stdio .h=&quot;&quot;&gt;          /* printf, perror */
#include &lt;fcntl .h=&quot;&quot;&gt;          /* open */
#include &lt;unistd .h=&quot;&quot;&gt;         /* close */
#include &lt;errno .h=&quot;&quot;&gt;          /* errno */
#include &lt;string .h=&quot;&quot;&gt;         /* memset */
#include &lt;sys socket.h=&quot;&quot;&gt;     /* socket */
#include &lt;netinet in.h=&quot;&quot;&gt;     /* sockaddr_in */
#include &lt;sys sendfile.h=&quot;&quot;&gt;   /* sendfile */
#include &lt;arpa inet.h=&quot;&quot;&gt;      /* inet_addr */
#define BUFF_SIZE (10*1024) /* size of the tmp
                               buffer */
&lt;/arpa&gt;&lt;/sys&gt;&lt;/netinet&gt;&lt;/sys&gt;&lt;/string&gt;&lt;/errno&gt;&lt;/unistd&gt;&lt;/fcntl&gt;&lt;/stdio&gt;&lt;/pre&gt;
Besides the regular &lt;sys socket.h=&quot;&quot;&gt; and &lt;netinet in.h=&quot;&quot;&gt; required for basic socket operation, we need a prototype definition of the sendfile system call. This can be found in the &lt;sys sendfile.h=&quot;&quot;&gt; server flag:&lt;/sys&gt;&lt;/netinet&gt;&lt;/sys&gt;&lt;br /&gt;
&lt;pre class=&quot;programlisting&quot; style=&quot;color: #336699; overflow: auto;&quot;&gt;/* are we sending or receiving */
if(argv[1][0] == &#39;s&#39;) is_server++;
/* open descriptors */
sd = socket(PF_INET, SOCK_STREAM, 0);
if(is_server) fd = open(&quot;data.bin&quot;, O_RDONLY);
&lt;/pre&gt;
The same program can act as either a server/sender or a client/receiver. We have to check one of the command-prompt parameters, and then set the flag is_server to run in sender mode. We also open a stream socket of the INET protocol family. As part of running in server mode we need some type of data to transmit to a client, so we open our data file. We are using the system call sendfile to transmit data, so we don&#39;t have to read the actual contents of the file and store it in our program memory buffer. Here&#39;s the server address:&lt;pre class=&quot;programlisting&quot; style=&quot;color: #336699; overflow: auto;&quot;&gt;/* clear the memory */
memset(&amp;amp;sa, 0, sizeof(struct sockaddr_in));
/* initialize structure */
sa.sin_family = PF_INET;
sa.sin_port = htons(1033);
sa.sin_addr.s_addr = inet_addr(argv[2]);
&lt;/pre&gt;
We clear the server address structure and assign the protocol family, port and IP address of the server. The address of the server is passed as a command-line parameter. The port number is hard coded to unassigned port 1033. This port number was chosen because it is above the port range requiring root access to the system.&lt;br /&gt;
Here is the server execution branch:&lt;br /&gt;
&lt;pre class=&quot;programlisting&quot; style=&quot;color: #336699; overflow: auto;&quot;&gt;if(is_server){
    int client; /* new client socket */
    printf(&quot;Server binding to [%s]\n&quot;, argv[2]);
    if(bind(sd, (struct sockaddr *)&amp;amp;sa,
                      sizeof(sa)) &amp;lt; 0){
        perror(&quot;bind&quot;);
        exit(errno);
    }
&lt;/pre&gt;
As a server, we need to assign an address to our socket descriptor. This is achieved by the system call bind, which assigns the socket descriptor (sd) a server address (sa):&lt;br /&gt;
&lt;pre class=&quot;programlisting&quot; style=&quot;color: #336699; overflow: auto;&quot;&gt;if(listen(sd,1) &amp;lt; 0){
    perror(&quot;listen&quot;);
    exit(errno);
}
&lt;/pre&gt;
Because we are using a stream socket, we have to advertise our willingness to accept incoming connections and set the connection queue size. I&#39;ve set the backlog queue to 1, but it is common to set the backlog a bit higher for established connections waiting to be accepted. In older versions of the kernel, the backlog queue was used to prevent syn flood attacks. Because the system call listen changed to set parameters for only established connections, the backlog queue feature has been deprecated for this call. The kernel parameter tcp_max_syn_backlog has taken over the role of protecting the system from syn flood attacks:&lt;pre class=&quot;programlisting&quot; style=&quot;color: #336699; overflow: auto;&quot;&gt;if((client = accept(sd, NULL, NULL)) &amp;lt; 0){
    perror(&quot;accept&quot;);
    exit(errno);
}
&lt;/pre&gt;
The system call accept creates a new connected socket from the first connection request on the pending connections queue. The return value from the call is a descriptor for a newly created connection; the socket is now ready for read, write or poll/select system calls:&lt;pre class=&quot;programlisting&quot; style=&quot;color: #336699; overflow: auto;&quot;&gt;if((cnt = sendfile(client,fd,&amp;amp;off,
                          BUFF_SIZE)) &amp;lt; 0){
    perror(&quot;sendfile&quot;);
    exit(errno);
}
printf(&quot;Server sent %d bytes.\n&quot;, cnt);
close(client);
&lt;/pre&gt;
A connection is established on the client socket descriptor, so we can start transmitting data to the remote system. We do this by calling the sendfile system call, which is prototyped under Linux in the following manner:&lt;pre class=&quot;programlisting&quot; style=&quot;color: #336699; overflow: auto;&quot;&gt;extern ssize_t
sendfile (int __out_fd, int __in_fd, off_t *offset,
          size_t __count) __THROW;&amp;nbsp;&lt;/pre&gt;
&lt;span style=&quot;line-height: 1.3em;&quot;&gt;The first two parameters are file descriptors. The third parameter points to an offset from which sendfile should start sending data. The fourth parameter is the number of bytes we want to transmit. In order for the sendfile transmit to use zero-copy functionality, you need memory gather operation support from your networking card. You also need checksum capabilities for protocols that implement checksums, such as TCP or UDP. If your NIC is outdated and doesn&#39;t support those features, you still can use sendfile to transmit files. The difference is the kernel will merge the buffers before transmitting them.&lt;/span&gt;ng fcntl F_SETLEASE with the lease type of F_UNLCK.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;simplesect&quot; lang=&quot;en&quot;&gt;
&lt;div class=&quot;titlepage&quot;&gt;
Portability Issues&lt;/div&gt;
One of the problems with the sendfile system call, in general, is the lack of a standard implementation, as there is for the open system call. Sendfile implementations in Linux, Solaris or HP-UX are quite different. This poses a problem for developers who wish to use zero copy in their network data transmission code.&lt;br /&gt;
One of the implementation differences is Linux provides a sendfile that defines an interface for transmitting data between two file descriptors (file-to-file) and (file-to-socket). HP-UX and Solaris, on the other hand, can be used only for file-to-socket submissions.&lt;br /&gt;
The second difference is Linux doesn&#39;t implement vectored transfers. Solaris sendfile and HP-UX sendfile have extra parameters that eliminate overhead associated with prepending headers to the data being transmitted.&lt;/div&gt;
&lt;div class=&quot;simplesect&quot; lang=&quot;en&quot;&gt;
&lt;div class=&quot;titlepage&quot;&gt;
&lt;a href=&quot;&quot; name=&quot;N0xa50890.0xb3d250&quot; style=&quot;color: #003366; font-weight: bold;&quot;&gt;&lt;/a&gt;Looking Ahead&lt;/div&gt;
The implementation of zero copy under Linux is far from finished and is likely to change in the near future. More functionality should be added. For example, the sendfile call doesn&#39;t support vectored transfers, and servers such as Samba and Apache have to use multiple sendfile calls with the TCP_CORK flag set. This flag tells the system more data is coming through in the next sendfile calls. TCP_CORK also is incompatible with TCP_NODELAY and is used when we want to prepend or append headers to the data. This is a perfect example of where a vectored call would eliminate the need for multiple sendfile calls and delays mandated by the current implementation.&lt;br /&gt;
One rather unpleasant limitation in the current sendfile is it cannot be used when transferring files greater than 2GB. Files of such size are not all that uncommon today, and it&#39;s rather disappointing having to duplicate all that data on its way out. Because both sendfile and mmap methods are unusable in this case, a sendfile64 would be really handy in a future kernel version.&lt;/div&gt;
&lt;div class=&quot;simplesect&quot; lang=&quot;en&quot;&gt;
&lt;div class=&quot;titlepage&quot;&gt;
&lt;a href=&quot;&quot; name=&quot;N0xa50890.0xb3d3b0&quot; style=&quot;color: #003366; font-weight: bold;&quot;&gt;&lt;/a&gt;Conclusion&lt;/div&gt;
Despite some drawbacks, zero-copy sendfile is a useful feature, and I hope you have found this article informative enough to start using it in your programs. If you have a more in-depth interest in the subject, keep an eye out for my second article, titled “Zero Copy II: Kernel Perspective”, where I will dig a bit more into the kernel internals of zero copy.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/2247530021567893406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/zero-copy-i-user-mode-perspective.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/2247530021567893406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/2247530021567893406'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/zero-copy-i-user-mode-perspective.html' title='Zero Copy I: User-Mode Perspective'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-7656387728501405600</id><published>2013-11-15T03:00:00.000-08:00</published><updated>2013-11-15T03:00:09.839-08:00</updated><title type='text'>What are high memory and low memory on Linux?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;border: 0px; clear: both; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
On a 32-bit architecture, the address space range for addressing RAM is:&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 0px; color: #333333; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13px; line-height: 20px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; color: #222222; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;0x00000000 - 0xffffffff
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;border: 0px; clear: both; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
or&amp;nbsp;&lt;code style=&quot;background-color: #eeeeee; border: 0px; color: #222222; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13px; margin: 0px; padding: 1px 5px; vertical-align: baseline;&quot;&gt;4&#39;294&#39;967&#39;295&lt;/code&gt;&amp;nbsp;(4 GB).&lt;/div&gt;
&lt;div style=&quot;border: 0px; clear: both; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
The linux kernel splits that up 3/1 (could also be 2/2, or 1/3) into user space (high memory) and kernel space (low memory) respectively.&lt;/div&gt;
&lt;div style=&quot;border: 0px; clear: both; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
The user space range:&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 0px; color: #333333; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13px; line-height: 20px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; color: #222222; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;0x00000000 - 0xbfffffff
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;border: 0px; clear: both; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
Every newly spawned user process gets an address (range) inside this area. User processes are generally untrusted and therefore are forbidden to access the kernel space. Further, they are considered non-urgent, as a general rule, the kernel tries to defer the allocation of memory to those processes.&lt;/div&gt;
&lt;div style=&quot;border: 0px; clear: both; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
The kernel space range:&lt;/div&gt;
&lt;pre style=&quot;background-color: #eeeeee; border: 0px; color: #333333; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13px; line-height: 20px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; color: #222222; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;0xc0000000 - 0xffffffff
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;border: 0px; clear: both; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
A kernel processes gets its address (range) here. The kernel can directly access this 1 GB of addresses (well, not the full 1 GB, there are 128 MB reserved for high memory access).&lt;/div&gt;
&lt;div style=&quot;border: 0px; clear: both; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
Processes spawned in kernel space are trusted, urgent and assumed error-free, the memory request gets processed instantaneously.&lt;/div&gt;
&lt;div style=&quot;border: 0px; clear: both; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
Every kernel process can also access the user space range if it wishes to. And to achieve this, the kernel maps an address from the user space (the high memory) to its kernel space (the low memory), the 128 MB mentioned above are especially reserved for this.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/7656387728501405600/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/what-are-high-memory-and-low-memory-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/7656387728501405600'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/7656387728501405600'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/what-are-high-memory-and-low-memory-on.html' title='What are high memory and low memory on Linux?'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-2597992390589748520</id><published>2013-11-15T02:54:00.001-08:00</published><updated>2013-11-15T02:54:17.278-08:00</updated><title type='text'>What is difference between User space and Kernel space</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;blockquote style=&quot;background-color: #f0f0f0; border-left-color: rgb(204, 204, 204); border-left-style: dotted; border-width: 0px 0px 0px 2px; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin: 0px 0px 10px; padding: 10px 10px 1px; quotes: none; vertical-align: baseline;&quot;&gt;
&lt;div style=&quot;border: 0px; clear: both; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
Is Kernel space used when Kernel is executing on the behalf of the user program i.e. System Call? Or is it the address space for all the Kernel threads (for example scheduler)?&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;border: 0px; clear: both; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
Yes and yes.&lt;/div&gt;
&lt;div style=&quot;border: 0px; clear: both; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
Before we go any further, we should state this about memory.&lt;/div&gt;
&lt;div style=&quot;border: 0px; clear: both; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Memory get&#39;s divided into two distinct areas:&lt;/strong&gt;&lt;/div&gt;
&lt;ul style=&quot;border: 0px; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 1em 30px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; line-height: 16px; margin: 0px 0px 7px; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;The user space&lt;/strong&gt;, which is a set of locations where normal user processes run (i.e everything other than the kernel). The role of the kernel is to manage applications running in this space from messing with each other, and the machine, and&lt;/li&gt;
&lt;li style=&quot;border: 0px; line-height: 16px; margin: 0px 0px 7px; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;The kernel space&lt;/strong&gt;, which is the location where the code of the kernel is stored, and executes under.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;border: 0px; clear: both; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
Processes running under the user space have access only to a limited part of memory, whereas the kernel has access to all of the memory. Processes running in user space also&amp;nbsp;&lt;em style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;don&#39;t&lt;/em&gt;&amp;nbsp;have access to the kernel space. User space processes can&amp;nbsp;&lt;em style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;only access a small part of the kernel&lt;/em&gt;&amp;nbsp;via an interface exposed by the kernel -&amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;the system calls&lt;/strong&gt;. If an process performs a system call, a software interrupt is sent to the kernel, which then dispatches the appropriate interrupt handler and continues its work after the handler has finished.&lt;/div&gt;
&lt;div style=&quot;border: 0px; clear: both; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
Kernel space code has the property to run in &quot;kernel mode&quot;, which (in your typical desktop -x86- computer) is what you&amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;call code that executes under ring 0&lt;/strong&gt;.&amp;nbsp;&lt;em style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Typically in x86 architecture, there are 4 rings of protection&lt;/em&gt;. Ring 0 (kernel mode), Ring 1 (may be used by virtual machine hypervisors or drivers), Ring 2 (may be used by drivers, I am not so sure about that though) and Ring 3. Ring 3 is what typical applications run under. It is the least privileged ring, and applications running on it have access to a subset of the processor&#39;s instructions. Ring 0 (kernel space) is the most privileged ring, and has access to all of the machine&#39;s instructions. For example to this, a &quot;plain&quot; application (like a browser) can not use x86 assembly instructions&amp;nbsp;&lt;code style=&quot;background-color: #eeeeee; border: 0px; color: #222222; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13px; margin: 0px; padding: 1px 5px; vertical-align: baseline;&quot;&gt;lgdt&lt;/code&gt;&amp;nbsp;to load the global descriptor table or&amp;nbsp;&lt;code style=&quot;background-color: #eeeeee; border: 0px; color: #222222; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13px; margin: 0px; padding: 1px 5px; vertical-align: baseline;&quot;&gt;hlt&lt;/code&gt;&amp;nbsp;to halt a processor.&lt;/div&gt;
&lt;blockquote style=&quot;background-color: #f0f0f0; border-left-color: rgb(204, 204, 204); border-left-style: dotted; border-width: 0px 0px 0px 2px; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin: 0px 0px 10px; padding: 10px 10px 1px; quotes: none; vertical-align: baseline;&quot;&gt;
&lt;div style=&quot;border: 0px; clear: both; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
If it is the first one, than does it mean that normal user program cannot have more than 3GB of memory (if the division is 3GB + 1GB)? Also, in that case how can kernel use High Memory, because to what virtual memory address will the pages from high memory be mapped to, as 1GB of kernel space will be logically mapped?&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;border: 0px; clear: both; color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 15px; line-height: 20px; margin-bottom: 1em; padding: 0px; vertical-align: baseline;&quot;&gt;
For an answer to this, please refer to the excellent answer by&amp;nbsp;&lt;a href=&quot;http://unix.stackexchange.com/users/3069/wag&quot; style=&quot;border: 0px; color: #2b6d97; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot;&gt;wag&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;http://unix.stackexchange.com/a/5151/20260&quot; style=&quot;border: 0px; color: #2b6d97; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot;&gt;here&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/2597992390589748520/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/what-is-difference-between-user-space.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/2597992390589748520'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/2597992390589748520'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/what-is-difference-between-user-space.html' title='What is difference between User space and Kernel space'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-6221534991505626167</id><published>2013-11-14T22:41:00.002-08:00</published><updated>2013-11-15T03:21:23.778-08:00</updated><title type='text'>NAT DSlite 6rd NAT64</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
NAT&lt;br /&gt;
&lt;br /&gt;
&lt;h1 class=&quot;post-title&quot; style=&quot;background-color: white; border: 0px; color: #70963e; font-family: Arial, Helvetica, sans-serif; font-size: 35px; font-weight: normal; letter-spacing: -1px; line-height: 32px; margin: 0px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
Network components&lt;/h1&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; margin-bottom: 8px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;http://blogs.citrix.com/2012/02/03/ipv6-migration-%e2%80%93-what-why-and-how/network-components/&quot; rel=&quot;attachment wp-att-174180415&quot; style=&quot;border: 0px; color: #0075b0; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; outline: none; padding: 0px; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;aligncenter size-large wp-image-174180415&quot; height=&quot;336&quot; src=&quot;http://cdn.ws.citrix.com/wp-content/uploads/2012/02/Network-components-1024x538.png&quot; style=&quot;border: 0px; display: block; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px auto; padding: 0px; text-align: center; vertical-align: top;&quot; width=&quot;665&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; margin-bottom: 8px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;post-attachment&quot; style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; margin: 0px; padding: 0px; text-align: center; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
1. DS lite&lt;br /&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; margin-bottom: 8px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
DS-Lite enables service providers to natively allocate IPv6 addresses to new customers while continuing to support IPv4 customers. Main functional components involved in DS-Lite are B4 (Basic Bridging BroadBand) and AFTR (Address Family Translation Router) as shown in figure below:&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; margin-bottom: 8px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;http://blogs.citrix.com/2012/03/22/ds-lite-%e2%80%93-ipv4-over-ipv6-and-nat/dslite/&quot; rel=&quot;attachment wp-att-174183973&quot; style=&quot;border: 0px; color: #0075b0; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; outline: none; padding: 0px; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;aligncenter size-large wp-image-174183973&quot; height=&quot;233&quot; src=&quot;http://cdn.ws.citrix.com/wp-content/uploads/2012/03/DSLite-1024x377.png&quot; style=&quot;border: 0px; display: block; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px auto; padding: 0px; text-align: center; vertical-align: top;&quot; width=&quot;592&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; margin-bottom: 8px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
Following sequence describes the connection establishment process using DS Lite:&lt;/div&gt;
&lt;ol style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; list-style-image: none; list-style-position: outside; margin: 0px 0px 8px 30px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Host with private IPv4 address initiates a connection to a resource on the public internet&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Traffic is sent to B4, which is the default gateway&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;B4, using its service provider network facing IPv6 addresses establishes the tunnel with AFTR. Address of the AFTR can be pre-configured or can be discovered using DHCPv6&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;B4 encapsulates the IPv4 packets in IPv6 transport and sends across to AFTR&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;AFTR terminates the tunnel and de-capsulate the IPv4 packet&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;AFTR device performs IPv4-IPv4 NAT before sending traffic to the destination IPv4 network&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; margin-bottom: 8px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; margin-bottom: 8px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
There are many benefits that DS Lite provides:&lt;/div&gt;
&lt;ol style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; list-style-image: none; list-style-position: outside; margin: 0px 0px 8px 30px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;A lightweight solution to allow IPv4 connectivity over IPv6 network&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Avoids the need of multiple levels of NAT as in case of LSN&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Allows service providers to move their core and access networks to IPv6 thus enabling them to benefit from IPv6 advantages&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Allows coexistence of IPv4 and IPv6&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Helps resolve IPv4 address scarcity issue&lt;/li&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Allows incremental migration to native IPv6 environmen&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; margin-bottom: 8px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
&lt;b&gt;But as always is the case, benefits don’t come without its own set of challenges:&lt;/b&gt;&lt;/div&gt;
&lt;ol style=&quot;background-color: white; border: 0px; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; list-style-image: none; list-style-position: outside; margin: 0px 0px 8px 30px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;DS Lite does not provide IPv6 and IPv4 hosts to talk to each other&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; color: #4d4f53; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Increases the size of traffic due to tunnel headers – requires MTU management to avoid fragmentation&lt;/li&gt;
&lt;li style=&quot;border: 0px; color: #4d4f53; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Need to manage and maintain bindings between customer addresses and public addresses used for translation in the AFTR device&lt;/li&gt;
&lt;li style=&quot;border: 0px; color: #4d4f53; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Brings in additional challenges for DPI in service provider network&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
2. 6rd&lt;br /&gt;
&lt;b style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;6rd&lt;/b&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;&amp;nbsp;is a mechanism to facilitate&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;IPv6 rapid deployment&lt;/b&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;&amp;nbsp;across&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/IPv4&quot; style=&quot;background-color: white; background-image: none; color: #0b0080; font-family: sans-serif; font-size: 13px; line-height: 19.1875px; text-decoration: none;&quot; title=&quot;IPv4&quot;&gt;IPv4&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;&amp;nbsp;infrastructures of Internet service providers (&lt;/span&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Internet_service_provider&quot; style=&quot;background-color: white; background-image: none; color: #0b0080; font-family: sans-serif; font-size: 13px; line-height: 19.1875px; text-decoration: none;&quot; title=&quot;Internet service provider&quot;&gt;ISPs&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;).&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: red; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 19.1875px;&quot;&gt;&lt;b&gt;6rd is just&amp;nbsp;opposite&amp;nbsp;of DS lite (just replace v4 to v6)&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;It is derived from&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/6to4&quot; style=&quot;background-color: white; background-image: none; color: #0b0080; font-family: sans-serif; font-size: 13px; line-height: 19.1875px; text-decoration: none;&quot; title=&quot;6to4&quot;&gt;6to4&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;, a preexisting mechanism to transfer&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/IPv6&quot; style=&quot;background-color: white; background-image: none; color: #0b0080; font-family: sans-serif; font-size: 13px; line-height: 19.1875px; text-decoration: none;&quot; title=&quot;IPv6&quot;&gt;IPv6&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;&amp;nbsp;packets over the&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/IPv4&quot; style=&quot;background-color: white; background-image: none; color: #0b0080; font-family: sans-serif; font-size: 13px; line-height: 19.1875px; text-decoration: none;&quot; title=&quot;IPv4&quot;&gt;IPv4&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;&amp;nbsp;network, with the significant change that it operates entirely within the end-user&#39;s&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Internet_service_provider&quot; style=&quot;background-color: white; background-image: none; color: #0b0080; font-family: sans-serif; font-size: 13px; line-height: 19.1875px; text-decoration: none;&quot; title=&quot;Internet service provider&quot;&gt;ISP&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;&#39;s network, thus avoiding the major architectural problems inherent in the original design of 6to4. The name 6rd is a reference to both the rapid deployments of IPv6 it makes possible and, informally, the initials (RD) of its inventor,&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/R%C3%A9mi_Despr%C3%A9s&quot; style=&quot;background-color: white; background-image: none; color: #0b0080; font-family: sans-serif; font-size: 13px; line-height: 19.1875px; text-decoration: none;&quot; title=&quot;Rémi Després&quot;&gt;Rémi Després&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;. A description of 6rd principles and of how they were first used by&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Free_(ISP)&quot; style=&quot;background-color: white; background-image: none; color: #0b0080; font-family: sans-serif; font-size: 13px; line-height: 19.1875px; text-decoration: none;&quot; title=&quot;Free (ISP)&quot;&gt;Free&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;&amp;nbsp;is published in&amp;nbsp;&lt;/span&gt;&lt;a class=&quot;external mw-magiclink-rfc&quot; href=&quot;http://tools.ietf.org/html/rfc5569&quot; rel=&quot;nofollow&quot; style=&quot;background-color: white; background-image: url(data:image/png; background-position: 100% 50%; background-repeat: no-repeat no-repeat; color: #663366; font-family: sans-serif; font-size: 13px; line-height: 19.1875px; padding-right: 13px; text-decoration: none;&quot;&gt;RFC 5569&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.1875px;&quot;&gt;.&lt;/span&gt;&lt;sup class=&quot;reference&quot; id=&quot;cite_ref-RFC5569_1-0&quot; style=&quot;background-color: white; font-family: sans-serif; line-height: 1em;&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/IPv6_rapid_deployment#cite_note-RFC5569-1&quot; style=&quot;background-image: none; background-position: initial initial; background-repeat: initial initial; color: #0b0080; text-decoration: none; white-space: nowrap;&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; margin-bottom: 8px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
&amp;nbsp;Service Providers to provision IPv6 addresses to end customers without upgrading their core infrastructure to IPv6. 6rd enables IPv6 hosts separated by IPv4 networks to communicate with each other by establishing an IPv4 tunnel. The tunnel origination point on the sender’s side of the tunnel encapsulates the IPv6 traffic within IPv4 packets, and sends them over IPv4 to the device at the remote end of the tunnel. The device on the other end of the tunnel decapsulates the packets and sends them over the IPv6 network to their destination.&lt;/div&gt;
&lt;div class=&quot;mceTemp mceIEcenter&quot; style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;

&lt;dl style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: 1.5; margin: 0px 0px 8px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;dt style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;http://blogs.citrix.com/2012/03/02/6rd-%e2%80%93-ipv6-gets-a-ride-over-ipv4/6rd/&quot; rel=&quot;attachment wp-att-174182223&quot; style=&quot;border: 0px; color: #0075b0; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; outline: none; padding: 0px; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;size-large wp-image-174182223&quot; height=&quot;261&quot; src=&quot;http://cdn.ws.citrix.com/wp-content/uploads/2012/02/6rd-1024x448.png&quot; style=&quot;border: 0px; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: top;&quot; width=&quot;622&quot; /&gt;&lt;/a&gt;&lt;/dt&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;span style=&quot;background-color: white; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;Though 6rd helps ISPs to provision IPv6 connectivity to end users but it does not allow IPv6 clients to talk with IPv4 servers. For that to work solutions like NAT64 / SLB64 are required.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
3. NAT64&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;This brings in the challenge of ensuring that new IPv6 enabled devices are able to access any content – hosted on IPv4 or IPv6. &amp;nbsp;NAT64 is technology that provides the bridge between IPv6 and IPv4 by doing the protocol transformation that the other side understands.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; margin-bottom: 8px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
NAT64 does the translation from IPv6 to IPv4 based on a pre-assigned /96 prefix that is carried in the destination IPv6 address of packets. Last 32 bits of the IPv6 address carry the&lt;br /&gt;
IPv4 address of the destination IPv4 host. As the traffic passes through the NAT64 device, it looks for the prefix match – if the match is found, the device knows that the destination is IPv4 host and needs translation. Unlike the good old NAT devices, NAT64 devices need to perform protocol transformation – creating an IPv4 header based on the information in the IPv6 header. There are additional requirements to make sure that two disparate networks can talk to each other like ICMP translation along with translation of traditional applications that embed Layer 3/4 information in the packets (e.g. FTP, SIP etc).&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; margin-bottom: 8px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
Now the question is – how does the connection initiating IPv6 host knows the destination address? This gap is filled by DNS64 device. Whenever DNS64 device gets a query (AAAA) to resolve a name – it first tries to fetch the IPv6 address. If the address is found, it is returned to the host but if there is no IPv6 address – DNS64 device gets the IPv4 address prepends it with the preconfigured 96 bit prefix and returns to the host. Following diagram shows the sequence of events when an IPv6 host tries to connect with an IPv4 server.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; margin-bottom: 8px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;mceTemp mceIEcenter&quot; style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;http://blogs.citrix.com/2012/02/24/nat64-dns64-%e2%80%93-co-existential-translation/nat64/&quot; rel=&quot;attachment wp-att-174181941&quot; style=&quot;border: 0px; color: #0075b0; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px; outline: none; padding: 0px; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;aligncenter size-large wp-image-174181941&quot; height=&quot;457&quot; src=&quot;http://cdn.ws.citrix.com/wp-content/uploads/2012/02/NAT64-1024x605.png&quot; style=&quot;border: 0px; display: block; font-family: inherit; font-style: inherit; line-height: inherit; margin: 0px auto; padding: 0px; text-align: center; vertical-align: top;&quot; width=&quot;587&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; margin-bottom: 8px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; margin-bottom: 8px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
In early stages of IPv6 transition content providers are primarily providing access to web content hosted on IPv4 servers. In such scenarios SLB64 offer advantages over pure NAT64 technology. SLB64 is Server Load Balancing by exposing IPv6 connection points for IPv4 servers – so SLB64 devices not only provide translation but also provide other benefits that come along with advanced ADCs like NetScaler.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #4d4f53; font-family: HelveticaNeueW01-55Roma, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 1.5; margin-bottom: 8px; padding: 0px; position: relative; vertical-align: baseline;&quot;&gt;
There are many detractors of NAT yet there is no denying that NAT has been in use for years and is not going away anywhere soon. For IPv6 transition it is emerging as a very strong enabling technology.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/6221534991505626167/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/nat-network-components-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/6221534991505626167'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/6221534991505626167'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/nat-network-components-1.html' title='NAT DSlite 6rd NAT64'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-6128307496217151743</id><published>2013-11-11T21:45:00.001-08:00</published><updated>2013-11-11T21:45:32.307-08:00</updated><title type='text'></title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h3 class=&quot;r&quot; style=&quot;background-color: white; color: #222222; font-family: arial, sans-serif; font-size: medium; font-weight: normal; margin: 0px; overflow: hidden; padding: 0px; text-overflow: ellipsis; white-space: nowrap;&quot;&gt;
&lt;span style=&quot;color: #660099; cursor: pointer; font-weight: bold;&quot;&gt;&lt;a href=&quot;https://www.barracuda.com/&quot; style=&quot;color: #660099; cursor: pointer;&quot;&gt;Barracuda Networks&lt;/a&gt;&amp;nbsp;Interview&lt;/span&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;span style=&quot;color: #660099; cursor: pointer; font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #660099; cursor: pointer; font-weight: bold;&quot;&gt;1. kernal space and user spce commmunication&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #660099; cursor: pointer; font-weight: bold;&quot;&gt;2. pagging, virtual memory&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #660099;&quot;&gt;&lt;b&gt;3. 32bit and 64bit machine ,what is sizeof (int) in 64 bit machine&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/6128307496217151743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/barracuda-networks-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/6128307496217151743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/6128307496217151743'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2013/11/barracuda-networks-1.html' title=''/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-7171936872602420314</id><published>2013-07-22T06:45:00.003-07:00</published><updated>2013-07-22T06:45:58.669-07:00</updated><title type='text'>Mutex vs. Semaphores</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h1 style=&quot;background-color: white; clear: both; color: #3d787a; font-family: &#39;Trebuchet MS&#39;, Arial, Helvetica, sans-serif; font-size: 28px; font-weight: normal; margin-bottom: 20px; text-align: center; text-shadow: rgb(153, 153, 153) 1px 1px 2px;&quot;&gt;
&lt;a href=&quot;http://blog.feabhas.com/2009/09/mutex-vs-semaphores-%e2%80%93-part-1-semaphores/&quot; rel=&quot;bookmark&quot; style=&quot;color: #3d787a; text-decoration: none;&quot; title=&quot;Permalink to: Mutex vs. Semaphores – Part 1: Semaphores&quot;&gt;Mutex vs. Semaphores – Part 1: Semaphores&lt;/a&gt;&lt;/h1&gt;
&lt;div class=&quot;entrytext&quot; style=&quot;background-color: white; border-left-color: rgb(238, 238, 238); border-left-style: solid; border-left-width: 10px; border-right-color: rgb(238, 238, 238); border-right-style: solid; border-right-width: 10px; color: #333333; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 22px; padding: 0px 10px;&quot;&gt;
It never ceases to amaze me how often I see postings in newsgroups, etc. asking the difference between a semaphore and a mutex. Probably what baffles me more is that over 90% of the time the responses given are either incorrect or missing the key differences. The most often quoted response is that of the “&lt;a href=&quot;http://koti.mbnet.fi/niclasw/MutexSemaphore.html&quot; style=&quot;color: #3d787a; text-decoration: none;&quot;&gt;The Toilet Example (c) Copyright 2005, Niclas Winquist&lt;/a&gt;” . This summarises the differences as:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;A mutex is really a semaphore with value 1&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
No, no and no again. Unfortunately this kind of talk leads to all sorts of confusion and misunderstanding&amp;nbsp; (not to mention companies like Wind River Systems redefining a mutex as a “Mutual-Exclusion Semaphore” – now where is that wall to bang my head against?).&lt;br /&gt;
Firstly we need to clarify some terms and this is best done by revisiting the roots of the semaphore. Back in 1965, Edsger Dijkstra, a Dutch computer scientist, introduced the concept of a binary semaphore into modern programming to address possible race conditions in concurrent programs. His very simple idea was to use a pair of function calls to the operating system to indicate entering and leaving a critical region. This was achieved through the acquisition and release of an operating system resource called a semaphore. In his original work, Dijkstra used the notation of P &amp;amp; V, from the Dutch words&amp;nbsp;&lt;i&gt;Prolagen&amp;nbsp;&lt;/i&gt;(P), a neologism coming from&amp;nbsp;&lt;i&gt;To try and lower&lt;/i&gt;, and&amp;nbsp;&lt;i&gt;Verhogen&amp;nbsp;&lt;/i&gt;(V)&amp;nbsp;&lt;i&gt;To raise, To increase&lt;/i&gt;.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://www.feabhas.com/blog/uploaded_images/P-and-V-734546.png&quot; imageanchor=&quot;1&quot; style=&quot;color: #3d787a; margin-left: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;71&quot; src=&quot;http://www.feabhas.com/blog/uploaded_images/P-and-V-734542.png&quot; style=&quot;margin: 0px; padding: 5px;&quot; width=&quot;420&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
With this model the first task arriving at the&amp;nbsp;&lt;b&gt;P(S)&amp;nbsp;&lt;/b&gt;[where S is the semaphore] call gains access to the critical region. If a context switch happens while that task is in the critical region, and another task also calls on&amp;nbsp;&lt;b&gt;P(S)&lt;/b&gt;, then that second task (and any subsequent tasks) will be blocked from entering the critical region by being put in a waiting state by the operating system. At a later point the first task is rescheduled and calls&amp;nbsp;&lt;b&gt;V(S)&lt;/b&gt;&amp;nbsp;to indicate it has left the critical region. The second task will now be allowed access to the critical region.&lt;br /&gt;
A variant of Dijkstra’s semaphore was put forward by another Dutchman, Dr. Carel S. Scholten. In his proposal the semaphore can have an initial value (or count) greater than one. This enables building programs where more than one resource is being managed in a given critical region. For example, a counting semaphore could be used to manage the parking spaces in a robotic parking system. The initial count would be set to the initial free parking places. Each time a place is used the count is decremented. If the count reaches zero then the next task trying to acquire the semaphore would be blocked (i.e. it must wait until a parking space is available). Upon releasing the semaphore (A car leaving the parking system) the count is incremented by one.&lt;br /&gt;
Scholten’s semaphore is referred to as the&amp;nbsp;&lt;b&gt;General or Counting Semaphore&lt;/b&gt;, Dijkstra’s being known as the&lt;b&gt;Binary Semaphore&lt;/b&gt;.&lt;br /&gt;
Pretty much all modern Real-Time Operating Systems (RTOS) support the semaphore. For the majority, the actual implementation is based around the&amp;nbsp;&lt;b&gt;counting&amp;nbsp;&lt;/b&gt;semaphore concept. Programmers using these RTOSs may use an initial count of 1 (one) to approximate to the binary semaphore. One of the most notable exceptions is probably the leading commercial RTOS VxWorks from Wind River Systems. This has two separate APIs for semaphore creation, one for the Binary semaphore (&lt;i&gt;semBCreate&lt;/i&gt;) and another for the Counting semaphore (&lt;i&gt;semCCreate&lt;/i&gt;).&lt;br /&gt;
Hopefully we now have a clear understanding of the difference between the binary semaphore and the counting semaphore. Before moving onto the mutex we need to understand the inherent dangers associated with using the semaphore. These include:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Accidental release&lt;/li&gt;
&lt;li&gt;Recursive deadlock&lt;/li&gt;
&lt;li&gt;Task-Death deadlock&lt;/li&gt;
&lt;li&gt;Priority inversion&lt;/li&gt;
&lt;li&gt;Semaphore as a signal&lt;/li&gt;
&lt;/ul&gt;
All these problems occur at run-time and can be very difficult to reproduce; making technical support very difficult.&lt;br /&gt;
&lt;div style=&quot;color: #0b5394;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;color: #0b5394;&quot;&gt;
Accidental release&lt;/div&gt;
This problem arises mainly due to a bug fix, product enhancement or cut-and-paste mistake. In this case, through a simple programming mistake, a semaphore isn’t correctly acquired but is then released.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://www.feabhas.com/blog/uploaded_images/accidental-rel-729824.png&quot; imageanchor=&quot;1&quot; style=&quot;color: #3d787a; margin-left: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;98&quot; src=&quot;http://www.feabhas.com/blog/uploaded_images/accidental-rel-729821.png&quot; style=&quot;margin: 0px; padding: 5px;&quot; width=&quot;420&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
When the counting semaphore is being used as a binary semaphore (initial count of 1 – the most common case) this then allows two tasks into the critical region. Each time the buggy code is executed the count is increment and yet another task can enter. This is an inherent weakness of using the counting semaphore as a binary semaphore.&lt;br /&gt;
&lt;div style=&quot;color: #0b5394;&quot;&gt;
Deadlock&lt;/div&gt;
Deadlock occurs when tasks are blocked waiting on some condition that can never become true, e.g. waiting to acquire a semaphore that never becomes free. There are three possible deadlock situations associated with the semaphore:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Recursive Deadlock&lt;/li&gt;
&lt;li&gt;Deadlock through Death&lt;/li&gt;
&lt;li&gt;Cyclic Deadlock (Deadly Embrace)&lt;/li&gt;
&lt;/ul&gt;
Here we shall address the first two, but shall return to the cyclic deadlock in a later posting.&lt;br /&gt;
&lt;div style=&quot;color: #0b5394;&quot;&gt;
Recursive Deadlock&lt;/div&gt;
Recursive deadlock can occur if a task tries to lock a semaphore it has already locked. This can typically occur in libraries or recursive functions; for example, the simple locking of malloc being called twice within the framework of a library. An example of this appeared in the MySQL database bug reporting system:&lt;i&gt;&amp;nbsp;Bug #24745 InnoDB semaphore wait timeout/crash – deadlock waiting for itself&lt;/i&gt;&lt;br /&gt;
&lt;div style=&quot;color: #0b5394;&quot;&gt;
Deadlock through Task Death&lt;/div&gt;
What if a task that is holding a semaphore dies or is terminated? If you can’t detect this condition then all tasks waiting (or may wait in the future) will never acquire the semaphore and deadlock. To partially address this, it is common for the function call that acquires the semaphore to specify an optional timeout value.&lt;br /&gt;
&lt;div style=&quot;color: #0b5394;&quot;&gt;
Priority Inversion&lt;/div&gt;
The majority of RTOSs use a priority-driven pre-emptive scheduling scheme. In this scheme each task has its own assigned priority. The pre-emptive scheme ensures that a higher priority task will force a lower priority task to release the processor so it can run. This is a core concept to building real-time systems using an RTOS. Priority inversion is the case where a high priority task becomes blocked for an indefinite period by a low priority task. As an example:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;An embedded system contains an “information bus”&lt;/li&gt;
&lt;li&gt;Sequential access to the bus is protected with a semaphore.&lt;/li&gt;
&lt;li&gt;A bus management task runs frequently with a&amp;nbsp;&lt;b&gt;high priority&lt;/b&gt;&amp;nbsp;to move certain kinds of data in and out of the information bus.&lt;/li&gt;
&lt;li&gt;A meteorological data gathering task runs as an infrequent,&amp;nbsp;&lt;b&gt;low priority&lt;/b&gt;&amp;nbsp;task, using the information bus to publish its data. When publishing its data, it acquires the semaphore, writes to the bus, and release the semaphore.&lt;/li&gt;
&lt;li&gt;The system also contains a communications task which runs with&amp;nbsp;&lt;b&gt;medium priority&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Very infrequently it is possible for an interrupt to occur that causes the (medium priority) communications task to be sch&lt;br /&gt;eduled while the (high priority) information bus task is blocked waiting for the (low priority) meteorological data task.&lt;/li&gt;
&lt;li&gt;In this case, the long-running communications task, having higher priority than the meteorological task, prevents it from running, consequently preventing the blocked information bus task from running.&lt;/li&gt;
&lt;li&gt;After some time has passed, a&amp;nbsp;&lt;b&gt;watchdog timer&lt;/b&gt;&amp;nbsp;goes off, notices that the data bus task has not been executed for some time, concludes that something has gone drastically wrong, and initiate a total system reset.&lt;/li&gt;
&lt;/ul&gt;
This well reported event actual sequence of events happened on&amp;nbsp;&lt;a href=&quot;http://research.microsoft.com/en-us/um/people/mbj/Mars_Pathfinder/Authoritative_Account.html&quot; style=&quot;color: #3d787a; text-decoration: none;&quot;&gt;NASA JPL’s Mars Pathfinder spacecraft&lt;/a&gt;.&lt;br /&gt;
&lt;div style=&quot;color: #0b5394;&quot;&gt;
Semaphore as a Signal&lt;/div&gt;
Unfortunately, the term synchronization is often misused in the context of mutual exclusion. Synchronization is, by definition “To occur at the same time; be simultaneous”. Synchronization between tasks is where, typically, one task waits to be notified by another task before it can continue execution (&lt;i&gt;unilateral rendezvous&lt;/i&gt;). A variant of this is either task may wait, called the bidirectional rendezvous. This is quite different to mutual exclusion, which is a protection mechanism. However, this misuse has arisen as the counting semaphore can be used for unidirectional synchronization. For this to work, the semaphore is created with a count of 0 (zero).&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://www.feabhas.com/blog/uploaded_images/Sem-as-signal-748851.png&quot; imageanchor=&quot;1&quot; style=&quot;color: #3d787a; margin-left: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;50&quot; src=&quot;http://www.feabhas.com/blog/uploaded_images/Sem-as-signal-748850.png&quot; style=&quot;margin: 0px; padding: 5px;&quot; width=&quot;420&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Note that the P and V calls are not used as a pair in the same task. In the example, assuming Task1 calls the&amp;nbsp;&lt;b&gt;P(S)&lt;/b&gt;&amp;nbsp;it will block. When Task 2 later calls the&amp;nbsp;&lt;b&gt;V(S)&amp;nbsp;&lt;/b&gt;then the unilateral synchronization takes place and both task are ready to run (with the higher priority task actually running). Unfortunately “misusing” the semaphore as synchronization primitive can be problematic in that it makes debugging harder and increase the potential to miss “accidental release” type problems, as an&amp;nbsp;&lt;b&gt;V(S)&lt;/b&gt;&amp;nbsp;on its own (i.e. not paired with a&lt;b&gt;P(S)&lt;/b&gt;) is now considered legal code.&lt;br /&gt;
In the next posting I shall look at how the mutex address most of the weaknesses of the semaphore.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;post&quot; id=&quot;post-12&quot; style=&quot;color: black; font-size: medium; line-height: normal; padding: 0px;&quot;&gt;
&lt;h1 style=&quot;clear: both; color: #3d787a; font-family: &#39;Trebuchet MS&#39;, Arial, Helvetica, sans-serif; font-size: 28px; font-weight: normal; margin-bottom: 20px; text-align: center; text-shadow: rgb(153, 153, 153) 1px 1px 2px;&quot;&gt;
&lt;a href=&quot;http://blog.feabhas.com/2009/09/mutex-vs-semaphores-%e2%80%93-part-2-the-mutex/&quot; rel=&quot;bookmark&quot; style=&quot;color: #3d787a; text-decoration: none;&quot; title=&quot;Permalink to: Mutex vs. Semaphores – Part 2: The Mutex&quot;&gt;Mutex vs. Semaphores – Part 2: The Mutex&lt;/a&gt;&lt;/h1&gt;
&lt;div class=&quot;entrytext&quot; style=&quot;border-left-color: rgb(238, 238, 238); border-left-style: solid; border-left-width: 10px; border-right-color: rgb(238, 238, 238); border-right-style: solid; border-right-width: 10px; color: #333333; font-size: 12px; line-height: 22px; padding: 0px 10px;&quot;&gt;
In Part 1 of this series we looked at the history of the binary and counting semaphore, and then went on to discuss some of the associated problem areas. In this posting I aim to show how a different RTOS construct, the mutex, may overcome some, if not all, of these weaknesses.&lt;br /&gt;
To address the problems associated with semaphore, a new concept was developed during the late 1980’s. I have struggled to find it’s first clear definition, but the major use of the term&amp;nbsp;&lt;em&gt;mutex&amp;nbsp;&lt;/em&gt;(another neologism based around MUTual EXclusion) appears to have been driven through the development of the common programming specification for UNIX based systems. In 1990 this was formalised by the IEEE as standard IEEE Std 1003.1 commonly known as POSIX.&lt;br /&gt;
The mutex is similar to the principles of the binary semaphore with one significant difference:&amp;nbsp;&lt;strong&gt;the principle of ownership&lt;/strong&gt;. Ownership is the simple concept that when a task locks (acquires) a mutex only it can unlock (release) it. If a task tries to unlock a mutex it hasn’t locked (thus doesn’t own) then an error condition is encountered and, most importantly, the mutex is not unlocked. If the mutual exclusion object doesn’t have ownership then, irrelevant of what it is called, it is not a mutex.&lt;br /&gt;
The concept of ownership enables mutex implementations to address the problems discussed in&amp;nbsp;&lt;a href=&quot;http://www.feabhas.com/blog/2009/09/mutex-vs-semaphores-part-1-semaphores.html&quot; style=&quot;color: #3d787a; text-decoration: none;&quot;&gt;part 1&lt;/a&gt;:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Accidental release&lt;/li&gt;
&lt;li&gt;Recursive deadlock&lt;/li&gt;
&lt;li&gt;Task-Death deadlock&lt;/li&gt;
&lt;li&gt;Priority inversion&lt;/li&gt;
&lt;li&gt;Semaphore as a signal&lt;/li&gt;
&lt;/ol&gt;
&lt;a href=&quot;&quot; name=&quot;more&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;Accidental Release&lt;/span&gt;&lt;br /&gt;As already stated, ownership stops accidental release of a mutex as a check is made on the release and an error is raised if current task is not owner.&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Recursive Deadlock&lt;/span&gt;&lt;br /&gt;Due to ownership, a mutex can support relocking of the same mutex by the owning task as long as it is released the same number of times.&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Priority Inversion&lt;/span&gt;&lt;br /&gt;With ownership this problem can be addressed using one of the following priority inheritance protocols:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;[Basic] Priority Inheritance Protocol&lt;/li&gt;
&lt;li&gt;Priority Ceiling Protocol&lt;/li&gt;
&lt;/ul&gt;
The&amp;nbsp;&lt;em&gt;Basic Priority Inheritance Protocol&lt;/em&gt;&amp;nbsp;enables a low-priority task to inherit a higher-priorities task’s priority if this higher-priority task becomes blocked waiting on a mutex currently owned by the low-priority task. The low priority task can now run and unlock the mutex – at this point it is returned back to its original priority.&lt;br /&gt;
The details of the Priority Inheritance Protocol and Priority Ceiling Protocol (a slight variant) will be covered in part 3 of this series.&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Death Detection&lt;/span&gt;&lt;br /&gt;If a task terminates for any reason, the RTOS can detect if that task current owns a mutex and signal waiting tasks of this condition. In terms of what happens to the waiting tasks, there are various models, but two doiminate:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;All tasks readied with error condition;&lt;/li&gt;
&lt;li&gt;Only one task readied; this task is responsible for ensuring integrity of critical region.&lt;/li&gt;
&lt;/ul&gt;
When&amp;nbsp;&lt;em&gt;all tasks&lt;/em&gt;&amp;nbsp;are readied, these tasks must then assume critical region is in an undefined state. In this model no task currently has ownership of the mutex. The mutex is in an undefined state (and cannot be locked) and must be reinitialized.&lt;br /&gt;
When&amp;nbsp;&lt;em&gt;only one task&lt;/em&gt;&amp;nbsp;is readied, ownership of the mutex is passed from the terminated task to the readied task. This task is now responsible for ensuring integrity of critical region, and can unlock the mutex as normal.&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Mutual Exclusion / Synchronisation&lt;/span&gt;&lt;br /&gt;Due to ownership a mutex cannot be used for synchronization due to lock/unlock pairing. This makes the code cleaner by not confusing the issues of mutual exclusion with synchronization.&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Caveat&lt;/span&gt;&lt;br /&gt;A specific Operating Systems mutex implementation&amp;nbsp;&lt;strong&gt;may or may not&lt;/strong&gt;&amp;nbsp;support the following:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Recursion&lt;/li&gt;
&lt;li&gt;Priority Inheritance&lt;/li&gt;
&lt;li&gt;Death Detection&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Review of some APIs&lt;/span&gt;&lt;br /&gt;It should be noted that many Real-Time Operating Systems (or more correctly Real-Time Kernels) do not support the concept of the mutex, only supporting the&amp;nbsp;&lt;em&gt;Counting Semaphore&lt;/em&gt;&amp;nbsp;(e.g. MicroC/OS-II). [ CORRECTION: The later versions of&amp;nbsp;&lt;a href=&quot;http://micrium.com/page/products/rtos/os-ii&quot; style=&quot;color: #3d787a; text-decoration: none;&quot;&gt;uC/OS-II&lt;/a&gt;&amp;nbsp;do support the mutex, only the original version did not].&lt;br /&gt;
In this section we shall briefly examine three different implementations. I have chosen these as they represent the broad spectum of APIs offered (&lt;em&gt;Footnote 1&lt;/em&gt;):&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;VxWorks Version 5.4&lt;/li&gt;
&lt;li&gt;POSIX Threads (pThreads) – IEEE Std 1003.1, 2004 Edition&lt;/li&gt;
&lt;li&gt;Microsoft Windows Win32 – Not .NET&lt;/li&gt;
&lt;/ul&gt;
VxWorks from Wind River Systems is among the leading commercial Real-Time Operating System used in embedded systems today. POSIX Threads is a widely supported standard, but has become more widely used due to the growth of the use of Embedded Linux. Finally Microsoft Window’s common programming API, Win32 is examined. Windows CE, targeted at embedded development, supports this API.&lt;br /&gt;
However, before addressing the APIs in detail we need to introduce the concept of a&amp;nbsp;&lt;em&gt;Release Order Policy&lt;/em&gt;. In Dijkstra’s original work the concept of task priorities were not part of the problem domain. Therefore it was assumed that if more than one task was waiting on a held semaphore, when released the next task to acquire the semaphore would be chosen on a First-Come-First-Server (First-In-First-Out; FIFO) policy. However once tasks have priorities, the policy may be:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;FIFO&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; – waiting tasks ordered by arrival time&lt;/li&gt;
&lt;li&gt;Priority &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; – waiting tasks ordered by priority&lt;/li&gt;
&lt;li&gt;Undefined&amp;nbsp;&amp;nbsp; &amp;nbsp;- implementation doesn’t specify&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;VxWorks v5.4&lt;/span&gt;&lt;br /&gt;VxWorks supports the Binary Semaphore, the Counting Semaphore and the Mutex (called the Mutual-Exclusion Semaphore in VxWorks terminology). They all support a common API for acquiring (semTake) and releasing (semGive) the particular semaphore. For all semaphore types, waiting tasks can be queued by priority or FIFO and can have a timeout specified.&lt;br /&gt;
The&amp;nbsp;&lt;em&gt;Binary Semaphor&lt;/em&gt;e has, as expected, no support for recursion or inheritance and the taker and giver do not have to be same task. Some additional points of interest are&amp;nbsp; that there is no effect of releasing the semaphore again; It can be used as a signal (thus can be created empty); and supports the idea of a broadcast release (wake up all waiting tasks rather than just the first). The&amp;nbsp;&lt;em&gt;Counting Semaphore&lt;/em&gt;, as expected, is the same as the&amp;nbsp;&lt;em&gt;Binary Semaphore&lt;/em&gt;&amp;nbsp;with ability to define an initial count.&lt;br /&gt;
The Mutual-Exclusion Semaphore is the VxWorks&amp;nbsp;&lt;em&gt;mutex&lt;/em&gt;. Only the owning task may successfully call semGive. The VxWorks mutex also has the ability to support both priority inheritance (basic priority inheritance protocol) and deletion safety.&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;POSIX&amp;nbsp;&lt;/span&gt;&lt;br /&gt;POSIX is an acronym for Portable Operating System Interface (the X has no meaning). The current POSIX standard is formally defined by IEEE Std 1003.1, 2004 Edition. The mutex is part of the core POSIX Threads (pThreads) specification (historically referred to as IEEE Std 1003.1c-1995).&lt;br /&gt;POSIX also supports both semaphores and priority-inheritance mutexes as part of what are called Feature Groups. Support for these Feature Groups is optional, but when an implementation claims that a feature is provided, all of its constituent parts must be provided&lt;br /&gt;and must comply with this specification. There are two main Feature Groups of interest, the Realtime Group and Realtime Threads Groups.&lt;br /&gt;
The semaphore is not part of the core standard but is supported as part of the Realtime Feature Group. The Realtime Semaphore is an implementation of the&amp;nbsp;&lt;em&gt;Counting semaphore&lt;/em&gt;.&lt;br /&gt;
The default POSIX&amp;nbsp;&lt;em&gt;mutex&amp;nbsp;&lt;/em&gt;is non-recursive , has no priority inheritance support or death detection.&lt;br /&gt;However, the Pthreads standard allows for non-portable extensions (as long as they are tagged with “-np”).&amp;nbsp; A high proportion of programmers using POSIX threads are programming for Linux. Linux supports four different mutex types through non-portable extensions:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Fast mutex &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; – non-recursive and will deadlock [default]&lt;/li&gt;
&lt;li&gt;Error checking mutex – non-recursive but will report error&lt;/li&gt;
&lt;li&gt;Recursive mutex&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; – as the name implies&lt;/li&gt;
&lt;li&gt;Adaptive mutex &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;- extra fast for mutli-processor systems&lt;/li&gt;
&lt;/ul&gt;
These are extreamly well covered by Chris Simmonds in his posting&amp;nbsp;&lt;a href=&quot;http://www.embedded-linux.co.uk/tutorial/mutex_mutandis&quot; style=&quot;color: #3d787a; text-decoration: none;&quot;&gt;Mutex mutandis: understanding mutex types and attributes&lt;/a&gt;.&lt;br /&gt;
Finally the Realtime Threads Feature Group adds mutex support for both priority inheritance and priority ceiling protocols.&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Win32 API&lt;/span&gt;&lt;br /&gt;Microsoft Window’s common API is referred to as Win32. This API supports three different primitives:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Semaphore&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; – The counting semaphore&lt;/li&gt;
&lt;li&gt;Critical Section &amp;nbsp;&amp;nbsp; &amp;nbsp;- Mutex between threads in the same process; Recursive, no timeout, queuing order undefined&lt;/li&gt;
&lt;li&gt;Mutex &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; – As per critical sections, but can be used by threads in different processes; Recursive, timeout, queuing order undefined&lt;/li&gt;
&lt;/ul&gt;
The XP/Win32 mutex API does not support priority inheritance in application code, however the WinCE/Win32 API does!&lt;br /&gt;
Win32 mutexes do have built-in death detection; if a thread terminates when holding a mutex, then that mutex is said to be abandoned. The mutex is released (with WAIT_ABANDONED error code) and a waiting thread will take ownership. Note that Critical sections do not have any form of death detection.&lt;br /&gt;
Critical Sections have no timeout ability, whereas mutexes do. However Critical Sections support a separate function call TryEnterCriticalSection. A major weakness of the Win32 API is that the queuing model is undefined (i.e. neither Priority nor FIFO). According to Microsoft this is done to improve performance.&lt;br /&gt;
So, what can we gather from this? First and foremost the term mutex is less well defined than the semaphore. Secondly,the actual implementations from RTOS to RTOS vary massively. I urge you to go back and look at your faviourite RTOS and work out what support, if any, you have for the mutex. I’d love to hear from people regarding mutual exclusion support (both semaphores and mutexes) for their RTOS of choice. If you’d like to contact me do so at&amp;nbsp;&lt;a href=&quot;mailto:nsc@acm.org&quot; style=&quot;color: #3d787a; text-decoration: none;&quot;&gt;nsc(at)acm.org&lt;/a&gt;.&lt;br /&gt;
Finally, Part 3 will look at a couple of problems the mutex doesn’t solve, and how these can be overcome. As part of that it will review the Basic Priority Inheritance Protcol and the Prority Ceiling Protocol.&lt;br /&gt;
At a later date I will also address the use of, and problems associted with, the semaphore being used for task synchronisation.&lt;br /&gt;
&lt;strong&gt;ENDNOTES&lt;/strong&gt;&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Please I do not want to get into the “&lt;em&gt;that’s not a real-time OS&lt;/em&gt;” debate here – let’s save that for another day!&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&amp;nbsp;&lt;/em&gt;A number of people pointed out that Michael Barr (former editor of Embedded Systems Programming, now president of Netrino) has a good article about the differences between mutexes &amp;amp; semaphores at the following location:&amp;nbsp;&lt;a href=&quot;http://www.netrino.com/node/202&quot; style=&quot;color: #3d787a; text-decoration: none;&quot;&gt;http://www.netrino.com/node/202&lt;/a&gt;. I urge you to read his posting as well.&lt;/li&gt;
&lt;li&gt;Apologies about not having the atom feed sorted – this should all be working now&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;clear&quot; style=&quot;clear: both;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;commenti-info&quot; style=&quot;clear: both; color: black; font-size: 10px; line-height: normal; text-align: right;&quot;&gt;
Posted on September 11th, 2009&lt;br /&gt;»&amp;nbsp;&lt;a href=&quot;http://blog.feabhas.com/2009/09/mutex-vs-semaphores-%e2%80%93-part-2-the-mutex/feed/&quot; style=&quot;color: #3d787a; text-decoration: none;&quot;&gt;Feed to this thread&lt;/a&gt;&lt;br /&gt;»&amp;nbsp;&lt;a href=&quot;http://blog.feabhas.com/2009/09/mutex-vs-semaphores-%e2%80%93-part-2-the-mutex/trackback/&quot; rel=&quot;trackback&quot; style=&quot;color: #3d787a; text-decoration: none;&quot;&gt;Trackback&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;post&quot; id=&quot;post-11&quot; style=&quot;font-size: medium; padding: 0px; text-align: start;&quot;&gt;
&lt;h1 style=&quot;clear: both; color: #3d787a; font-family: &#39;Trebuchet MS&#39;, Arial, Helvetica, sans-serif; font-size: 28px; font-weight: normal; margin-bottom: 20px; text-align: center; text-shadow: rgb(153, 153, 153) 1px 1px 2px;&quot;&gt;
&lt;a href=&quot;http://blog.feabhas.com/2009/10/mutex-vs-semaphores-%e2%80%93-part-3-final-part-mutual-exclusion-problems/&quot; rel=&quot;bookmark&quot; style=&quot;color: #3d787a; text-decoration: none;&quot; title=&quot;Permalink to: Mutex vs. Semaphores – Part 3 (final part): Mutual Exclusion Problems&quot;&gt;Mutex vs. Semaphores – Part 3 (final part): Mutual Exclusion Problems&lt;/a&gt;&lt;/h1&gt;
&lt;div class=&quot;entrytext&quot; style=&quot;border-left-color: rgb(238, 238, 238); border-left-style: solid; border-left-width: 10px; border-right-color: rgb(238, 238, 238); border-right-style: solid; border-right-width: 10px; color: #333333; font-size: 12px; line-height: 22px; padding: 0px 10px;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://www.feabhas.com/blog/uploaded_images/deadlock-764912.JPG&quot; style=&quot;color: #3d787a; margin-left: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;/a&gt;&lt;/div&gt;
As hopefully you can see from the previous posting, the mutex is a significantly safer mechanism to use for implementing mutual exclusion around shared resources. Nevertheless, there are still a couple of problems that use of the mutex (in preference to the semaphore) will not solve. These are:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Circular deadlock&lt;/li&gt;
&lt;li&gt;Non-cooperation&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;color: #3d85c6;&quot;&gt;Circular Deadlock&lt;/span&gt;&lt;br /&gt;Circular deadlock, often referred to as the “deadly embrace” problem is a condition where two or more tasks develop a circular dependency of mutual exclusion. Simply put, one task is blocked waiting on a mutex owned by another task. That other task is also block waiting on a mutex held by the first task.&lt;br /&gt;
So how can this happen? Take as an example a small control system. The system is made up of three tasks, a low priority Control task, a medium priority System Identification (SI) task and a high priority Alarm task. There is an analogue input shared by the Control and the SI tasks, which is protected by a mutex. There is also an analogue output protected by a different mutex.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://www.feabhas.com/blog/uploaded_images/deadlock-tasks-745788.PNG&quot; style=&quot;color: #3d787a; margin-left: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;258&quot; src=&quot;http://www.feabhas.com/blog/uploaded_images/deadlock-tasks-745784.PNG&quot; style=&quot;margin: 0px; padding: 5px;&quot; width=&quot;420&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
The Control task waits for mutexes ADC and DAC:&lt;br /&gt;
&lt;div style=&quot;color: #073763;&quot;&gt;
mutex_lock (ADC);&lt;br /&gt;mutex_lock (DAC);&lt;br /&gt;/* critical section */&lt;br /&gt;mutex_unlock (ADC);&lt;br /&gt;mutex_unlock (DAC);&lt;/div&gt;
The SI Task waits for mutexes DAC and ADC:&lt;br /&gt;
&lt;span style=&quot;color: #073763;&quot;&gt;mutex_lock (DAC);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #073763;&quot;&gt;mutex_lock (ADC);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #073763;&quot;&gt;/* critical section */&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #073763;&quot;&gt;mutex_unlock (DAC);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #073763;&quot;&gt;mutex_unlock (ADC);&lt;/span&gt;&lt;br /&gt;
Unfortunately, under certain timing conditions, this can lead to deadlock. In this example the Control task has locked the ADC, but before locking the DAC has been pre-empted by the higher priory SI task. The SI task then locks the DAC and tries to lock the ADC. The SI task is now blocked as the ADC is already owned by the Control task. The Control task now runs and tries to lock the DAC. It is blocked as the DAC is held by the SI task. Neither task can continue until the mutex is unlocked and neither mutex can be unlocked until either task runs – classic deadlock.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://www.feabhas.com/blog/uploaded_images/deadlock-764912.JPG&quot; style=&quot;color: #3d787a; margin-left: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;239&quot; src=&quot;http://www.feabhas.com/blog/uploaded_images/deadlock-764846.JPG&quot; style=&quot;margin: 0px; padding: 5px;&quot; width=&quot;420&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
For circular deadlock to occur the following conditions must all be true:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;A thread has exclusive use of resources (Mutual exclusion)&lt;/li&gt;
&lt;li&gt;A thread can hold on to a resource(s) whilst waiting for another resource (Hold and wait)&lt;/li&gt;
&lt;li&gt;A circular dependency of thread and resources is set up (Circular waiting)&lt;/li&gt;
&lt;li&gt;A thread never releases a resource until it is completely finished with it (No resource preemption)&lt;/li&gt;
&lt;/ul&gt;
These conditions can be addressed in a number of ways. For example, a design policy may stipulate that if a task needs to lock more than one mutex it must either lock all or none.&lt;br /&gt;
&lt;div style=&quot;color: #0b5394;&quot;&gt;
Priority Ceiling Protocol&lt;/div&gt;
With the&amp;nbsp;&lt;em&gt;Priority Ceiling Protocol&lt;/em&gt;&amp;nbsp;(PCP) method each mutex has a defined priority ceiling, set to that of the highest priority task which uses the mutex. Any task using a mutex executes at its own priority – until a second task attempts to acquire the mutex.&amp;nbsp; At this point it has its priority raised to the ceiling value, preventing suspension and thus eliminating the “hold and wait” condition.&lt;br /&gt;
In the deadlock example shown before, the significant point is when the SI task tries to lock the DAC. Before that succeeded and lead to cyclic deadlock. However with a PCP mutex, both the ADC and DAC mutex will have a ceiling priority equal to the SI’s task priority. When the SI task tries to lock the DAC, then the run-time system will detect that the SI’s task priority is not higher than the priority of the locked mutex ADC. The run-time system suspends the SI task without locking the DAC mutex. The control task now inherits the priority of the SI task and resumes execution.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://www.feabhas.com/blog/uploaded_images/PCP-725081.PNG&quot; style=&quot;color: #3d787a; margin-left: 1em; margin-right: 1em; text-decoration: none;&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;237&quot; src=&quot;http://www.feabhas.com/blog/uploaded_images/PCP-725077.PNG&quot; style=&quot;margin: 0px; padding: 5px;&quot; width=&quot;420&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;color: #0b5394;&quot;&gt;
Non-cooperation&lt;/div&gt;
The last, but most important aspect of mutual exclusion covered in these ramblings relies on one founding principle:&lt;em&gt;&amp;nbsp;we have to rely on all tasks to access critical regions using mutual exclusion primitives&lt;/em&gt;. Unfortunately this is dependent on the design of the software and cannot be detected by the run-time system. This final problem was addressed by Tony Hoare, called the&amp;nbsp;&lt;strong&gt;Monitor&lt;/strong&gt;.&lt;br /&gt;
&lt;div style=&quot;color: #0b5394;&quot;&gt;
The Monitor&lt;/div&gt;
The monitor is a mechanism&amp;nbsp; not typically supplied by the RTOS, but something the programmer tends to build (a notable exception is Ada95′s protected object mechanism). A monitor simply encapsulates the shared resource and the locking mechanism into a single construct (e.g. a C++ Object that encapsulates the mutex mechanism). Access to the shared resource, then, is through a controlled interface which cannot be bypassed (i.e. the application never explicitly calls the mutex, but calls upon access functions).&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Finishing Off…&lt;/span&gt;&lt;br /&gt;This goal of these initial postings is to demonstrate that common terms used in the real-time programming community are open to ambiguity and interpretation. Hopefully you should now be clear about the core differences between the Binary Semaphore, General (counting) Semaphore and the Mutex.&lt;br /&gt;
The underlying difference between the Semaphores and the Mutex is the&amp;nbsp;&lt;strong&gt;Principle of Ownership&lt;/strong&gt;. Given the principle of ownership a particular implementation of a mutex may support&amp;nbsp;&lt;em&gt;Recursion&lt;/em&gt;,&amp;nbsp;&lt;em&gt;Priority inheritance&lt;/em&gt;and&amp;nbsp;&lt;em&gt;Death Detection&lt;/em&gt;.&lt;br /&gt;
&lt;strong&gt;ENDNOTE&amp;nbsp;&lt;/strong&gt;&lt;br /&gt;An aspect of the mutex I haven’t covered here is that many operating systems support the concept of a&lt;em&gt;condition variable&lt;/em&gt;. A condition variable allows a task to wait on a synchronization primitive within a critical region. The whole aspect Synchronization Patterns (e.g. semaphore as a signal) within the context of RTOSs will be the subject of my next posting.&lt;br /&gt;
&lt;div class=&quot;clear&quot; style=&quot;clear: both;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;commenti-info&quot; style=&quot;clear: both;&quot;&gt;
Posted on October 5th, 2009&lt;br /&gt;»&amp;nbsp;&lt;a href=&quot;http://blog.feabhas.com/2009/10/mutex-vs-semaphores-%e2%80%93-part-3-final-part-mutual-exclusion-problems/feed/&quot; style=&quot;color: #3d787a; text-decoration: none;&quot;&gt;Feed to this thread&lt;/a&gt;&lt;br /&gt;»&amp;nbsp;&lt;a href=&quot;http://blog.feabhas.com/2009/10/mutex-vs-semaphores-%e2%80%93-part-3-final-part-mutual-exclusion-problems/trackback/&quot; rel=&quot;trackback&quot; style=&quot;color: #3d787a; text-decoration: none;&quot;&gt;Trackback&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/7171936872602420314/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2013/07/mutex-vs-semaphores.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/7171936872602420314'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/7171936872602420314'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2013/07/mutex-vs-semaphores.html' title='Mutex vs. Semaphores'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-718558314010682562</id><published>2013-07-22T00:04:00.002-07:00</published><updated>2013-07-22T00:04:53.614-07:00</updated><title type='text'>When should one use a spinlock instead of mutex?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;
&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;he Theory&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;
In theory, when a thread tries to lock a mutex and it does not succeed, because the mutex is already locked, it will go to sleep, immediately allowing another thread to run. It will continue to sleep until being woken up, which will be the case once the mutex is being unlocked by whatever thread was holding the lock before. When a tread tries to lock a spinlock and it does not succeed, it will continuously re-try locking it, until it finally succeeds; thus it will not allow another thread to take its place (however, the operating system will forcefully switch to another thread, once the CPU runtime quantum of the current thread has been exceeded, of course).&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;
&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;The Problem&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;
The problem with mutexes is that putting threads to sleep and waking them up again are both rather expensive operations, they&#39;ll need quite a lot of CPU instructions and thus also take some time. If now the mutex was only locked for a very short amount of time, the time spent in putting a thread to sleep and waking it up again might exceed the time the thread has actually slept by far and it might even exceed the time the thread would have wasted by constantly polling on a spinlock. On the other hand, polling on a spinlock will constantly waste CPU time and if the lock is held for a longer amount of time, this will waste a lot more CPU time and it would have been much better if the thread was sleeping instead.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;
&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;The Solution&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;
Using spinlocks on a single-core/single-CPU system makes usually no sense, since as long as the spinlock polling is blocking the only available CPU core, no other thread can run and since no other thread can run, the lock won&#39;t be unlocked either. IOW, a spinlock wastes only CPU time on those systems for no real benefit. If the thread was put to sleep instead, another thread could have ran at once, possibly unlocking the lock and then allowing the first thread to continue processing, once it woke up again.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;
On a multi-core/multi-CPU systems, with plenty of locks that are held for a very short amount of time only, the time wasted for constantly putting threads to sleep and waking them up again might decrease runtime performance noticeably. When using spinlocks instead, threads get the chance to take advantage of their full runtime quantum (always only blocking for a very short time period, but then immediately continue their work), leading to much higher processing throughput.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;
&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;The Practice&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;
Since very often programmers cannot know in advance if mutexes or spinlocks will be better (e.g. because the number of CPU cores of the target architecture is unknown), nor can operating systems know if a certain piece of code has been optimized for single-core or multi-core environments, most systems don&#39;t strictly distinguish between mutexes and spinlocks. In fact, most modern operating systems have hybrid mutexes and hybrid spinlocks. What does that actually mean?&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;
A hybrid mutex behaves like a spinlock at first on a multi-core system. If a thread cannot lock the mutex, it won&#39;t be put to sleep immediately, since the mutex might get unlocked pretty soon, so instead the mutex will first behave exactly like a spinlock. Only if the lock has still not been obtained after a certain amount of time (or retries or any other measuring factor), the thread is really put to sleep. If the same system runs on a system with only a single core, the mutex will not spinlock, though, as, see above, that would not be beneficial.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;
A hybrid spinlock behaves like a normal spinlock at first, but to avoid wasting too much CPU time, it may have a back-off strategy. It will usually not put the thread to sleep (since you don&#39;t want that to happen when using a spinlock), but it may decide to stop the thread (either immediately or after a certain amount of time) and allow another thread to run, thus increasing chances that the spinlock is unlocked (a pure thread switch is usually less expensive than one that involves putting a thread to sleep and waking it up again later on, though not by far).&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;
&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Summary&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: both; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 18px; margin-bottom: 1em; padding: 0px; vertical-align: baseline; word-wrap: break-word;&quot;&gt;
If in doubt, use mutexes, they are usually the better choice and most modern systems will allow them to spinlock for a very short amount of time, if this seems beneficial. Using spinlocks can sometimes improve performance, but only under certain conditions and the fact that you are in doubt rather tells me, that you are not working on any project currently where a spinlock might be beneficial. You might consider using your own &quot;lock object&quot;, that can either use a spinlock or a mutex internally (e.g. this behavior could be configurable when creating such an object), initially use mutexes everywhere and if you think that using a spinlock somewhere might really help, give it a try and compare the results (e.g. using a profiler), but be sure to test both cases, a single-core and a multi-core system before you jump to conclusions (and possibly different operating systems, if your code will be cross-platform).&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/718558314010682562/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2013/07/when-should-one-use-spinlock-instead-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/718558314010682562'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/718558314010682562'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2013/07/when-should-one-use-spinlock-instead-of.html' title='When should one use a spinlock instead of mutex?'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-765928600741277799</id><published>2012-12-16T20:02:00.001-08:00</published><updated>2012-12-16T20:02:02.462-08:00</updated><title type='text'>saminer</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;iframe allowfullscreen=&quot;allowfullscreen&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;http://www.youtube.com/embed/eDiA1p5DlLg&quot; width=&quot;560&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/765928600741277799/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2012/12/saminer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/765928600741277799'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/765928600741277799'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2012/12/saminer.html' title='saminer'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/eDiA1p5DlLg/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-7868313755335398295</id><published>2012-06-21T23:09:00.002-07:00</published><updated>2012-06-21T23:09:23.212-07:00</updated><title type='text'></title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;hentry-meta&quot; style=&quot;border-bottom-color: rgb(255, 88, 0); border-bottom-style: solid; border-width: 0px 0px 1px; font-family: Helvetica, Arial, sans-serif; font-size: 10px; margin: 0px 0px 5px; outline: 0px; padding: 0px 0px 15px; vertical-align: baseline;&quot;&gt;
&lt;h1 style=&quot;background-color: transparent; border: 0px; color: #323232; font-size: 30px; line-height: 33px; margin: 0px; outline: 0px; padding: 0px 0px 10px; vertical-align: baseline;&quot;&gt;
GNU Make in Detail for Beginners&lt;/h1&gt;
&lt;div class=&quot;hentry-meta-data&quot; style=&quot;background-color: transparent; border: 0px; color: #323232; font-size: 12px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
By&amp;nbsp;&lt;a href=&quot;http://www.linuxforu.com/author/sarath-lakshman/&quot; style=&quot;background-color: transparent; border: 0px; color: #007ac9; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; title=&quot;Posts by Sarath Lakshman&quot;&gt;Sarath Lakshman&lt;/a&gt;&amp;nbsp;on June 9, 2012 in&amp;nbsp;&lt;a href=&quot;http://www.linuxforu.com/category/developers/&quot; rel=&quot;category tag&quot; style=&quot;background-color: transparent; border: 0px; color: #007ac9; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; title=&quot;View all posts in Developers&quot;&gt;Developers&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://www.linuxforu.com/category/how-tos/&quot; rel=&quot;category tag&quot; style=&quot;background-color: transparent; border: 0px; color: #007ac9; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; title=&quot;View all posts in How-Tos&quot;&gt;How-Tos&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://www.linuxforu.com/category/how-tos/tools-apps/&quot; rel=&quot;category tag&quot; style=&quot;background-color: transparent; border: 0px; color: #007ac9; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; title=&quot;View all posts in Tools / Apps&quot;&gt;Tools / Apps&lt;/a&gt;&amp;nbsp;·&amp;nbsp;&lt;a data-disqus-identifier=&quot;12042 http://www.linuxforu.com/?p=12042&quot; href=&quot;http://www.linuxforu.com/2012/06/gnu-make-in-detail-for-beginners/#disqus_thread&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; border: 0px; color: #007ac9; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; title=&quot;Comment on GNU Make in Detail for Beginners&quot;&gt;2 Comments and 0 Reactions&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;hentry-container clear&quot; style=&quot;border: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 10px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;hentry-middle&quot; style=&quot;background-color: transparent; border: 0px; float: none; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; width: 620px;&quot;&gt;
&lt;div class=&quot;hentry-content clear&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #323232; font-size: 14px; line-height: 1.5; margin: 0px; outline: 0px; overflow: hidden; padding: 15px 0px 0px; vertical-align: baseline; width: 610px;&quot;&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;img alt=&quot;GNU Make in Detail for Beginners&quot; class=&quot;aligncenter size-large wp-image-12047&quot; height=&quot;295&quot; src=&quot;http://cdn.linuxforu.com/wp-content/uploads/2012/06/make-590x295.jpg&quot; style=&quot;background-color: transparent; border: 1px double rgb(239, 239, 239); clear: both; display: block; height: auto; margin: 15px auto; max-width: 610px; outline: 0px; padding: 0px; vertical-align: baseline;&quot; title=&quot;GNU Make in Detail for Beginners&quot; width=&quot;590&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;introduction&quot; style=&quot;background-color: transparent; border-bottom-color: rgb(255, 88, 0); border-bottom-style: double; border-width: 0px 0px 3px; font-family: Georgia; font-size: medium; font-style: italic; margin-bottom: 15px; outline: 0px; padding: 10px; vertical-align: baseline;&quot;&gt;
Have you ever peeked into the source code of any of the applications you run every day? Ever used&amp;nbsp;&lt;em style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 16px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;make install&lt;/em&gt;&amp;nbsp;to install some application? You will see make in most projects. It enables developers to easily compile large and complex programs with many components. It’s also used for writing maintenance scripts based on timestamps. This article shows you how to have fun with make.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Large projects can contain thousands of lines of code, distributed in multiple source files, written by many developers and arranged in several subdirectories. A project may contain several component divisions. These components may have complex inter-dependencies — for example, in order to compile component X, you have to first compile Y; in order to compile Y, you have to first compile Z; and so on. For a large project, when a few changes are made to the source, manually recompiling the entire project each time is tedious, error-prone and time-consuming.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Make is a solution to these problems. It can be used to specify dependencies between components, so that it will compile components in the order required to satisfy dependencies. An important feature is that when a project is recompiled after a few changes, it will recompile only the files which are changed, and any components that are dependent on it. This saves a lot of time. Make is, therefore, an essential tool for a large software project.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Each project needs a Makefile — a script that describes the project structure, namely, the source code files, the dependencies between them, compiler arguments, and how to produce the target output (normally, one or more executables). Whenever the make command is executed, the Makefile in the current working directory is interpreted, and the instructions executed to produce the target outputs. The Makefile contains a collection of rules, macros, variable assignments, etc. (‘Makefile’ or ‘makefile’ are both acceptable.)&lt;/div&gt;
&lt;h2 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 26px; font-weight: normal; line-height: 30px; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Installing GNU Make&lt;/h2&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Most distributions don’t ship make as part of the default installation. You have to install it, either using the package-management system, or by manually compiling from source. To compile and build from source,&amp;nbsp;&lt;a href=&quot;http://ftp.gnu.org/gnu/make/&quot; style=&quot;background-color: transparent; border: 0px; color: #007ac9; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;download the tarball&lt;/a&gt;, extract it, and go through the README file. (If you’re running Ubuntu, you can install make as well as some other common packages required for building from source, by running:&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;sudo apt-get install build-essential&lt;/code&gt;.)&lt;/div&gt;
&lt;h2 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 26px; font-weight: normal; line-height: 30px; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
A sample project&lt;/h2&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
To acquaint ourselves with the basics of make, let’s use a simple C “Hello world” project, and a Makefile that handles building of the target binary. We have three files (below):&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.h&lt;/code&gt;, the header file that contains the declarations;&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.c&lt;/code&gt;, which contains the definition of the function defined in&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.h&lt;/code&gt;; and the main file,&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;main.c&lt;/code&gt;, in which we call the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;sample_func()&lt;/code&gt;&amp;nbsp;defined in&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.c&lt;/code&gt;. Since&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.h&lt;/code&gt;&amp;nbsp;includes the required header files like&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;stdio.h&lt;/code&gt;, we don’t need to include&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;stdio.h&lt;/code&gt;&amp;nbsp;in every module; instead, we just include&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.h&lt;/code&gt;. Here,&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.c&lt;/code&gt;&amp;nbsp;and&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;main.c&lt;/code&gt;&amp;nbsp;can be compiled as separate object modules, and can be linked by GCC to obtain the target binary.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.h:&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate c&quot; id=&quot;highlighter_598228&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;c preprocessor&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: gray !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;#include &lt;stdio.h&gt;&lt;/stdio.h&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;c keyword bold&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;void&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;sample_func();&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.c:&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate c&quot; id=&quot;highlighter_355201&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;c preprocessor&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: gray !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;#include &quot;module.h&quot;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;c keyword bold&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;void&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;sample_func()&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;c plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;c spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c functions bold&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(255, 20, 147) !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;printf&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;c string&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: blue !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&quot;Hello world!&quot;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;c plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;main.c:&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate c&quot; id=&quot;highlighter_169366&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;c preprocessor&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: gray !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;#include &quot;module.h&quot;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;c keyword bold&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;void&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;sample_func();&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;c color1 bold&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: gray !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;main()&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;c plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;c spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;sample_func();&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;c spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;c keyword bold&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: rgb(0, 102, 153) !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-weight: bold !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;return&lt;/code&gt; &lt;code class=&quot;c plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;0;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;c plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The following are the manual steps to compile the project and produce the target binary:&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate text&quot; id=&quot;highlighter_858828&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;slynux@freedom:~$ gcc -I . -c main.c # Obtain main.o&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;slynux@freedom:~$ gcc -I . -c module.c # Obtain module.o&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;slynux@freedom:~$ gcc main.o module.o -o target_bin #Obtain target binary&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
(&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;-I&lt;/code&gt;&amp;nbsp;is used to include the current directory (&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/code&gt;) as a header file location.)&lt;/div&gt;
&lt;h3 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 22px; font-weight: normal; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Writing a Makefile from scratch&lt;/h3&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
By convention, all variable names used in a Makefile are in upper-case. A common variable assignment in a Makefile is&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;CC = gcc&lt;/code&gt;, which can then be used later on as&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;${CC}&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;$(CC)&lt;/code&gt;. Makefiles use&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;#&lt;/code&gt;&amp;nbsp;as the comment-start marker, just like in shell scripts.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The general syntax of a Makefile rule is as follows:&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate text&quot; id=&quot;highlighter_61330&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;target: dependency1 dependency2 ...&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;[TAB] action1&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;[TAB] action2&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;...&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Let’s take a look at a simple Makefile for our sample project:&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate text&quot; id=&quot;highlighter_717278&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;all: main.o module.o&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;gcc main.o module.o -o target_bin&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;main.o: main.c module.h&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;gcc -I . -c main.c&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;module.o: module.c module.h&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;gcc -I . -c module.c&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;clean:&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;rm -rf *.o&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;rm target_bin&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
We have four targets in the Makefile:&lt;/div&gt;
&lt;ul style=&quot;background-color: transparent; border: 0px; list-style: square; margin: 0px 0px 15px 16px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;all&lt;/code&gt;&amp;nbsp;is a special target that depends on&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;main.o&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.o&lt;/code&gt;, and has the command (from the “manual” steps earlier) to make GCC link the two object files into the final executable binary.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;main.o&lt;/code&gt;&amp;nbsp;is a filename target that depends on&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;main.c&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.h&lt;/code&gt;, and has the command to compile&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;main.c&lt;/code&gt;&amp;nbsp;to produce&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;main.o&lt;/code&gt;.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.o&lt;/code&gt;&amp;nbsp;is a filename target that depends on&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.c&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.h&lt;/code&gt;; it calls GCC to compile the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.c&lt;/code&gt;&amp;nbsp;file to produce&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.o&lt;/code&gt;.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;clean&lt;/code&gt;&amp;nbsp;is a special target that has no dependencies, but specifies the commands to clean the compilation outputs from the project directories.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
You may be wondering why the order of the make targets and commands in the Makefile are not the same as that of the manual compilation commands we ran earlier. The reason is so that the easiest invocation, by just calling the make command, will result in the most commonly desired output — the final executable. How does this work?&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The make command accepts a target parameter (one of those defined in the Makefile), so the generic command line syntax is&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;make &lt;target&gt;&lt;/target&gt;&lt;/code&gt;. However, make also works if you do not specify any target on the command line, saving you a little typing; in such a case, it defaults to the first target defined in the Makefile. In our Makefile, that is the target&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;all&lt;/code&gt;, which results in the creation of the desired executable binary&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;target_bin&lt;/code&gt;!&lt;/div&gt;
&lt;h3 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 22px; font-weight: normal; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Makefile processing, in general&lt;/h3&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
When the make command is executed, it looks for a file named&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;makefile&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Makefile&lt;/code&gt;&amp;nbsp;in the current directory. It parses the found&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Makefile&lt;/code&gt;, and constructs a dependency tree. Based on the desired make target specified (or implied) on the command-line, make checks if the dependency files of that target exist. And (for filename targets — explained below) if they exist, whether they are newer than the target itself, by comparing file timestamps.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Before executing the action (commands) corresponding to the desired target, its dependencies must be met; when they are not met, the targets corresponding to the unmet dependencies are executed before the given make target, to supply the missing dependencies.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
When a target is a filename, make compares the timestamps of the target file and its dependency files. If the dependency filename is another target in the Makefile, make then checks the timestamps of that target’s dependencies. It thus winds up recursively checking all the way down the dependency tree, to the source code files, to see if any of the files in the dependency tree are newer than their target filenames. (Of course, if the dependency files don’t exist, then make knows it must start executing the make targets from the “lowest” point in the dependency tree, to create them.)&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
If make finds that files in the dependency tree are newer than their target, then all the targets in the affected branch of the tree are executed, starting from the “lowest”, to update the dependency files. When make finally returns from its recursive checking of the tree, it completes the final comparison for the desired make target. If the dependency files are newer than the target (which is usually the case), it runs the command(s) for the desired make target.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
This process is how make saves time, by executing only commands that need to be executed, based on which of the source files (listed as dependencies) have been updated, and have a newer timestamp than their target.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Now, when a target is not a filename (like all and clean in our Makefile, which we called “special targets”), make obviously cannot compare timestamps to check whether the target’s dependencies are newer. Therefore, such a target is always executed, if specified (or implied) on the command line.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
For the execution of each target, make prints the actions while executing them. Note that each of the actions (shell commands written on a line) are executed in a separate sub-shell. If an action changes the shell environment, such a change is restricted to the sub-shell for that action line only. For example, if one action line contains a command like&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;cd newdir&lt;/code&gt;, the current directory will be changed only for that line/action; for the next line/action, the current directory will be unchanged.&lt;/div&gt;
&lt;h3 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 22px; font-weight: normal; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Processing our Makefile&lt;/h3&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
After understanding how make processes Makefiles, let’s run make on our own Makefile, and see how it is processed to illustrate how it works. In the project directory, we run the following command:&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate text&quot; id=&quot;highlighter_283794&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;slynux@freedom:~$ make&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;gcc -I . -c main.c&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;gcc -I . -c module.c&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;gcc main.o module.o -o target_bin&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
What has happened here?&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
When we ran make without specifying a target on the command line, it defaulted to the first target in our Makefile — that is, the target&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;all&lt;/code&gt;. This target’s dependencies are&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.o&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;main.o&lt;/code&gt;. Since these files do not exist on our first run of make for this project, make notes that it must execute the targets&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;main.o&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.o&lt;/code&gt;. These targets, in turn, produce the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;main.o&lt;/code&gt;&amp;nbsp;and&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.o&lt;/code&gt;&amp;nbsp;files by executing the corresponding actions/commands. Finally, make executes the command for the target&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;all&lt;/code&gt;. Thus, we obtain our desired output,&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;target_bin&lt;/code&gt;.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
If we immediately run make again, without changing any of the source files, we will see that only the command for the target&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;all&lt;/code&gt;&amp;nbsp;is executed:&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate text&quot; id=&quot;highlighter_609824&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;slynux@freedom:~$ make&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;gcc main.o module.o -o target_bin&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Though make checked the dependency tree, neither of the dependency targets (&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.o&lt;/code&gt;&amp;nbsp;and&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;main.o&lt;/code&gt;) had their own dependency files bearing a later timestamp than the dependency target filename. Therefore, make rightly did not execute the commands for the dependency targets. As we mentioned earlier, since the target&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;all&lt;/code&gt;&amp;nbsp;is not a filename, make cannot compare file timestamps, and thus executes the action/command for this target.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Now, we update&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.c&lt;/code&gt;&amp;nbsp;by adding a statement&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;printf(&quot;\nfirst update&quot;);&lt;/code&gt;&amp;nbsp;inside the&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;sample_func()&lt;/code&gt;&amp;nbsp;function. We then run make again:&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate text&quot; id=&quot;highlighter_565316&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;slynux@freedom:~$ make&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;gcc -I . -c module.c&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;gcc main.o module.o -o target_bin&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Since&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.c&lt;/code&gt;&amp;nbsp;in the dependency tree has changed (it now has a later timestamp than its target,&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.o&lt;/code&gt;), make runs the action for the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;module.o&lt;/code&gt;&amp;nbsp;target, which recompiles the changed source file. It then runs the action for the all target.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
We can explicitly invoke the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;clean&lt;/code&gt;&amp;nbsp;target to clean up all the generated&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.o&lt;/code&gt;&amp;nbsp;files and&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;target_bin&lt;/code&gt;:&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate text&quot; id=&quot;highlighter_560249&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;$ make clean&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;rm -rf *.o&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;rm target_bin&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 26px; font-weight: normal; line-height: 30px; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
More bytes on Makefiles&lt;/h2&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Make provides many interesting features that we can use in Makefiles. Let’s look at the most essential ones.&lt;/div&gt;
&lt;h3 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 22px; font-weight: normal; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Dealing with assignments&lt;/h3&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
There are different ways of assigning variables in a Makefile. They are (type of assignment, followed by the operator in parentheses):&lt;/div&gt;
&lt;h4 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 18px; font-weight: normal; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Simple assignment (:=)&lt;/h4&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
We can assign values (RHS) to variables (LHS) with this operator, for example:&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;CC := gcc&lt;/code&gt;. With simple assignment (&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;:=&lt;/code&gt;), the value is expanded and stored to all occurrences in the Makefile when its first definition is found.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
For example, when a&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;CC := ${GCC} ${FLAGS}&lt;/code&gt;&amp;nbsp;simple definition is first encountered,&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;CC&lt;/code&gt;&amp;nbsp;is set to&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;gcc -W&lt;/code&gt;&amp;nbsp;and wherever&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;${CC}&lt;/code&gt;&amp;nbsp;occurs in actions, it is replaced with&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;gcc -W&lt;/code&gt;.&lt;/div&gt;
&lt;h4 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 18px; font-weight: normal; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Recursive assignment (=)&lt;/h4&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Recursive assignment (the operator used is&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/code&gt;) involves variables and values that are not evaluated immediately on encountering their definition, but are re-evaluated every time they are encountered in an action that is being executed. As an example, say we have:&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate text&quot; id=&quot;highlighter_675381&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;GCC = gcc&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;FLAGS = -W&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
With the above lines,&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;CC = ${GCC} {FLAGS}&lt;/code&gt;&amp;nbsp;will be converted to&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;gcc -W&lt;/code&gt;&amp;nbsp;only when an action like&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;${CC} file.c&lt;/code&gt;&amp;nbsp;is executed somewhere in the Makefile. With recursive assignation, if the GCC variable is changed later (for example,&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;GCC = c++&lt;/code&gt;), then when it is next encountered in an action line that is being updated, it will be re-evaluated, and the new value will be used;&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;${CC}&lt;/code&gt;will now expand to&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;c++ -W&lt;/code&gt;.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
We will also have an interesting and useful application further in the article, where this feature is used to deal with varying cases of filename extensions of image files.&lt;/div&gt;
&lt;h4 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 18px; font-weight: normal; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Conditional assignment (?=)&lt;/h4&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Conditional assignment statements assign the given value to the variable only if the variable does not yet have a value.&lt;/div&gt;
&lt;h4 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 18px; font-weight: normal; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Appending (+=)&lt;/h4&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The appending operation appends texts to an existing variable. For example:&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate text&quot; id=&quot;highlighter_260523&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;CC = gcc&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;CC += -W&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;CC&lt;/code&gt;&amp;nbsp;now holds the value&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;gcc -W&lt;/code&gt;.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Though variable assignments can occur in any part of the Makefile, on a new line, most variable declarations are found at the beginning of the Makefile.&lt;/div&gt;
&lt;h3 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 22px; font-weight: normal; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Using patterns and special variables&lt;/h3&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;%&lt;/code&gt;&amp;nbsp;character can be used for wildcard pattern-matching, to provide generic targets. For example:&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate text&quot; id=&quot;highlighter_19167&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;%.o: %.c&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;[TAB] actions&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
When&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;%&lt;/code&gt;&amp;nbsp;appears in the dependency list, it is replaced with the same string that was used to perform substitution in the target.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Inside actions, we can use special variables for matching filenames. Some of them are:&lt;/div&gt;
&lt;ul style=&quot;background-color: transparent; border: 0px; list-style: square; margin: 0px 0px 15px 16px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;$@&lt;/code&gt;&amp;nbsp;(full target name of the current target)&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;$?&lt;/code&gt;&amp;nbsp;(returns the dependencies that are newer than the current target)&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;$*&lt;/code&gt;&amp;nbsp;(returns the text that corresponds to&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;%&lt;/code&gt;&amp;nbsp;in the target)&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;$&amp;lt;&lt;/code&gt;&amp;nbsp;(name of the first dependency)&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;$^&lt;/code&gt;&amp;nbsp;(name of all the dependencies with space as the delimiter)&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Instead of writing each of the file names in the actions and the target, we can use shorthand notations based on the above, to write more generic Makefiles.&lt;/div&gt;
&lt;h3 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 22px; font-weight: normal; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Action modifiers&lt;/h3&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
We can change the behaviour of the actions we use by prefixing certain action modifiers to the actions. Two important action modifiers are:&lt;/div&gt;
&lt;ul style=&quot;background-color: transparent; border: 0px; list-style: square; margin: 0px 0px 15px 16px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;-&lt;/code&gt;&amp;nbsp;(minus) — Prefixing this to any action causes any error that occurs while executing the action to be ignored. By default, execution of a Makefile stops when any command returns a non-zero (error) value. If an error occurs, a message is printed, with the status code of the command, and noting that the error has been ignored. Looking at the Makefile from our sample project: in the clean target, the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;rm target_bin&lt;/code&gt;&amp;nbsp;command will produce an error if that file does not exist (this could happen if the project had never been compiled, or if&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;make clean&lt;/code&gt;is run twice consecutively). To handle this, we can prefix the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;rm&lt;/code&gt;&amp;nbsp;command with a minus, to ignore errors:&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;-rm target_bin&lt;/code&gt;.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;@&lt;/code&gt;&amp;nbsp;(at) suppresses the standard print-action-to-standard-output behaviour of make, for the action/command that is prefixed with&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;@&lt;/code&gt;. For example, to echo a custom message to standard output, we want only the output of the echo command, and don’t want to print the echo command line itself.&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;@echo Message&lt;/code&gt;&amp;nbsp;will print “Message” without the echo command line being printed.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 22px; font-weight: normal; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Use PHONY to avoid file-target name conflicts&lt;/h3&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Remember the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;all&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;clean&lt;/code&gt;&amp;nbsp;special targets in our Makefile? What happens when the project directory has files with the names&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;all&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;clean&lt;/code&gt;? The conflicts will cause errors. Use the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.PHONY&lt;/code&gt;directive to specify which targets are not to be treated as files — for example:&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.PHONY: all clean&lt;/code&gt;.&lt;/div&gt;
&lt;h3 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 22px; font-weight: normal; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Simulating make without actual execution&lt;/h3&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
At times, maybe when developing the Makefile, we may want to trace the make execution (and view the logged messages) without actually running the actions, which is time consuming. Simply use&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;make -n&lt;/code&gt;&amp;nbsp;to do a “dry run”.&lt;/div&gt;
&lt;h3 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 22px; font-weight: normal; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Using the shell command output in a variable&lt;/h3&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Sometimes we need to use the output from one command/action in other places in the Makefile — for example, checking versions/locations of installed libraries, or other files required for compilation.&amp;nbsp;We can obtain the shell output using the shell command. For example, to return a list of files in the current directory into a variable, we would run:&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;LS_OUT = $(shell ls)&lt;/code&gt;.&lt;/div&gt;
&lt;h3 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 22px; font-weight: normal; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Nested Makefiles&lt;/h3&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Nested Makefiles (which are Makefiles in one or more subdirectories that are also executed by running the make command in the parent directory) can be useful for building smaller projects as part of a larger project. To do this, we set up a target whose action changes directory to the subdirectory, and invokes make again:&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate text&quot; id=&quot;highlighter_299554&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;subtargets:&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;cd subdirectory &amp;amp;&amp;amp; $(MAKE)&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Instead of running the make command, we used&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;$(MAKE)&lt;/code&gt;, an environment variable, to provide flexibility to include arguments. For example, if you were doing a “dry run” invocation: if we used the make command directly for the subdirectory, the simulation option (&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;-n&lt;/code&gt;) would not be passed, and the commands in the subdirectory’s Makefile would actually be executed. To enable use of the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;-n&lt;/code&gt;&amp;nbsp;argument, use the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;$(MAKE)&lt;/code&gt;&amp;nbsp;variable.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Now let’s improve our original Makefile using these advanced features:&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate text&quot; id=&quot;highlighter_719041&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 610px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 610px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;CC = gcc # Compiler to use&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;OPTIONS = -O2 -g -Wall # -g for debug, -O2 for optimise and -Wall additional messages&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;INCLUDES = -I . # Directory for header file&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;OBJS = main.o module.o # List of objects to be build&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;.PHONY: all clean # To declare all, clean are not files&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;all: ${OBJS}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;@echo &quot;Building..&quot; # To print &quot;Building..&quot; message&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;${CC} ${OPTIONS} ${INCLUDES} ${OBJS} -o target_bin &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;%.o: %.c&amp;nbsp; # % pattern wildcard matching&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;${CC} ${OPTIONS} -c $*.c ${INCLUDES}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;list:&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number14 index13 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;@echo $(shell ls) # To print output of command &#39;ls&#39;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number15 index14 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number16 index15 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;clean:&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number17 index16 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;@echo &quot;Cleaning up..&quot;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number18 index17 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;-rm -rf *.o # - prefix for ignoring errors and continue execution&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number19 index18 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;-rm target_bin&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Run make on the modified Makefile and test it; also run make with the new list target. Observe the output.&lt;/div&gt;
&lt;h2 style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; font-size: 26px; font-weight: normal; line-height: 30px; margin: 0px 0px 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Make in non-compilation contexts&lt;/h2&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
I hope you’re now well informed about using make in a programming context. However, it’s also useful in non-programming contexts, due to the basic behaviour of checking the modification timestamps of target files and dependencies, and running the specified actions when required. For example, let’s write a Makefile that will manage an image store for us, doing thumbnailing when required. Our scenario is as follows:&lt;/div&gt;
&lt;ul style=&quot;background-color: transparent; border: 0px; list-style: square; margin: 0px 0px 15px 16px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;We have a directory with two subdirectories,&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;images&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;thumb&lt;/code&gt;.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;The&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;images&lt;/code&gt;&amp;nbsp;subdirectory contains many large image files;&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;thumb&lt;/code&gt;&amp;nbsp;contains thumbnails of the images, as&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.jpg&lt;/code&gt;&amp;nbsp;files, 100x100px in image size.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;When a new image is added to the images directory, creation of its thumbnail in the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;thumb&lt;/code&gt;directory should be automated. If an image is modified, its thumbnail should be updated.&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; border: 0px; margin: 3px 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;The thumbnailing process should only be done for new or updated images, and not images that have up-to-date thumbnails.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
This problem can be solved easily by creating a Makefile in the top-level directory, as follows:&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate text&quot; id=&quot;highlighter_251404&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;FILES = $(shell&amp;nbsp; find images -type f -iname &quot;*.jpg&quot; | sed &#39;s/images/thumb/g&#39;)&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;CONVERT_CMD = convert -resize &quot;100x100&quot; $&amp;lt; $@&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;MSG = @echo &quot;\nUpdating thumbnail&quot; $@&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;all: ${FILES}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;thumb/%.jpg: images/%.jpg&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;$(MSG)&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;$(CONVERT_CMD)&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;thumb/%.JPG: images/%.JPG&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;$(MSG)&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;$(CONVERT_CMD)&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;clean:&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;@echo Cleaning up files..&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number14 index13 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text spaces&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; color: #054e76; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;rm -rf thumb/*.jpg thumb/*.JPG&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
In the above Makefile,&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;FILES = $(shell&amp;nbsp; find images -type f -iname &quot;*.jpg&quot; | sed &#39;s/images/thumb/g&#39;)&lt;/code&gt;&amp;nbsp;is used to generate a list of dependency filenames. JPEG files could have the extension&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.jpg&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.JPG&lt;/code&gt;&amp;nbsp;(that is, differing in case). The&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;-iname&lt;/code&gt;&amp;nbsp;parameter to find (&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;find images -type f -iname &quot;*.jpg&quot;&lt;/code&gt;) will do a case-insensitive search on the names of files, and will return files with both lower-case and upper-case extensions — for example,&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;images/1.jpg&lt;/code&gt;,&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;images/2.jpg&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;images/3.JPG&lt;/code&gt;&amp;nbsp;and so on.&amp;nbsp;The&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;sed&lt;/code&gt;&amp;nbsp;command replaces the text “images” with “thumb”, to get the dependency file path.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
When make is invoked, the all target is executed first. Since FILES contains a list of thumbnail files for which to check the timestamp (or if they exist), make jumps down to the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;thumb/%.jpg&lt;/code&gt;wildcard target for each thumbnail image file name. (If the extension is upper-case, that is,&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;thumb/3.JPG&lt;/code&gt;, then make will look for, and find, the second wildcard target,&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;thumb/%.JPG&lt;/code&gt;.)&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
For each thumbnail file in the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;thumb&lt;/code&gt;&amp;nbsp;directory, its dependency is the image file in the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;images&lt;/code&gt;directory. Hence, if any file (that’s expected to be) in the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;thumb&lt;/code&gt;&amp;nbsp;directory does not exist, or its timestamp is older than the dependency file in the&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;images&lt;/code&gt;&amp;nbsp;directory, the action (calling&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;$(CONVERT_CMD&lt;/code&gt;) to create a thumbnail) is run.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Using the features we described earlier,&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;CONVERT_CMD&lt;/code&gt;&amp;nbsp;is defined before targets are specified, but it uses recursive assignment. Hence, the input and target filenames passed to the convert command are substituted from the first dependency (&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;$&amp;lt;&lt;/code&gt;) and the target (&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;$@&lt;/code&gt;) every time the action is invoked, and thus will work no matter from which action target (&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;thumb/%.JPG&lt;/code&gt;&amp;nbsp;or&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;thumb/%.jpg&lt;/code&gt;) the action is invoked.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Naturally, the “Updating thumbnail” message is also defined using recursive assignment for the same reasons, ensuring that&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;$(MSG)&lt;/code&gt;&amp;nbsp;is re-evaluated every time the actions are executed, and thereby able to cope with variations in the case of the filename extension.&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate text&quot; id=&quot;highlighter_294668&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;slynux@freedom:~$ make&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;Updating thumbnail 1.jpg&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;convert -resize &quot;100x100&quot; images/1.jpg thumb/1.jpg&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt; Updating thumbnail 4.jpg&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;convert -resize &quot;100x100&quot; images/4.jpg thumb/4.jpg&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
If I edit&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;4.jpg&lt;/code&gt;&amp;nbsp;in images and rerun make, since only&amp;nbsp;&lt;code style=&quot;background-color: #edf7ff; background-position: initial initial; background-repeat: initial initial; border: 0px; color: #054e76; font-size: 13px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;4.jpg&lt;/code&gt;‘s timestamp has changed, a thumbnail is generated for that image:&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;div class=&quot;syntaxhighlighter nogutter notranslate text&quot; id=&quot;highlighter_490502&quot; style=&quot;background-color: white !important; background-position: initial initial; background-repeat: initial initial; border: 1px solid rgb(239, 239, 239); font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-size: 12px !important; margin: 1em 0px !important; outline: 0px; overflow-x: auto !important; overflow-y: hidden !important; padding: 1px !important; position: relative !important; vertical-align: baseline; width: 603px;&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-collapse: collapse; border-spacing: 0px; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-size: 12px !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; text-align: left !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;tbody style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;tr style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;&lt;td class=&quot;code&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: 603px;&quot;&gt;&lt;div class=&quot;container&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: relative !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;slynux@freedom:~$ make&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;Updating thumbnail 4.jpg&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot; style=&quot;background-color: white !important; background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em 0px 3px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; white-space: pre !important; width: auto !important;&quot;&gt;
&lt;code class=&quot;text plain&quot; style=&quot;background-image: none !important; border-bottom-left-radius: 0px !important; border-bottom-right-radius: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border: 0px !important; bottom: auto !important; box-sizing: content-box !important; float: none !important; font-family: Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; min-height: inherit !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important;&quot;&gt;convert -resize &quot;100x100&quot; images/4.jpg thumb/4.jpg&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
Writing a script (shell script or Python, etc) to maintain image thumbnails by monitoring timestamps would have taken many lines of code. With make, we can do this in just 8 lines of Makefile. Isn’t make awesome?&lt;/div&gt;
&lt;div style=&quot;background-color: transparent; border: 0px; margin-bottom: 15px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
That’s all about the basics of using the make utility. Happy hacking till we meet again!&lt;/div&gt;
&lt;div class=&quot;note&quot; style=&quot;background-attachment: scroll; background-color: #edf7ff; background-image: none; background-position: 0px 0px; background-repeat: repeat repeat; border: 0px; margin-bottom: 15px; outline: 0px; padding: 3px 10px; vertical-align: baseline;&quot;&gt;
&lt;em style=&quot;background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;This article was originally published in September 2010 issue of the print magazine.&lt;/em&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/7868313755335398295/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2012/06/gnu-make-in-detail-for-beginners-by.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/7868313755335398295'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/7868313755335398295'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2012/06/gnu-make-in-detail-for-beginners-by.html' title=''/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-7029425010931893799</id><published>2012-05-23T09:01:00.001-07:00</published><updated>2012-05-23T09:01:49.511-07:00</updated><title type='text'>setup of IP camera</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;a href=&quot;http://www.youtube.com/watch?v=ZU_xobdKQOs&quot;&gt;http://www.youtube.com/watch?v=ZU_xobdKQOs&lt;/a&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/7029425010931893799/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2012/05/setup-of-ip-camera.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/7029425010931893799'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/7029425010931893799'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2012/05/setup-of-ip-camera.html' title='setup of IP camera'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-3557874837578319489</id><published>2012-05-10T22:35:00.001-07:00</published><updated>2012-05-10T22:35:50.043-07:00</updated><title type='text'>Vim plugin</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;headline_area&quot; style=&quot;background-color: white; color: #111111; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 10px; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;&quot;&gt;
&lt;h1 class=&quot;entry-title&quot; style=&quot;color: #a90000; font-size: 2.2em; font-weight: normal; letter-spacing: -1px; line-height: 1.364em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;a href=&quot;http://www.thegeekstuff.com/2009/04/ctags-taglist-vi-vim-editor-as-sourece-code-browser/&quot;&gt;http://www.thegeekstuff.com/2009/04/ctags-taglist-vi-vim-editor-as-sourece-code-browser/&lt;/a&gt;
&lt;/h1&gt;
&lt;h1 class=&quot;entry-title&quot; style=&quot;color: #a90000; font-size: 2.2em; font-weight: normal; letter-spacing: -1px; line-height: 1.364em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;br /&gt;&lt;/h1&gt;
&lt;h1 class=&quot;entry-title&quot; style=&quot;color: #a90000; font-size: 2.2em; font-weight: normal; letter-spacing: -1px; line-height: 1.364em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Ctags and Taglist: Convert Vim Editor to Beautiful Source Code Browser for Any Programming Language&lt;/h1&gt;
&lt;div class=&quot;headline_meta&quot; style=&quot;color: #888888; font-size: 1em; font-style: italic; line-height: 1.8em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
by&amp;nbsp;&lt;span class=&quot;author vcard fn&quot; style=&quot;font-style: normal; letter-spacing: 1px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-transform: uppercase;&quot;&gt;SATHIYAMOORTHY&lt;/span&gt;&amp;nbsp;on&amp;nbsp;&lt;abbr class=&quot;published&quot; style=&quot;border-bottom-color: initial; border-bottom-style: none; border-bottom-width: initial; cursor: help; font-style: normal; letter-spacing: 1px; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-transform: uppercase;&quot; title=&quot;2009-04-20&quot;&gt;APRIL 20, 2009&lt;/abbr&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;format_text entry-content&quot; style=&quot;background-color: white; color: #111111; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 1.4em; line-height: 1.571em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: -webkit-auto;&quot;&gt;
&lt;div style=&quot;margin-bottom: 6px; margin-left: 0px; margin-right: 0px; margin-top: 7px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px;&quot;&gt;
&lt;div style=&quot;float: left; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;div id=&quot;___plusone_0&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; display: inline-block; float: none; font-size: 1px; height: 20px; line-height: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline; width: 90px;&quot;&gt;
&lt;iframe allowtransparency=&quot;true&quot; frameborder=&quot;0&quot; hspace=&quot;0&quot; id=&quot;I1_1336714237957&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; name=&quot;I1_1336714237957&quot; scrolling=&quot;no&quot; src=&quot;https://plusone.google.com/_/+1/fastbutton?bsv=p&amp;amp;url=http%3A%2F%2Fwww.thegeekstuff.com%2F2009%2F04%2Fctags-taglist-vi-vim-editor-as-sourece-code-browser%2F&amp;amp;size=medium&amp;amp;count=true&amp;amp;hl=en-US&amp;amp;jsh=m%3B%2F_%2Fapps-static%2F_%2Fjs%2Fgapi%2F__features__%2Frt%3Dj%2Fver%3DSzzUGHdbSXA.en.%2Fsv%3D1%2Fam%3D!AuYF0E1N7E-Ine7KrA%2Fd%3D1%2Frs%3DAItRSTNOEhPMf48cb2OLvyu7EguqO-jRdg#id=I1_1336714237957&amp;amp;parent=http%3A%2F%2Fwww.thegeekstuff.com&amp;amp;rpctoken=242446812&amp;amp;_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart&quot; style=&quot;border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; height: 20px; left: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: static; top: 0px; visibility: visible; width: 90px;&quot; tabindex=&quot;0&quot; title=&quot;+1&quot; vspace=&quot;0&quot; width=&quot;100%&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;float: left; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 2px; padding-left: 2px; padding-right: 2px; padding-top: 2px; width: 90px;&quot;&gt;
&lt;iframe allowtransparency=&quot;true&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.thegeekstuff.com%2F2009%2F04%2Fctags-taglist-vi-vim-editor-as-sourece-code-browser%2F&amp;amp;send=false&amp;amp;layout=button_count&amp;amp;width=450&amp;amp;show_faces=false&amp;amp;action=like&amp;amp;colorscheme=light&amp;amp;font&amp;amp;height=21&quot; style=&quot;border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; height: 21px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: hidden; overflow-y: hidden; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 450px;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;iframe allowtransparency=&quot;true&quot; class=&quot;twitter-share-button twitter-count-horizontal&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://platform.twitter.com/widgets/tweet_button.1336551279.html#_=1336714247304&amp;amp;count=horizontal&amp;amp;id=twitter-widget-0&amp;amp;lang=en&amp;amp;original_referer=http%3A%2F%2Fwww.thegeekstuff.com%2F2009%2F04%2Fctags-taglist-vi-vim-editor-as-sourece-code-browser%2F&amp;amp;size=m&amp;amp;text=Ctags%20and%20Taglist%3A%20Convert%20Vim%20Editor%20to%20Beautiful%20Source%20Code%20Browser%20for%20Any%20Programming%20Language&amp;amp;url=http%3A%2F%2Fwww.thegeekstuff.com%2F2009%2F04%2Fctags-taglist-vi-vim-editor-as-sourece-code-browser%2F&quot; style=&quot;height: 20px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; width: 110px;&quot; title=&quot;Twitter Tweet Button&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;optional_excerpt&quot; style=&quot;color: #555555; float: right; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-style: italic; margin-bottom: 0px; margin-left: 20px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; text-align: right;&quot;&gt;
&lt;img alt=&quot;Code C Program using Vim Editor&quot; src=&quot;http://static.thegeekstuff.com/wp-content/uploads/2009/04/c-code-300x199.jpg&quot; style=&quot;display: block; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; title=&quot;C Programming Language&quot; /&gt;&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;small style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Photo Courtesy:&amp;nbsp;&lt;a href=&quot;http://www.flickr.com/photos/t0msk/2638393907/&quot; style=&quot;color: #98c4e0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;mint imperial&lt;/a&gt;&lt;/small&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
This article is part of the on-going&amp;nbsp;&lt;a href=&quot;http://www.thegeekstuff.com/tag/vi-vim-tips-and-tricks/&quot; style=&quot;color: #2361a1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Vi / Vim Tips and Tricks&lt;/a&gt;&amp;nbsp;series. As a programmer or system administrator, you will be constantly browsing source codes and shell scripts.&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.929em; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/code&gt;&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;Following are some typical activities that you may perform while browsing a source code file:&lt;/div&gt;
&lt;ol style=&quot;margin-bottom: 1.571em; margin-left: 1.571em; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Navigating to the function definition by specifying the function name.&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Navigating to the function definition from ‘function call’.&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Returning back again to function call from the definition.&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Viewing the prototype/signature of functions or variables.&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Viewing the number of functions in a file, etc.,&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;span id=&quot;more-451&quot; style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/span&gt;&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;In this article, let us review how to perform the above activities efficiently in&amp;nbsp;&lt;strong style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Vim editor&lt;/strong&gt;&amp;nbsp;using&lt;a href=&quot;http://ctags.sourceforge.net/&quot; style=&quot;color: #2361a1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;ctags&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=273&quot; style=&quot;color: #2361a1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;taglist plugin&lt;/a&gt;.&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.929em; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/code&gt;&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;The techniques mentioned in this article using Vim editor can be used for any programming language.&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.929em; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/code&gt;&lt;/div&gt;
&lt;h2 style=&quot;color: #a90000; font-size: 1.286em; letter-spacing: -1px; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
I. Ctags Package Install and Configure&lt;/h2&gt;
&lt;h3 style=&quot;font-size: 1.286em; font-weight: normal; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Step 1: Installing ctags Package&lt;/h3&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(221, 221, 221); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.857em; line-height: 1.5em; margin-bottom: 1.833em; overflow-x: auto; overflow-y: auto; padding-bottom: 0.667em; padding-left: 0.917em; padding-right: 0.917em; padding-top: 0.667em;&quot;&gt;# apt-get install exuberant-ctags

(or)

# rpm -ivh ctags-5.5.4-1.i386.rpm
warning: ctags-5.5.4-1.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
Preparing...          ########################################### [100%]
   1:ctags            ########################################### [100%]&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.929em; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/code&gt;&lt;/div&gt;
&lt;h3 style=&quot;font-size: 1.286em; font-weight: normal; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Step 2: Generating ctags on your source code&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Go to the directory where your source code is located. In the example below, I have stored all my C programming source code under ~/src directory.&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(221, 221, 221); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.857em; line-height: 1.5em; margin-bottom: 1.833em; overflow-x: auto; overflow-y: auto; padding-bottom: 0.667em; padding-left: 0.917em; padding-right: 0.917em; padding-top: 0.667em;&quot;&gt;# cd ~/src

# &lt;strong style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;ctags *.c&lt;/strong&gt;&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.929em; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
The ctags command will create a filename tags the will contain all required information (tags) about the *.c program files. Following is partial output of the tags entries in the ctags file.&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(221, 221, 221); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.857em; line-height: 1.5em; margin-bottom: 1.833em; overflow-x: auto; overflow-y: auto; padding-bottom: 0.667em; padding-left: 0.917em; padding-right: 0.917em; padding-top: 0.667em;&quot;&gt;# &lt;strong style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;cat tags&lt;/strong&gt;
AddAcl  dumputils.c     /^AddAcl(PQExpBuffer aclbuf, const char *keyword)$/;&quot;   f       file:
ArchiveEntry    pg_backup_archiver.c    /^ArchiveEntry(Archive *AHX,$/;&quot;        f
AssignDumpId    common.c        /^AssignDumpId(DumpableObject *dobj)$/;&quot;        f&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.929em; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/code&gt;&lt;/div&gt;
&lt;center style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 10px; margin-left: 2px; margin-right: 0px; margin-top: 10px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;ins style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; display: inline-table; height: 280px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; visibility: visible; width: 336px;&quot;&gt;&lt;ins id=&quot;aswift_2_anchor&quot; style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; display: block; height: 280px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: relative; visibility: visible; width: 336px;&quot;&gt;&lt;iframe allowtransparency=&quot;true&quot; frameborder=&quot;0&quot; height=&quot;280&quot; hspace=&quot;0&quot; id=&quot;aswift_2&quot; marginheight=&quot;0&quot; marginwidth=&quot;0&quot; name=&quot;aswift_2&quot; scrolling=&quot;no&quot; style=&quot;left: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; position: absolute; top: 0px;&quot; vspace=&quot;0&quot; width=&quot;336&quot;&gt;&lt;/iframe&gt;&lt;/ins&gt;&lt;/ins&gt;&lt;/div&gt;
&lt;/center&gt;&lt;h2 style=&quot;color: #a90000; font-size: 1.286em; letter-spacing: -1px; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
II. 4 Powerful Ctags Usages inside Vim Editor&lt;/h2&gt;
&lt;h3 style=&quot;font-size: 1.286em; font-weight: normal; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
1. Navigate to function definition by specifying the function name using :ta&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
In the example below, :ta main will take you to the main function definition inside the mycprogram.c&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(221, 221, 221); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.857em; line-height: 1.5em; margin-bottom: 1.833em; overflow-x: auto; overflow-y: auto; padding-bottom: 0.667em; padding-left: 0.917em; padding-right: 0.917em; padding-top: 0.667em;&quot;&gt;# vim mycprogram.c
:ta main&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
By using this facility you can navigate to any function definition by specifying the function name.&lt;/div&gt;
&lt;h3 style=&quot;font-size: 1.286em; font-weight: normal; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
2. Navigating to the function definition from ‘function call’ using Ctrl + ]&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
When the cursor is under the function call, then press CTRL + ] to go to the function definition. In the following example, when the cursor is in the function call ssh_xcalloc, pressing Ctrl + ] will take you to the ssh_xcalloc function definition.&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(221, 221, 221); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.857em; line-height: 1.5em; margin-bottom: 1.833em; overflow-x: auto; overflow-y: auto; padding-bottom: 0.667em; padding-left: 0.917em; padding-right: 0.917em; padding-top: 0.667em;&quot;&gt;# vim mycprogram.c
            av = ssh_xcalloc(argc, sizeof(char *));&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.929em; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;strong style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Note:&lt;/strong&gt;&amp;nbsp;If the ctags couldn’t find that function, you’ll get the following message in the vim status bar at the bottom: E426 tag not found ssh_xcalloc&lt;/div&gt;
&lt;h3 style=&quot;font-size: 1.286em; font-weight: normal; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
3. Returning back again to function call from the definition using Ctrl + t&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Press CTRL + t which will take back to the function call again.&lt;/div&gt;
&lt;h3 style=&quot;font-size: 1.286em; font-weight: normal; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
4. Navigating through a list of function names which has the similar names&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
In this example, :ta will go to the function definition whose name starts with get, and also builds a list to navigate with the relevant functions.&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(221, 221, 221); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.857em; line-height: 1.5em; margin-bottom: 1.833em; overflow-x: auto; overflow-y: auto; padding-bottom: 0.667em; padding-left: 0.917em; padding-right: 0.917em; padding-top: 0.667em;&quot;&gt;# vim mycprogram.c

:ta /^get&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Following vim commands can be used to navigate through relevant functions&lt;/div&gt;
&lt;ul style=&quot;list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 1.571em; margin-left: 1.571em; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;strong style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;:ts&lt;/strong&gt;&amp;nbsp;– shows the list.&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;strong style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;:tn&lt;/strong&gt;&amp;nbsp;– goes to the next tag in that list.&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;strong style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;:tp&amp;nbsp;&lt;/strong&gt;- goes to the previous tag in that list.&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;strong style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;:tf&lt;/strong&gt;&amp;nbsp;– goes to the function which is in the first of the list.&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;strong style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;:tl&lt;/strong&gt;&amp;nbsp;– goes to the function which is in the last of the list.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style=&quot;color: #a90000; font-size: 1.286em; letter-spacing: -1px; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
III. Taglist Plugin: Vim Editor as Ultimate Source Code Browser&lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
The above Ctags might have not given a source code browsing feeling, as it is driven by commands instead of visually browsing the code. So if you want to navigate through the source as like navigating in the file browser, you need to use vim taglist plugin which makes vim as a source code browser.&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.929em; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Author of the vim taglist plugin Yegappan Lakshmanan, says about it as&lt;/div&gt;
&lt;blockquote style=&quot;border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 1px; color: #666666; margin-bottom: 1.571em; margin-left: 0.786em; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0.786em; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
The “Tag List” plugin is a source code browser plugin for Vim and provides an overview of the structure of source code files and allows you to efficiently browse through source code files for different programming languages.&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.929em; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/code&gt;&lt;/div&gt;
&lt;h3 style=&quot;font-size: 1.286em; font-weight: normal; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Step 1: Download the Vim Taglist plugin&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Download it from from&amp;nbsp;&lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=273&quot; style=&quot;color: #2361a1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;vim.org&lt;/a&gt;&amp;nbsp;website as shown below.&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(221, 221, 221); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.857em; line-height: 1.5em; margin-bottom: 1.833em; overflow-x: auto; overflow-y: auto; padding-bottom: 0.667em; padding-left: 0.917em; padding-right: 0.917em; padding-top: 0.667em;&quot;&gt;$ cd /usr/src

$ wget -O taglist.zip http://www.vim.org/scripts/download_script.php?src_id=7701&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.929em; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/code&gt;&lt;/div&gt;
&lt;h3 style=&quot;font-size: 1.286em; font-weight: normal; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Step 2: Install the TagList Vim Plugin&lt;/h3&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(221, 221, 221); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.857em; line-height: 1.5em; margin-bottom: 1.833em; overflow-x: auto; overflow-y: auto; padding-bottom: 0.667em; padding-left: 0.917em; padding-right: 0.917em; padding-top: 0.667em;&quot;&gt;$ mkdir ~/.vim # if the directory does not exist already

$ cd ~/.vim

$ unzip /usr/src/taglist.zip
Archive:  /usr/src/taglist.zip
  inflating: plugin/taglist.vim
  inflating: doc/taglist.txt&lt;/pre&gt;
&lt;h3 style=&quot;font-size: 1.286em; font-weight: normal; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Step 3: Enable the plugin in the ~/.vimrc&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Add the following line to the ~/.vimrc to enable the plugin for Vim editor.&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(221, 221, 221); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.857em; line-height: 1.5em; margin-bottom: 1.833em; overflow-x: auto; overflow-y: auto; padding-bottom: 0.667em; padding-left: 0.917em; padding-right: 0.917em; padding-top: 0.667em;&quot;&gt;$ vim ~/.vimrc
filetype plugin on&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.929em; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;strong style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Pre-Requisite:&lt;/strong&gt;&amp;nbsp;ctags should be installed to use taglist plugin. But it is not a must to generate the tag list manually by ctags command for using taglist plugin.&lt;/div&gt;
&lt;h2 style=&quot;color: #a90000; font-size: 1.286em; letter-spacing: -1px; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
IV. 5 Powerful Features of Taglist Vim Plugin&lt;/h2&gt;
&lt;h3 style=&quot;font-size: 1.286em; font-weight: normal; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
1. Open the Tag List Window in Vim using :TlistOpen&lt;/h3&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(221, 221, 221); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 1px; clear: both; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.857em; line-height: 1.5em; margin-bottom: 1.833em; overflow-x: auto; overflow-y: auto; padding-bottom: 0.667em; padding-left: 0.917em; padding-right: 0.917em; padding-top: 0.667em;&quot;&gt;# vim mycprogram.c
:TlistOpen&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.929em; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
From the vim editor, execute :TlistOpen as shown above, which opens the tag list window with the tags of the current file as shown in the figure below.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: center;&quot;&gt;
&lt;a href=&quot;http://static.thegeekstuff.com/wp-content/uploads/2009/04/2-tlistopen.png&quot; style=&quot;color: #2361a1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;img alt=&quot;Function Browser Window inside Vim Editor&quot; class=&quot;size-full wp-image-454 aligncenter&quot; height=&quot;385&quot; src=&quot;http://static.thegeekstuff.com/wp-content/uploads/2009/04/2-tlistopen.png&quot; style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; clear: both; display: block; float: none; margin-bottom: 1.571em; margin-left: auto; margin-right: auto; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; width=&quot;500&quot; /&gt;&lt;/a&gt;&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;strong style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Fig:&lt;/strong&gt;&amp;nbsp;Vim – Source Code Tag/Function List Windows&lt;/div&gt;
&lt;h3 style=&quot;font-size: 1.286em; font-weight: normal; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
2. Jump to the Function Definition inside a source code&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
By clicking on the function name in the left panel, you would be able to go to the definition of the function as shown in the Figure below.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: center;&quot;&gt;
&lt;a href=&quot;http://static.thegeekstuff.com/wp-content/uploads/2009/04/31-jump-to-function.png&quot; style=&quot;color: #2361a1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;img alt=&quot;Jump to a Function inside Vim Editor&quot; class=&quot;size-full wp-image-455 aligncenter&quot; height=&quot;320&quot; src=&quot;http://static.thegeekstuff.com/wp-content/uploads/2009/04/31-jump-to-function.png&quot; style=&quot;border-bottom-style: none; border-color: initial; border-image: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; clear: both; display: block; float: none; margin-bottom: 1.571em; margin-left: auto; margin-right: auto; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; width=&quot;500&quot; /&gt;&lt;/a&gt;&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;strong style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Fig:&lt;/strong&gt;&amp;nbsp;Jump to a function definition quickly&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.929em; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Apart form jumping to the function names quickly, you can jump to classes, structures, variables, etc., by clicking on the corresponding values from the tag-browser in the left hand side.&lt;/div&gt;
&lt;h3 style=&quot;font-size: 1.286em; font-weight: normal; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
3. Jump to the function definition which is in another source file&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
When you are going through a function in a source file and would want to go to the function definition which is in another file, you can do this in two different methods.&lt;/div&gt;
&lt;h4 style=&quot;font-size: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Method 1:&lt;/h4&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
If you had the ctags generated for that file, when the cursor is in the function call pressing CTRL + ] will take you to the function definition. And automatically the tag list window will show the tags for that newly opened file.&lt;/div&gt;
&lt;h4 style=&quot;font-size: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Method 2:&lt;/h4&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Open another file also in the same vim session which will update the tag list window with the information about that file. Search for that function name in the tag list window, and by pressing &lt;cr&gt; on that function name in the tag list window you can go to the function definition.&lt;/cr&gt;&lt;/div&gt;
&lt;h3 style=&quot;font-size: 1.286em; font-weight: normal; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
4. Viewing the prototype/signature of functions or variables.&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Press ‘space’ in the function name or in the variable name in the tag list window to show the prototype (function signature) of it in the VIM status bar as shown below. In the example below, click on selectDumpableTable function from the Tag-window and press space-bar, which displays the function signature for selectDumptableTable function in the bottom Vim Status bar.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: center;&quot;&gt;
&lt;img alt=&quot;Display Function Prototype inside Vim Editor&quot; class=&quot;size-full wp-image-456 aligncenter&quot; height=&quot;267&quot; src=&quot;http://static.thegeekstuff.com/wp-content/uploads/2009/04/41-function-signature.png&quot; style=&quot;clear: both; display: block; float: none; margin-bottom: 1.571em; margin-left: auto; margin-right: auto; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; width=&quot;425&quot; /&gt;&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;strong style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Fig:&lt;/strong&gt;&amp;nbsp;Display Function signature at the Vim Status Bar&lt;/div&gt;
&lt;h3 style=&quot;font-size: 1.286em; font-weight: normal; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
5. Viewing the total number of functions or variables in a source code file&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
press ‘space’ in the tag type in the tag list window, which shows the count of it. In the example below, when the cursor is at ‘function’ press space, which will display the total number of functions in the current source code.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: center;&quot;&gt;
&lt;img alt=&quot;Display Total Number of functions for a source code inside Vim Editor&quot; class=&quot;size-full wp-image-457 aligncenter&quot; height=&quot;290&quot; src=&quot;http://static.thegeekstuff.com/wp-content/uploads/2009/04/51-function-count.png&quot; style=&quot;clear: both; display: block; float: none; margin-bottom: 1.571em; margin-left: auto; margin-right: auto; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; width=&quot;409&quot; /&gt;&lt;br style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;strong style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Fig:&lt;/strong&gt;&amp;nbsp;Display the total number of functions available in the source code&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.929em; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
For effectively writing new source code files using Vim, please refer to our earlier articles:&lt;/div&gt;
&lt;ul style=&quot;list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 1.571em; margin-left: 1.571em; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;a href=&quot;http://www.thegeekstuff.com/2009/01/make-vim-as-your-perl-ide-using-perl-supportvim-plugin/&quot; style=&quot;color: #2361a1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Make Vim as Your Perl IDE Using perl-support.vim Plugin&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;a href=&quot;http://www.thegeekstuff.com/2009/01/tutorial-make-vim-as-your-cc-ide-using-cvim-plugin/&quot; style=&quot;color: #2361a1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Make Vim as Your C/C++ IDE Using c.vim Plugin&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;a href=&quot;http://www.thegeekstuff.com/2009/02/make-vim-as-your-bash-ide-using-bash-support-plugin/&quot; style=&quot;color: #2361a1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Make Vim as Your Bash-IDE Using bash-support Plugin&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; font-family: Consolas, &#39;Andale Mono&#39;, Monaco, Courier, &#39;Courier New&#39;, Verdana, sans-serif; font-size: 0.929em; line-height: 1em; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;/code&gt;&lt;/div&gt;
&lt;h3 style=&quot;font-size: 1.286em; font-weight: normal; line-height: 1.222em; margin-bottom: 0.611em; margin-left: 0px; margin-right: 0px; margin-top: 1.833em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Recommended Reading&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 1.571em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;a href=&quot;http://www.thegeekstuff.com/vim-101-hacks-ebook/&quot; rel=&quot;nofollow&quot; style=&quot;color: #2361a1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;img alt=&quot;&quot; class=&quot;frame alignright size-full wp-image-2394&quot; height=&quot;125&quot; src=&quot;http://static.thegeekstuff.com/wp-content/uploads/2009/10/vim-101-hacks-125x125.png&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #eeeeee; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-bottom-width: 0.071em; border-color: initial; border-image: initial; border-left-color: rgb(221, 221, 221); border-left-style: solid; border-left-width: 0.071em; border-right-color: rgb(221, 221, 221); border-right-style: solid; border-right-width: 0.071em; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-top-width: 0.071em; border-width: initial; float: right; margin-bottom: 1.571em; margin-left: 1.571em; margin-right: 0px; margin-top: 0px; padding-bottom: 0.714em; padding-left: 0.714em; padding-right: 0.714em; padding-top: 0.714em;&quot; title=&quot;Vim 101 Hacks eBook&quot; width=&quot;125&quot; /&gt;&lt;/a&gt;&lt;strong style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;a href=&quot;http://www.thegeekstuff.com/vim-101-hacks-ebook/&quot; rel=&quot;nofollow&quot; style=&quot;color: #2361a1; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Vim 101 Hacks&lt;/a&gt;, by Ramesh Natarajan&lt;/strong&gt;. I’m a command-line junkie. So, naturally I’m a huge fan of Vi and Vim editors. Several years back, when I wrote lot of C code on Linux, I used to read all available Vim editor tips and tricks. Based on my Vim editor experience, I’ve written Vim 101 Hacks eBook that contains 101 practical examples on various advanced Vim features that will make you fast and productive in the Vim editor. Even if you’ve been using Vi and Vim Editors for several years and have not read this book, please do yourself a favor and read this book. You’ll be amazed with the capabilities of Vim editor.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/3557874837578319489/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2012/05/vim-plugin.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/3557874837578319489'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/3557874837578319489'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2012/05/vim-plugin.html' title='Vim plugin'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-8386712193036579063</id><published>2012-05-10T02:43:00.005-07:00</published><updated>2012-05-10T02:44:21.020-07:00</updated><title type='text'>screen man page</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
screen

Multiplex a physical terminal between several processes (typically interactive shells).

Syntax:
 
   Start a screen session:

      screen [ -options ] [ cmd [args] ]

   Resume a detached screen session:

      screen -r [[pid.]tty[.host]]

      screen -r sessionowner/[[pid.]tty[.host]]

Options:

   -A -[r|R]     Adapt all windows to the new display width &amp; height.
   -c file       Read configuration file instead of .screenrc
   -d (-r)       Detach the elsewhere running screen (and reattach here).
   -dmS name     Start as daemon: Screen session in detached mode.
   -D (-r)       Detach and logout remote (and reattach here).
   -D -RR        Do whatever is needed to Reattach a screen session.
   -d -m         Start in &quot;detached&quot; mode. Useful for system startup scripts.
   -D -m         Start in &quot;detached&quot; mode, &amp; don&#39;t fork a new process.
   -list         List our SockDir and do nothing else (-ls) 
   -r            Reattach to a detached screen process.
   -R            Reattach if possible, otherwise start a new session.
   -t title      Set title. (window&#39;s name).
   -U            Tell screen to use UTF-8 encoding.
   -x            Attach to a not detached screen. (Multi display mode).
   -X            Execute cmd as a screen command in the specified session.
   
Interactive commands (default key bindings):

     Control-a ?    Display brief help
     Control-a &quot;    List all windows for selection
     Control-a &#39;    Prompt for a window name or number to switch to.
     Control-a 0    Select window 0
     Control-a 1    Select window 1
     ...            ...
     Control-a 9    Select window 9
     Control-a A    Accept a title name for the current window.
     Control-a b    Send a break to window
     Control-a c    Create new window running a shell
     Control-a C    Clear the screen
     Control-a d    Detach screen from this terminal.
     Control-a D D  Detach and logout.
     Control-a f    Toggle flow on, off or auto.
     Control-a F    Resize the window to the current region size.
     Control-a h    Write a hardcopy of the current window to file &quot;hardcopy.n&quot;
     Control-a H    Begin/end logging of the current window to file &quot;screenlog.n&quot;
     Control-a i    Show info about this window.
     Control-a k    Kill (Destroy) the current window.
     Control-a l    Fully refresh current window
     Control-a M    Monitor the current window for activity {toggle on/off}
     Control-a n    Switch to the Next window
     Control-a N    Show the Number and Title of window
     Control-a p    Switch to the Previous window
     Control-a q    Send a control-q to the current window(xon)
     Control-a Q    Delete all regions but the current one.(only)
     Control-a r    Toggle the current window&#39;s line-wrap setting(wrap)
     Control-a s    Send a control-s to the current window(xoff)
     Control-a w    Show a list of windows (windows)
     Control-a x    Lock this terminal (lockscreen)
     Control-a X    Kill the current region(remove)
     Control-a Z    Reset the virtual terminal to its &quot;power-on&quot; values
     Control-a Control-\    Kill all windows and terminate screen(quit)
     Control-a :    Enter command line mode(colon)
     Control-a [    Enter copy/scrollback mode(copy)
     Control-a ]    Write the contents of the paste buffer to stdin(paste)
     Control-a _    Monitor the current window for inactivity {toggle on/off}
     Control-a *    Show  a listing of all currently attached displays.
When screen is called, it creates a single window with a shell in it (or the specified command) and then gets out of your way so that you can use the program as you normally would.

Then, at any time, you can:

Create new (full-screen) windows with other programs in them (including more shells)

Kill existing windows

View a list of windows

Switch between windows - all windows run their programs completely independent of each other. Programs continue to run when their window is currently not visible and even when the whole screen session is detached from the user&#39;s terminal.

The interactive commands above assume the default key bindings. You can modify screen’s settings by creating a ~/.screenrc file in your home directory. This can change the default keystrokes, bind function keys F11, F12 or even set a load of programs/windows to run as soon as you start screen.

Attaching and Detaching

Once you have screen running, switch to any of the running windows and type Control-a d. this will detach screen from this terminal. Now, go to a different machine, open a shell, ssh to the machine running screen (the one you just detached from), and type: % screen -r

This will reattach to the session. Just like magic, your session is back up and running, just like you never left it.

Exiting screen completely

Screen will exit automatically when all of its windows have been killed.

Close whatever program is running or type `Exit &#39; to exit the shell, and the window that contained it will be killed by screen. (If this window was in the foreground, the display will switch to the previous window)

When none are left, screen exits.

This page is just a summary of the options available, type man screen for more.

&quot;Growing old is mandatory, but growing up is optional&quot; - Motto of the Silver Screen Saddle Pals


========================================


Using screen (virtual terminal multiplexer)

What is screen?
“Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells).” (from man page)

In every-day use you just type

$ screen
and it seems that nothing happens. :) In fact a program is run that manages multiple bash processes and allows doing cool stuff in console(s) without having to run X.

Basics
Ctrl+a is a basic command that allows you to control screen. After you&#39;ve pressed Ctrl+a your input is not being sent to current console, but to the screen itself. That&#39;s where you issue one-letter commands. (and more, but let&#39;s not get you confused)

basic commands

Ctrl+a c - create new console
Ctrl+a n - switch to next console (it loops)
Ctrl+a p - switch to previous console (it loops)
Ctrl+a a - send Ctrl+a combination to the program, I didn&#39;t want to call screen
Ctrl+a k - kill current console (asks to confirm)(ends screen when last console is killed)
Ctrl+a d - detach - exits screen but leaves consoles and theri processes running
For jornada it might be comfortable to bind winkey to do Ctrl+a. I&#39;ll expand the tutorial when I find the best way to do it.

Copy and paste [[awesome]]
You like using links browser in text mode, but you hate having to start X or use wget to copy some text from a page? Screen is the answer!

Ctrl+a [[ - switch to copy mode
 - then use arrows to move cursor
 - press Enter to start selection
 - move cursor to the end
 - press Enter again
Now switch to another console with your awesome script being developed in an editor or just jump to a textfield on a page…

Ctrl+a ]] - pastes the copied text
Useful for transporting data between two separate instances of screen or for using copied text as an input file for programs:

Ctrl+a &gt; - writes copied buffer to a file given in config (/tmp/screen-exchange by default, but don&#39;t go looking through options - it&#39;ll tell you where it writes)
Ctrl+a &lt; - loads the file to buffer
Splitting screen
You can split your screen and display two (or more, but…) consoles at the same time. Screen avaliable in jlime repos supports only horizontal splitting, so I won&#39;t mention the vertical splitting keys.

Ctrl+a S - does the split (S is Shift+s and it has to be capital S)
 - new screen region is created
 - you probably want to press //Ctrl+a c// to start a new console in there
Ctrl+a Tab - switches between visible splits
Ctrl+a :resize (Enter) - prompts for number of lines and resizes current split
Ctrl+a X - removes current split
Monitoring activity
If you work in one console and running something in another you might want to monitor it.

Ctrl+a M - starts monitoring current console for changes (Will inform you when a program outputs something new. Good for IM clients)
Ctrl+a _ - start monitoring current console for silence (Will inform you when a program stops outputting new stuff. Good for compiling or downloading with wget)
Sessions and attaching
Mostly useful when working on a remote machine with screen, but you might want to know this.

When you loose a connection or leave screen with Ctrl+a d your processes stay there. You might want to get to them again I suppose :)

$ screen -ls
There is a screen on:
 21209.pts-0.computername (Detached)
1 Socket in /var/run/screen/S-username.
To get back to the running screen type

$ screen -r 21209
21209 in both examples above is a PID of the screen process.

=====================================

http://snipplr.wordpress.com/2012/04/07/my-screenrc-with-custom-hardstatus-and-easy-switching-between-screens/


screen setup with custom hard status and dialog menu
Posted on April 7, 2012
The following set of scripts produce a nice screen setup along with a dialog menu for the most common tasks.

This is how it looks like



And this is how it’s done. Please see inline comments for details.

01
#!/bin/bash
02
## use shift-left/right to switch between windows
03
## use ctrl-n to add new shellwindow
04
## use shift-PgUp/PgDown for scrolling history hit esc to stop
05
## use ctrl-a-k for killing a window
06
## mark area with space, end marking with space, paste with ctrl-a-]
07
setenv TERM xterm
08
 
09
#kill startup messes
10
startup_message off
11
 
12
# detach on hangup
13
autodetach on
14
 
15
# define a bigger scrollback, default is 100 lines
16
defscrollback 4096
17
 
18
# shell
19
shell -bash
20
 
21
#make scrollbar work
22
termcapinfo xterm ti@:te@
23
 
24
defmonitor on                   # turn monitoring on
25
activity &quot;%&quot;                    # tell me when stuff happens!
26
 
27
# Make shift-PgUp and shift-PgDn work like they do in xterm.  (Note that this
28
# requires xterm to be configured to pass those keys through, and not try to
29
# act on them itself.)
30
bindkey &quot;^[O2A&quot; eval &quot;copy&quot; &quot;stuff ^b&quot;
31
bindkey -m &quot;^[O2A&quot; stuff ^u
32
bindkey -m &quot;^[O2B&quot; stuff ^d
33
 
34
bindkey &quot;^[O2D&quot; prev
35
bindkey &quot;^[O2C&quot; next
36
 
37
# ctrl-N for new window
38
bindkey &quot;^N&quot; screen
39
 
40
# ctrl-a-b to copy selection to osx-clipboard
41
#bind b eval &quot;writebuf&quot; &quot;exec sh -c &#39;pbcopy &lt; /tmp/screen-exchange&#39;&quot;
42
 
43
# Window numbering starts at 1, not 0.
44
bind c screen 1
45
bind 0 select 10
46
 
47
# Run everything in UTF-8.
48
defutf8 on
49
# If a window goes unresponsive, don&#39;t block the whole session waiting for it.
50
nonblock on
51
 
52
# An alternative hardstatus to display a bar at the bottom listing the
53
# windownames and highlighting the current windowname in blue. (This is only
54
# enabled if there is no hardstatus setting for your terminal)
55
# see http://www.debian-administration.org/articles/560
56
hardstatus on
57
hardstatus alwayslastline
58
hardstatus string &quot;%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a &quot;
59
 
60
screen -t selector sh screen-selector.sh
I use this via screen -c selector-screenrc. The helper script for initializing a screen session looks like this and would either connect to an existing one or create a new one.

1
#!/bin/bash
2
 
3
screenpid=`ps x|grep -E &#39;(.*)SCREEN(.*)selector-screenrc\$&#39;|awk &#39;{print \$1}&#39;|head -1`
4
if [ $screenpid -gt 0 ]; then
5
        screen -x $screenpid -c selector-screenrc
6
else
7
        screen -c selector-screenrc
8
fi
The screen-selector.sh file is a bonus and provides a dialog menu for frequently used commands. It looks like this

01
#!/bin/bash
02
 
03
while [ 1 ]; do
04
 
05
select=`/opt/local/bin/dialog --stdout --menu &quot;select task&quot; 20 60 13 \`cat tasks | tr &#39;\040&#39; &#39;_&#39; | tr &#39;\012&#39; &#39;\040&#39;\``
06
 
07
echo &quot;selected $select&quot;
08
 
09
if [ ! -z $select ]; then
10
 
11
    echo $select
12
 
13
    command=`grep $select tasks|awk &#39;BEGIN{FS=OFS=&quot;\t&quot;}{print \$2}&#39;|tr -d &quot;\&quot;&quot;`
14
 
15
    echo &quot;executing command \&quot;$command\&quot;&quot;
16
 
17
    $command
18
#   sleep 2
19
else
20
    exit 0
21
fi
22
 
23
done
The “tasks” file holds a simple list of tasks/commands. See the example below.

1
su      &quot;screen -t rootshell sudo su -&quot;
2
newshell    &quot;screen -t shell&quot;</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/8386712193036579063/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2012/05/screen-man-page.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/8386712193036579063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/8386712193036579063'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2012/05/screen-man-page.html' title='screen man page'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-4300809477050507135</id><published>2012-05-08T01:02:00.003-07:00</published><updated>2012-05-08T01:02:40.755-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="data structure"/><category scheme="http://www.blogger.com/atom/ns#" term="interview"/><title type='text'>Data structure</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
http://www.data-structure-definition.blogspot.in/</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/4300809477050507135/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2012/05/data-structure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/4300809477050507135'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/4300809477050507135'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2012/05/data-structure.html' title='Data structure'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-4808385226928989448</id><published>2012-04-13T01:29:00.000-07:00</published><updated>2012-04-13T01:30:02.136-07:00</updated><title type='text'>cordless phone</title><content type='html'>http://www.vijaypadiyar.in/blog/2011/04/how-to-choose-the-right-cordless-phone</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/4808385226928989448/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2012/04/cordless-phone.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/4808385226928989448'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/4808385226928989448'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2012/04/cordless-phone.html' title='cordless phone'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-2775020782369625307</id><published>2012-04-11T02:06:00.000-07:00</published><updated>2012-04-11T02:07:12.283-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tools"/><title type='text'>screen utility</title><content type='html'>1. http://magazine.redhat.com/2007/09/27/a-guide-to-gnu-screen/</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/2775020782369625307/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2012/04/screen-utility.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/2775020782369625307'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/2775020782369625307'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2012/04/screen-utility.html' title='screen utility'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-525363956679593096</id><published>2012-02-29T01:21:00.001-08:00</published><updated>2012-02-29T01:23:32.099-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="interview"/><title type='text'>netapp</title><content type='html'>1. mbuf and sk buff&lt;br /&gt;2. read or load , which is costely&lt;br /&gt;3. const int a;&lt;br /&gt;   int const a;&lt;br /&gt;   const int const a; &lt;br /&gt;what is difference between above 3&lt;br /&gt;4. spanning tree</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/525363956679593096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2012/02/netapp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/525363956679593096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/525363956679593096'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2012/02/netapp.html' title='netapp'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-9044668968785709333</id><published>2012-02-21T20:42:00.001-08:00</published><updated>2012-02-21T20:42:48.806-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android_Mobile"/><title type='text'>Mobile options</title><content type='html'>1. http://androidadvices.com/tether-galaxy-s2-i9100-wifi-hotspot/</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/9044668968785709333/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2012/02/mobile-options.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/9044668968785709333'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/9044668968785709333'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2012/02/mobile-options.html' title='Mobile options'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2845929896695469094.post-6504386347817496689</id><published>2012-02-05T16:15:00.000-08:00</published><updated>2012-02-05T16:23:08.846-08:00</updated><title type='text'>kernel space and user spcase</title><content type='html'>http://www.ibm.com/developerworks/linux/library/l-kernel-memory-access/ : good must read&lt;br /&gt;&lt;br /&gt;http://people.ee.ethz.ch/~arkeller/linux/kernel_user_space_howto.html#s5 : must read&lt;br /&gt;&lt;br /&gt;http://www.wil.cx/matthew/lca2003/paper.pdf : must read</content><link rel='replies' type='application/atom+xml' href='http://gneerajgupta.blogspot.com/feeds/6504386347817496689/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://gneerajgupta.blogspot.com/2012/02/kernel-space-and-user-spcase.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/6504386347817496689'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2845929896695469094/posts/default/6504386347817496689'/><link rel='alternate' type='text/html' href='http://gneerajgupta.blogspot.com/2012/02/kernel-space-and-user-spcase.html' title='kernel space and user spcase'/><author><name>Neeraj Gupta</name><uri>http://www.blogger.com/profile/02390511141258278874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>