<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>coder . cl &#187; c</title>
	<atom:link href="http://coder.cl/category/programming/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://coder.cl</link>
	<description>system programmer &#38; web developer</description>
	<lastBuildDate>Thu, 29 Jul 2010 21:52:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>[ANN] pyxser-1.4.4r was released</title>
		<link>http://coder.cl/2010/06/ann-pyxser-1-4-4r-was-released/</link>
		<comments>http://coder.cl/2010/06/ann-pyxser-1-4-4r-was-released/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 16:24:50 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[c]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[pyxser]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=688</guid>
		<description><![CDATA[Hello, today I&#8217;ve released pyxser-1.4.4r, the publishing message is as follows: Hello Python Community. I&#8217;m pleased to announce pyxser-1.4.4r, a python extension which contains functions to serialize and deserialize Python Objects into XML. It is a model based serializer. Here is the ChangeLog entry for this release: 1.4.4r (2010.02.10): Daniel Molina Wegener * src/include/pyxser_collections.h - [...]]]></description>
			<content:encoded><![CDATA[<p>Hello, today I&#8217;ve released <strong>pyxser-1.4.4r</strong>, the publishing message is as follows:</p>
<hr/>
<p>Hello Python Community.</p>
<p>I&#8217;m pleased to announce pyxser-1.4.4r, a python extension which contains functions to serialize and deserialize Python Objects into XML. It is a model based serializer. Here is the ChangeLog entry for this release:</p>
<p><span id="more-688"></span></p>
<pre>
1.4.4r (2010.02.10):

        Daniel Molina Wegener <d...@coder.cl>

        * src/include/pyxser_collections.h - added set handling
        function prototypes. Added support for unicode
        key names, which are converted to the user settings
        encoding (ie utf-8) inside the XML output.
        * src/pyxser_serializer.c - removed memory leak. Addded
        support for unicode object names in dictionary/list types.
        * src/pyxser_collections.c - added set handling function
        prototypes. added name property handling algorithm, so
        non string name properties are not serialized. I shall
        extend it to other modules.
        * src/pyxser_tools.c - added set handling prototypes and
        set type checking function.
        * test-utf8-leak.py - added serialization of SQL Alchemy
        objects, so we can test more complex Python objects
        serialization.
        * test-utf8-sqlalchemy.py - added sql alchemy object
        serialization test.
        * src/pyxser_serializer.c - reduced serialization algorithms,
        replacing deep nested if statements by flatten ones.
        * src/pyxser_collections.c - reduced serialization algorithms
        replacing deep nested if statements by flatten ones.
        * src/pyxser_typem.c - reduced serialization algorithms,
        replacing deep nested if statements by flatten ones.

        Thanks to pyxser users for their feedback.
</pre>
<p>This release contains some bug fixes, mainly related to type checking and type handling. I hope this small extension will help you on your programming tasks.</p>
<ul>
<li>The project is hosted at:<br/><a href='http://sourceforge.net/projects/pyxser/'>http://sourceforge.net/projects/pyxser/</a></li>
<li>The web page for the project is located at:<br/><a href='http://coder.cl/products/pyxser/'>http://coder.cl/products/pyxser/</a></li>
<li>PyPi entry is:<br/><a href='http://pypi.python.org/pypi/pyxser/1.4.4r'>http://pypi.python.org/pypi/pyxser/1.4.4r</a></li>
<li>For a sample article on how to integrate pyxser with ZSI WebServices:<br/><a href='http://coder.cl/2009/10/18/pyxser-and-zsi-webservices/'>http://coder.cl/2009/10/18/pyxser-and-zsi-webservices/</a></li>
</ul>
<p>Thanks and best regards&#8230;</p>
<hr/>
<p>I hope that this module can help you in your development tasks and thanks for your feedback.</p>



share this article at: 


	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fcoder.cl%2F2010%2F06%2Fann-pyxser-1-4-4r-was-released%2F&amp;title=%5BANN%5D%20pyxser-1.4.4r%20was%20released&amp;source=coder+.+cl+system+programmer+%26amp%3B+web+developer&amp;summary=Hello%2C%20today%20I%27ve%20released%20pyxser-1.4.4r%2C%20the%20publishing%20message%20is%20as%20follows%3A%0D%0A%0D%0A%0D%0A%0D%0AHello%20Python%20Community.%0D%0A%0D%0AI%27m%20pleased%20to%20announce%20pyxser-1.4.4r%2C%20a%20python%20extension%20which%20contains%20functions%20to%20serialize%20and%20deserialize%20Python%20Objects%20into%20XML." title="LinkedIn"><img src="http://coder.cl/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fcoder.cl%2F2010%2F06%2Fann-pyxser-1-4-4r-was-released%2F&amp;title=%5BANN%5D%20pyxser-1.4.4r%20was%20released&amp;notes=Hello%2C%20today%20I%27ve%20released%20pyxser-1.4.4r%2C%20the%20publishing%20message%20is%20as%20follows%3A%0D%0A%0D%0A%0D%0A%0D%0AHello%20Python%20Community.%0D%0A%0D%0AI%27m%20pleased%20to%20announce%20pyxser-1.4.4r%2C%20a%20python%20extension%20which%20contains%20functions%20to%20serialize%20and%20deserialize%20Python%20Objects%20into%20XML." title="del.icio.us"><img src="http://coder.cl/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fcoder.cl%2F2010%2F06%2Fann-pyxser-1-4-4r-was-released%2F&amp;title=%5BANN%5D%20pyxser-1.4.4r%20was%20released&amp;bodytext=Hello%2C%20today%20I%27ve%20released%20pyxser-1.4.4r%2C%20the%20publishing%20message%20is%20as%20follows%3A%0D%0A%0D%0A%0D%0A%0D%0AHello%20Python%20Community.%0D%0A%0D%0AI%27m%20pleased%20to%20announce%20pyxser-1.4.4r%2C%20a%20python%20extension%20which%20contains%20functions%20to%20serialize%20and%20deserialize%20Python%20Objects%20into%20XML." title="Digg"><img src="http://coder.cl/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fcoder.cl%2F2010%2F06%2Fann-pyxser-1-4-4r-was-released%2F&amp;title=%5BANN%5D%20pyxser-1.4.4r%20was%20released" title="Reddit"><img src="http://coder.cl/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fcoder.cl%2F2010%2F06%2Fann-pyxser-1-4-4r-was-released%2F&amp;t=%5BANN%5D%20pyxser-1.4.4r%20was%20released" title="Facebook"><img src="http://coder.cl/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=%5BANN%5D%20pyxser-1.4.4r%20was%20released%20-%20http%3A%2F%2Fcoder.cl%2F2010%2F06%2Fann-pyxser-1-4-4r-was-released%2F" title="Twitter"><img src="http://coder.cl/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fcoder.cl%2F2010%2F06%2Fann-pyxser-1-4-4r-was-released%2F&amp;title=%5BANN%5D%20pyxser-1.4.4r%20was%20released&amp;annotation=Hello%2C%20today%20I%27ve%20released%20pyxser-1.4.4r%2C%20the%20publishing%20message%20is%20as%20follows%3A%0D%0A%0D%0A%0D%0A%0D%0AHello%20Python%20Community.%0D%0A%0D%0AI%27m%20pleased%20to%20announce%20pyxser-1.4.4r%2C%20a%20python%20extension%20which%20contains%20functions%20to%20serialize%20and%20deserialize%20Python%20Objects%20into%20XML." title="Google Bookmarks"><img src="http://coder.cl/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/><br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2010 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2010. | <a href="http://coder.cl/2010/06/ann-pyxser-1-4-4r-was-released/">Permalink</a> | <a href="http://coder.cl/2010/06/ann-pyxser-1-4-4r-was-released/#comments">No comment</a><br/>Post tags: <br/></small></p>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2010/06/ann-pyxser-1-4-4r-was-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>my contribution to free/open source software</title>
		<link>http://coder.cl/2010/04/my-contribution-to-freeopen-source-software/</link>
		<comments>http://coder.cl/2010/04/my-contribution-to-freeopen-source-software/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 22:34:34 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[c]]></category>
		<category><![CDATA[caffeine]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[pyxser]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=643</guid>
		<description><![CDATA[I&#8217;ve worked on FOSS for years. Currently I have two active projects pyxser and caffeine. Both of them requires a great effort to being completed. Take an overview on their development: pyxser pyxser have about one year of development, some months doing research, and other months doing development or coding the Python Module. And the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve worked on FOSS for years. Currently I have two active projects <a href='http://coder.cl/products/pyxser/'>pyxser</a> and <a href='http://coder.cl/products/caffeine/'>caffeine</a>. Both of them requires a great effort to being completed. Take an overview on their development:</p>
<p><span id="more-643"></span></p>
<h3>pyxser</h3>
<p><b>pyxser</b> have about one year of development, some months doing research, and other months doing development or coding the <b>Python Module</b>.</p>
<div style='border: 1px solid #000; width: 600px; overflow: scroll;'>
<img src='http://coder.cl/uploads/2010/04/pyxser-last-12months.png' border='0' width='510' />
</div>
<p>And the SVN log show an average hour for commits between 22:00 and 23:00</p>
<div style='height: 200px; overflow: scroll;'>
<pre>
r125 | damowe | 2010-02-10 16:15:49 -0300 (Wed, 10 Feb 2010) | 2 lines
r124 | damowe | 2010-02-10 15:52:31 -0300 (Wed, 10 Feb 2010) | 2 lines
r123 | damowe | 2010-02-10 13:30:15 -0300 (Wed, 10 Feb 2010) | 10 lines
r122 | damowe | 2010-02-02 08:47:07 -0300 (Tue, 02 Feb 2010) | 3 lines
r121 | damowe | 2009-12-26 21:52:49 -0300 (Sat, 26 Dec 2009) | 2 lines
r118 | damowe | 2009-12-26 21:40:33 -0300 (Sat, 26 Dec 2009) | 2 lines
r117 | damowe | 2009-12-25 15:20:30 -0300 (Fri, 25 Dec 2009) | 4 lines
r116 | damowe | 2009-12-22 20:09:25 -0300 (Tue, 22 Dec 2009) | 5 lines
r115 | damowe | 2009-12-21 19:47:50 -0300 (Mon, 21 Dec 2009) | 2 lines
r114 | damowe | 2009-12-20 01:38:45 -0300 (Sun, 20 Dec 2009) | 7 lines
r112 | damowe | 2009-12-03 09:48:41 -0300 (Thu, 03 Dec 2009) | 6 lines
r110 | damowe | 2009-11-30 14:52:10 -0300 (Mon, 30 Nov 2009) | 2 lines
r109 | damowe | 2009-11-30 14:46:43 -0300 (Mon, 30 Nov 2009) | 9 lines
r107 | damowe | 2009-08-23 11:43:52 -0400 (Sun, 23 Aug 2009) | 2 lines
r102 | damowe | 2009-08-23 11:29:07 -0400 (Sun, 23 Aug 2009) | 2 lines
r99 | damowe | 2009-08-23 11:12:20 -0400 (Sun, 23 Aug 2009) | 6 lines
r98 | damowe | 2009-08-08 15:15:07 -0400 (Sat, 08 Aug 2009) | 3 lines
r93 | damowe | 2009-07-28 21:59:10 -0400 (Tue, 28 Jul 2009) | 2 lines
r90 | damowe | 2009-07-27 22:22:55 -0400 (Mon, 27 Jul 2009) | 2 lines
r89 | damowe | 2009-07-27 22:21:50 -0400 (Mon, 27 Jul 2009) | 5 lines
r88 | damowe | 2009-07-26 22:27:23 -0400 (Sun, 26 Jul 2009) | 4 lines
r87 | damowe | 2009-07-20 16:02:27 -0400 (Mon, 20 Jul 2009) | 5 lines
r86 | damowe | 2009-07-17 22:24:53 -0400 (Fri, 17 Jul 2009) | 4 lines
r84 | damowe | 2009-05-09 23:19:49 -0400 (Sat, 09 May 2009) | 2 lines
r83 | damowe | 2009-05-09 22:31:00 -0400 (Sat, 09 May 2009) | 7 lines
r82 | damowe | 2009-05-09 11:00:44 -0400 (Sat, 09 May 2009) | 3 lines
r81 | damowe | 2009-05-08 21:31:56 -0400 (Fri, 08 May 2009) | 2 lines
r80 | damowe | 2009-04-28 00:32:53 -0400 (Tue, 28 Apr 2009) | 3 lines
r78 | damowe | 2009-04-26 19:21:16 -0400 (Sun, 26 Apr 2009) | 2 lines
r77 | damowe | 2009-04-26 19:13:26 -0400 (Sun, 26 Apr 2009) | 2 lines
r76 | damowe | 2009-04-26 17:34:09 -0400 (Sun, 26 Apr 2009) | 4 lines
r75 | damowe | 2009-04-25 19:31:45 -0400 (Sat, 25 Apr 2009) | 3 lines
r74 | damowe | 2009-04-24 20:49:40 -0400 (Fri, 24 Apr 2009) | 3 lines
r73 | damowe | 2009-04-23 23:06:46 -0400 (Thu, 23 Apr 2009) | 4 lines
r72 | damowe | 2009-04-22 08:28:31 -0400 (Wed, 22 Apr 2009) | 3 lines
r71 | damowe | 2009-04-22 00:52:12 -0400 (Wed, 22 Apr 2009) | 2 lines
r70 | damowe | 2009-04-22 00:28:48 -0400 (Wed, 22 Apr 2009) | 3 lines
r69 | damowe | 2009-04-21 23:09:09 -0400 (Tue, 21 Apr 2009) | 2 lines
r68 | damowe | 2009-04-21 16:41:11 -0400 (Tue, 21 Apr 2009) | 3 lines
r65 | damowe | 2009-04-19 01:24:34 -0400 (Sun, 19 Apr 2009) | 2 lines
r64 | damowe | 2009-04-19 01:22:15 -0400 (Sun, 19 Apr 2009) | 2 lines
r63 | damowe | 2009-04-19 01:17:29 -0400 (Sun, 19 Apr 2009) | 2 lines
r62 | damowe | 2009-04-19 01:10:33 -0400 (Sun, 19 Apr 2009) | 2 lines
r61 | damowe | 2009-04-19 00:01:47 -0400 (Sun, 19 Apr 2009) | 3 lines
r59 | damowe | 2009-04-18 22:57:01 -0400 (Sat, 18 Apr 2009) | 2 lines
r58 | damowe | 2009-04-18 22:30:30 -0400 (Sat, 18 Apr 2009) | 3 lines
r57 | damowe | 2009-04-18 04:26:58 -0400 (Sat, 18 Apr 2009) | 2 lines
r56 | damowe | 2009-04-18 03:28:56 -0400 (Sat, 18 Apr 2009) | 3 lines
r55 | damowe | 2009-04-15 23:38:34 -0400 (Wed, 15 Apr 2009) | 2 lines
r54 | damowe | 2009-04-15 23:10:32 -0400 (Wed, 15 Apr 2009) | 2 lines
r53 | damowe | 2009-04-15 22:46:15 -0400 (Wed, 15 Apr 2009) | 3 lines
r52 | damowe | 2009-04-10 18:30:22 -0400 (Fri, 10 Apr 2009) | 2 lines
r49 | damowe | 2009-04-10 00:17:25 -0400 (Fri, 10 Apr 2009) | 2 lines
r47 | damowe | 2009-04-08 23:43:50 -0400 (Wed, 08 Apr 2009) | 4 lines
r46 | damowe | 2009-04-08 14:29:42 -0400 (Wed, 08 Apr 2009) | 4 lines
r45 | damowe | 2009-04-08 01:31:22 -0400 (Wed, 08 Apr 2009) | 2 lines
r44 | damowe | 2009-04-08 01:30:18 -0400 (Wed, 08 Apr 2009) | 2 lines
r43 | damowe | 2009-04-08 01:28:36 -0400 (Wed, 08 Apr 2009) | 3 lines
r42 | damowe | 2009-04-06 21:58:57 -0400 (Mon, 06 Apr 2009) | 2 lines
r41 | damowe | 2009-04-06 21:46:19 -0400 (Mon, 06 Apr 2009) | 2 lines
r40 | damowe | 2009-04-06 21:36:55 -0400 (Mon, 06 Apr 2009) | 3 lines
r39 | damowe | 2009-04-05 22:25:50 -0400 (Sun, 05 Apr 2009) | 2 lines
r38 | damowe | 2009-04-05 22:19:10 -0400 (Sun, 05 Apr 2009) | 4 lines
r37 | damowe | 2009-04-04 20:18:15 -0400 (Sat, 04 Apr 2009) | 3 lines
r36 | damowe | 2009-03-31 23:49:23 -0400 (Tue, 31 Mar 2009) | 5 lines
r33 | damowe | 2009-03-28 12:13:41 -0400 (Sat, 28 Mar 2009) | 2 lines
r30 | damowe | 2009-03-26 22:17:10 -0400 (Thu, 26 Mar 2009) | 3 lines
r29 | damowe | 2009-03-26 21:59:57 -0400 (Thu, 26 Mar 2009) | 5 lines
r28 | damowe | 2009-03-26 21:17:10 -0400 (Thu, 26 Mar 2009) | 2 lines
r27 | damowe | 2009-03-25 23:26:30 -0400 (Wed, 25 Mar 2009) | 3 lines
r26 | damowe | 2009-03-25 22:58:16 -0400 (Wed, 25 Mar 2009) | 5 lines
r25 | damowe | 2009-03-25 22:03:16 -0400 (Wed, 25 Mar 2009) | 2 lines
r24 | damowe | 2009-03-25 21:00:44 -0400 (Wed, 25 Mar 2009) | 4 lines
r23 | damowe | 2009-03-25 20:48:26 -0400 (Wed, 25 Mar 2009) | 3 lines
r22 | damowe | 2009-03-25 20:34:30 -0400 (Wed, 25 Mar 2009) | 2 lines
r21 | damowe | 2009-03-25 20:15:58 -0400 (Wed, 25 Mar 2009) | 2 lines
r20 | damowe | 2009-03-24 20:47:42 -0400 (Tue, 24 Mar 2009) | 2 lines
r19 | damowe | 2009-03-23 23:41:47 -0400 (Mon, 23 Mar 2009) | 5 lines
r18 | damowe | 2009-03-23 21:03:13 -0400 (Mon, 23 Mar 2009) | 3 lines
r17 | damowe | 2009-03-23 20:16:58 -0400 (Mon, 23 Mar 2009) | 2 lines
r16 | damowe | 2009-03-19 22:57:46 -0400 (Thu, 19 Mar 2009) | 2 lines
r15 | damowe | 2009-03-19 22:30:56 -0400 (Thu, 19 Mar 2009) | 5 lines
r14 | damowe | 2009-03-19 20:37:13 -0400 (Thu, 19 Mar 2009) | 2 lines
r13 | damowe | 2009-03-19 00:37:39 -0400 (Thu, 19 Mar 2009) | 3 lines
r12 | damowe | 2009-03-19 00:11:23 -0400 (Thu, 19 Mar 2009) | 3 lines
r11 | damowe | 2009-03-18 23:47:08 -0400 (Wed, 18 Mar 2009) | 3 lines
r10 | damowe | 2009-03-17 22:25:47 -0400 (Tue, 17 Mar 2009) | 2 lines
r9 | damowe | 2009-03-17 22:23:21 -0400 (Tue, 17 Mar 2009) | 2 lines
r8 | damowe | 2009-03-17 22:16:37 -0400 (Tue, 17 Mar 2009) | 2 lines
r7 | damowe | 2009-03-17 00:55:43 -0400 (Tue, 17 Mar 2009) | 2 lines
r6 | damowe | 2009-03-16 23:33:31 -0400 (Mon, 16 Mar 2009) | 2 lines
r5 | damowe | 2009-03-15 17:21:57 -0400 (Sun, 15 Mar 2009) | 2 lines
r4 | damowe | 2009-03-15 17:07:39 -0400 (Sun, 15 Mar 2009) | 2 lines
r1 | damowe | 2009-03-15 15:35:31 -0400 (Sun, 15 Mar 2009) | 2 lines
</pre>
</div>
<p>The project has <b>6,198</b> lines of code&#8230; a good effort and a good product. During the day I must work on those projects which bring me money, at night and as hobbits I work on my FOSS projects. I have a little time to work on them.</p>
<h3>caffeine</h3>
<p><b>caffeine</b> or C Application Framework has <b>14,177</b> lines of code, and it is evaluated as one project with three humans working on it, but it is really one, me.</p>
<div style='border: 1px solid #000; width: 600px; overflow: scroll;'>
<img src='http://coder.cl/uploads/2010/04/caffeine-last-year.png' border='0' width='510' />
</div>
<div style='border: 1px solid #000; width: 600px; overflow: scroll;'>
<img src='http://coder.cl/uploads/2010/04/caffeine-2009.png' border='0' width='510' />
</div>
<div style='border: 1px solid #000; width: 600px; overflow: scroll;'>
<img src='http://coder.cl/uploads/2010/04/caffeine-2008.png' border='0' width='510' />
</div>
<p>And the SVN log show an average hour for commits between 22:00 and 23:00</p>
<div style='height: 200px; overflow: scroll;'>
<pre>
r125 | damowe | 2009-09-30 14:45:06 -0400 (Wed, 30 Sep 2009) | 6 lines
r124 | damowe | 2009-09-26 18:49:31 -0400 (Sat, 26 Sep 2009) | 2 lines
r123 | damowe | 2009-09-26 17:46:26 -0400 (Sat, 26 Sep 2009) | 5 lines
r122 | damowe | 2009-09-26 13:14:50 -0400 (Sat, 26 Sep 2009) | 2 lines
r121 | damowe | 2009-09-26 12:25:19 -0400 (Sat, 26 Sep 2009) | 4 lines
r120 | damowe | 2009-09-22 05:18:11 -0400 (Tue, 22 Sep 2009) | 8 lines
r119 | damowe | 2009-09-19 23:27:06 -0400 (Sat, 19 Sep 2009) | 5 lines
r118 | damowe | 2009-09-19 19:06:50 -0400 (Sat, 19 Sep 2009) | 8 lines
r117 | damowe | 2009-09-01 22:18:54 -0400 (Tue, 01 Sep 2009) | 5 lines
r116 | damowe | 2008-10-27 07:40:14 -0300 (Mon, 27 Oct 2008) | 2 lines
r115 | damowe | 2008-10-27 07:38:30 -0300 (Mon, 27 Oct 2008) | 2 lines
r114 | damowe | 2008-10-27 07:35:09 -0300 (Mon, 27 Oct 2008) | 3 lines
r113 | damowe | 2008-10-25 13:01:20 -0300 (Sat, 25 Oct 2008) | 2 lines
r112 | damowe | 2008-06-10 21:10:30 -0400 (Tue, 10 Jun 2008) | 3 lines
r111 | damowe | 2008-06-06 20:05:39 -0400 (Fri, 06 Jun 2008) | 5 lines
r110 | damowe | 2008-05-08 21:12:50 -0400 (Thu, 08 May 2008) | 2 lines
r109 | damowe | 2008-05-06 23:53:10 -0400 (Tue, 06 May 2008) | 2 lines
r108 | damowe | 2008-05-05 23:37:42 -0400 (Mon, 05 May 2008) | 2 lines
r107 | damowe | 2008-04-27 02:08:49 -0400 (Sun, 27 Apr 2008) | 2 lines
r106 | damowe | 2008-04-26 11:59:49 -0400 (Sat, 26 Apr 2008) | 4 lines
r105 | damowe | 2008-04-22 23:06:33 -0400 (Tue, 22 Apr 2008) | 3 lines
r104 | damowe | 2008-04-21 21:13:06 -0400 (Mon, 21 Apr 2008) | 4 lines
r103 | damowe | 2008-02-10 13:16:32 -0300 (Sun, 10 Feb 2008) | 3 lines
r102 | damowe | 2008-02-10 10:22:34 -0300 (Sun, 10 Feb 2008) | 2 lines
r101 | damowe | 2008-02-10 10:08:35 -0300 (Sun, 10 Feb 2008) | 2 lines
r100 | damowe | 2008-01-06 12:07:57 -0300 (Sun, 06 Jan 2008) | 4 lines
r99 | damowe | 2008-01-05 20:03:27 -0300 (Sat, 05 Jan 2008) | 4 lines
r98 | damowe | 2008-01-01 17:29:14 -0300 (Tue, 01 Jan 2008) | 3 lines
r97 | damowe | 2007-12-31 15:47:20 -0300 (Mon, 31 Dec 2007) | 2 lines
r96 | damowe | 2007-12-30 12:15:46 -0300 (Sun, 30 Dec 2007) | 2 lines
r95 | damowe | 2007-12-30 12:06:41 -0300 (Sun, 30 Dec 2007) | 3 lines
r94 | damowe | 2007-12-30 07:59:58 -0300 (Sun, 30 Dec 2007) | 2 lines
r93 | damowe | 2007-12-25 10:37:15 -0300 (Tue, 25 Dec 2007) | 3 lines
r92 | damowe | 2007-12-22 09:57:27 -0300 (Sat, 22 Dec 2007) | 2 lines
r91 | damowe | 2007-12-22 09:56:15 -0300 (Sat, 22 Dec 2007) | 4 lines
r90 | damowe | 2007-12-22 07:26:39 -0300 (Sat, 22 Dec 2007) | 3 lines
r89 | damowe | 2007-12-16 22:21:51 -0300 (Sun, 16 Dec 2007) | 4 lines
r88 | damowe | 2007-12-03 21:35:27 -0300 (Mon, 03 Dec 2007) | 2 lines
r87 | damowe | 2007-12-01 23:56:53 -0300 (Sat, 01 Dec 2007) | 3 lines
r86 | damowe | 2007-12-01 23:44:02 -0300 (Sat, 01 Dec 2007) | 2 lines
r85 | damowe | 2007-11-11 09:06:24 -0300 (Sun, 11 Nov 2007) | 4 lines
r84 | damowe | 2007-11-10 21:43:36 -0300 (Sat, 10 Nov 2007) | 2 lines
r83 | damowe | 2007-11-10 21:25:58 -0300 (Sat, 10 Nov 2007) | 2 lines
r82 | damowe | 2007-10-07 11:39:55 -0400 (Sun, 07 Oct 2007) | 3 lines
r81 | damowe | 2007-10-07 08:32:09 -0400 (Sun, 07 Oct 2007) | 3 lines
r80 | damowe | 2007-09-30 21:53:52 -0400 (Sun, 30 Sep 2007) | 3 lines
r79 | damowe | 2007-09-19 18:27:20 -0400 (Wed, 19 Sep 2007) | 2 lines
r78 | damowe | 2007-09-18 00:34:21 -0400 (Tue, 18 Sep 2007) | 2 lines
r77 | damowe | 2007-09-17 17:10:57 -0400 (Mon, 17 Sep 2007) | 3 lines
r76 | damowe | 2007-09-15 17:27:45 -0400 (Sat, 15 Sep 2007) | 2 lines
r75 | damowe | 2007-09-08 11:19:19 -0400 (Sat, 08 Sep 2007) | 2 lines
r74 | damowe | 2007-09-02 12:11:38 -0400 (Sun, 02 Sep 2007) | 2 lines
r73 | damowe | 2007-09-02 10:57:54 -0400 (Sun, 02 Sep 2007) | 2 lines
r72 | damowe | 2007-09-02 10:55:09 -0400 (Sun, 02 Sep 2007) | 2 lines
r71 | damowe | 2007-09-02 09:38:43 -0400 (Sun, 02 Sep 2007) | 5 lines
r70 | damowe | 2007-09-02 02:13:20 -0400 (Sun, 02 Sep 2007) | 4 lines
r69 | damowe | 2007-08-31 20:05:06 -0400 (Fri, 31 Aug 2007) | 3 lines
r68 | damowe | 2007-08-26 13:34:53 -0400 (Sun, 26 Aug 2007) | 2 lines
r67 | damowe | 2007-08-26 13:15:04 -0400 (Sun, 26 Aug 2007) | 3 lines
r66 | damowe | 2007-08-26 10:10:19 -0400 (Sun, 26 Aug 2007) | 3 lines
r65 | damowe | 2007-08-25 19:00:10 -0400 (Sat, 25 Aug 2007) | 3 lines
r64 | damowe | 2007-08-19 00:26:00 -0400 (Sun, 19 Aug 2007) | 3 lines
r63 | damowe | 2007-08-18 10:36:16 -0400 (Sat, 18 Aug 2007) | 3 lines
r62 | damowe | 2007-08-15 17:23:28 -0400 (Wed, 15 Aug 2007) | 2 lines
r61 | damowe | 2007-08-13 07:48:31 -0400 (Mon, 13 Aug 2007) | 3 lines
r60 | damowe | 2007-08-12 17:06:08 -0400 (Sun, 12 Aug 2007) | 2 lines
r59 | damowe | 2007-08-12 16:33:09 -0400 (Sun, 12 Aug 2007) | 3 lines
r58 | damowe | 2007-08-12 13:39:59 -0400 (Sun, 12 Aug 2007) | 2 lines
r57 | damowe | 2007-08-12 01:26:32 -0400 (Sun, 12 Aug 2007) | 2 lines
r56 | damowe | 2007-08-11 13:26:10 -0400 (Sat, 11 Aug 2007) | 2 lines
r55 | damowe | 2007-08-11 13:21:17 -0400 (Sat, 11 Aug 2007) | 3 lines
r54 | damowe | 2007-08-06 21:58:22 -0400 (Mon, 06 Aug 2007) | 2 lines
r53 | damowe | 2007-08-04 23:03:06 -0400 (Sat, 04 Aug 2007) | 3 lines
r52 | damowe | 2007-08-04 22:39:10 -0400 (Sat, 04 Aug 2007) | 3 lines
r51 | damowe | 2007-08-04 17:28:45 -0400 (Sat, 04 Aug 2007) | 2 lines
r50 | damowe | 2007-08-04 16:54:48 -0400 (Sat, 04 Aug 2007) | 2 lines
r49 | damowe | 2007-07-29 09:15:12 -0400 (Sun, 29 Jul 2007) | 2 lines
r48 | damowe | 2007-07-28 17:38:23 -0400 (Sat, 28 Jul 2007) | 2 lines
r47 | damowe | 2007-07-16 23:45:16 -0400 (Mon, 16 Jul 2007) | 3 lines
r46 | damowe | 2007-07-16 16:47:06 -0400 (Mon, 16 Jul 2007) | 3 lines
r45 | damowe | 2007-07-15 20:03:51 -0400 (Sun, 15 Jul 2007) | 3 lines
r44 | damowe | 2007-07-15 12:10:35 -0400 (Sun, 15 Jul 2007) | 3 lines
r43 | damowe | 2007-07-02 17:30:56 -0400 (Mon, 02 Jul 2007) | 2 lines
r42 | damowe | 2007-07-02 10:46:27 -0400 (Mon, 02 Jul 2007) | 3 lines
r41 | damowe | 2007-06-30 16:23:19 -0400 (Sat, 30 Jun 2007) | 2 lines
r40 | damowe | 2007-06-23 21:08:20 -0400 (Sat, 23 Jun 2007) | 3 lines
r39 | damowe | 2007-06-23 10:37:22 -0400 (Sat, 23 Jun 2007) | 2 lines
r38 | damowe | 2007-06-23 10:33:24 -0400 (Sat, 23 Jun 2007) | 2 lines
r37 | damowe | 2007-06-22 23:10:58 -0400 (Fri, 22 Jun 2007) | 3 lines
r36 | damowe | 2007-06-20 21:57:34 -0400 (Wed, 20 Jun 2007) | 3 lines
r35 | damowe | 2007-06-18 21:22:26 -0400 (Mon, 18 Jun 2007) | 3 lines
r34 | damowe | 2007-06-17 21:33:13 -0400 (Sun, 17 Jun 2007) | 2 lines
r33 | damowe | 2007-06-17 21:31:58 -0400 (Sun, 17 Jun 2007) | 2 lines
r32 | damowe | 2007-06-17 18:48:40 -0400 (Sun, 17 Jun 2007) | 3 lines
r31 | damowe | 2007-06-17 12:03:32 -0400 (Sun, 17 Jun 2007) | 3 lines
r30 | damowe | 2007-06-17 11:50:15 -0400 (Sun, 17 Jun 2007) | 2 lines
r29 | damowe | 2007-06-16 21:48:05 -0400 (Sat, 16 Jun 2007) | 2 lines
r28 | damowe | 2007-06-16 21:43:38 -0400 (Sat, 16 Jun 2007) | 3 lines
r27 | damowe | 2007-06-09 18:25:07 -0400 (Sat, 09 Jun 2007) | 2 lines
r26 | damowe | 2007-06-09 18:05:07 -0400 (Sat, 09 Jun 2007) | 2 lines
r25 | damowe | 2007-06-09 18:03:56 -0400 (Sat, 09 Jun 2007) | 3 lines
r24 | damowe | 2007-06-03 20:45:25 -0400 (Sun, 03 Jun 2007) | 3 lines
r23 | damowe | 2007-06-03 19:08:34 -0400 (Sun, 03 Jun 2007) | 2 lines
r22 | damowe | 2007-06-03 19:07:35 -0400 (Sun, 03 Jun 2007) | 2 lines
r21 | damowe | 2007-05-21 10:48:01 -0400 (Mon, 21 May 2007) | 2 lines
r20 | damowe | 2007-05-20 22:00:12 -0400 (Sun, 20 May 2007) | 2 lines
r19 | damowe | 2007-05-20 21:45:38 -0400 (Sun, 20 May 2007) | 6 lines
r18 | damowe | 2007-05-20 10:57:12 -0400 (Sun, 20 May 2007) | 2 lines
r17 | damowe | 2007-05-19 22:22:24 -0400 (Sat, 19 May 2007) | 5 lines
r16 | damowe | 2007-05-18 21:41:36 -0400 (Fri, 18 May 2007) | 2 lines
r15 | damowe | 2007-05-14 23:02:09 -0400 (Mon, 14 May 2007) | 3 lines
r14 | damowe | 2007-05-13 12:03:47 -0400 (Sun, 13 May 2007) | 2 lines
r13 | damowe | 2007-05-13 01:01:13 -0400 (Sun, 13 May 2007) | 2 lines
r12 | damowe | 2007-05-12 22:48:18 -0400 (Sat, 12 May 2007) | 2 lines
r11 | damowe | 2007-05-12 22:41:14 -0400 (Sat, 12 May 2007) | 3 lines
r10 | damowe | 2007-05-07 08:57:33 -0400 (Mon, 07 May 2007) | 2 lines
r9 | damowe | 2007-05-03 08:37:04 -0400 (Thu, 03 May 2007) | 3 lines
r8 | damowe | 2007-05-02 20:50:25 -0400 (Wed, 02 May 2007) | 3 lines
r7 | damowe | 2007-05-01 17:43:00 -0400 (Tue, 01 May 2007) | 2 lines
r6 | damowe | 2007-05-01 09:31:08 -0400 (Tue, 01 May 2007) | 2 lines
r5 | damowe | 2007-05-01 09:24:07 -0400 (Tue, 01 May 2007) | 1 line
r4 | damowe | 2007-05-01 09:08:02 -0400 (Tue, 01 May 2007) | 2 lines
r3 | damowe | 2007-05-01 09:05:41 -0400 (Tue, 01 May 2007) | 2 lines
r2 | damowe | 2007-05-01 09:04:51 -0400 (Tue, 01 May 2007) | 2 lines
r1 | damowe | 2007-05-01 09:04:22 -0400 (Tue, 01 May 2007) | 2 lines
</pre>
</div>
<p><br/></p>
<p>Both projects requires effort and research, and both project are not simple ones to handle, since they are written in <b>C</b>, a language difficult to learn and handle&#8230; I hope that I can continue the foss development that I&#8217;ve started, but seems that I have some health problems now <img src='http://coder.cl/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>



share this article at: 


	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fcoder.cl%2F2010%2F04%2Fmy-contribution-to-freeopen-source-software%2F&amp;title=my%20contribution%20to%20free%2Fopen%20source%20software&amp;source=coder+.+cl+system+programmer+%26amp%3B+web+developer&amp;summary=I%27ve%20worked%20on%20FOSS%20for%20years.%20Currently%20I%20have%20two%20active%20projects%20pyxser%20and%20caffeine.%20Both%20of%20them%20requires%20a%20great%20effort%20to%20being%20completed.%20Take%20an%20overview%20on%20their%20development%3A%0D%0A%0D%0Apyxser%0D%0A%0D%0Apyxser%20have%20about%20one%20year%20of%20development%2C%20some%20mont" title="LinkedIn"><img src="http://coder.cl/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fcoder.cl%2F2010%2F04%2Fmy-contribution-to-freeopen-source-software%2F&amp;title=my%20contribution%20to%20free%2Fopen%20source%20software&amp;notes=I%27ve%20worked%20on%20FOSS%20for%20years.%20Currently%20I%20have%20two%20active%20projects%20pyxser%20and%20caffeine.%20Both%20of%20them%20requires%20a%20great%20effort%20to%20being%20completed.%20Take%20an%20overview%20on%20their%20development%3A%0D%0A%0D%0Apyxser%0D%0A%0D%0Apyxser%20have%20about%20one%20year%20of%20development%2C%20some%20mont" title="del.icio.us"><img src="http://coder.cl/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fcoder.cl%2F2010%2F04%2Fmy-contribution-to-freeopen-source-software%2F&amp;title=my%20contribution%20to%20free%2Fopen%20source%20software&amp;bodytext=I%27ve%20worked%20on%20FOSS%20for%20years.%20Currently%20I%20have%20two%20active%20projects%20pyxser%20and%20caffeine.%20Both%20of%20them%20requires%20a%20great%20effort%20to%20being%20completed.%20Take%20an%20overview%20on%20their%20development%3A%0D%0A%0D%0Apyxser%0D%0A%0D%0Apyxser%20have%20about%20one%20year%20of%20development%2C%20some%20mont" title="Digg"><img src="http://coder.cl/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fcoder.cl%2F2010%2F04%2Fmy-contribution-to-freeopen-source-software%2F&amp;title=my%20contribution%20to%20free%2Fopen%20source%20software" title="Reddit"><img src="http://coder.cl/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fcoder.cl%2F2010%2F04%2Fmy-contribution-to-freeopen-source-software%2F&amp;t=my%20contribution%20to%20free%2Fopen%20source%20software" title="Facebook"><img src="http://coder.cl/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=my%20contribution%20to%20free%2Fopen%20source%20software%20-%20http%3A%2F%2Fcoder.cl%2F2010%2F04%2Fmy-contribution-to-freeopen-source-software%2F" title="Twitter"><img src="http://coder.cl/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fcoder.cl%2F2010%2F04%2Fmy-contribution-to-freeopen-source-software%2F&amp;title=my%20contribution%20to%20free%2Fopen%20source%20software&amp;annotation=I%27ve%20worked%20on%20FOSS%20for%20years.%20Currently%20I%20have%20two%20active%20projects%20pyxser%20and%20caffeine.%20Both%20of%20them%20requires%20a%20great%20effort%20to%20being%20completed.%20Take%20an%20overview%20on%20their%20development%3A%0D%0A%0D%0Apyxser%0D%0A%0D%0Apyxser%20have%20about%20one%20year%20of%20development%2C%20some%20mont" title="Google Bookmarks"><img src="http://coder.cl/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/><br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2010 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2010. | <a href="http://coder.cl/2010/04/my-contribution-to-freeopen-source-software/">Permalink</a> | <a href="http://coder.cl/2010/04/my-contribution-to-freeopen-source-software/#comments">No comment</a><br/>Post tags: <br/></small></p>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2010/04/my-contribution-to-freeopen-source-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>source code optimization in c</title>
		<link>http://coder.cl/2009/12/source-code-optimization-in-c/</link>
		<comments>http://coder.cl/2009/12/source-code-optimization-in-c/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 21:45:02 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=589</guid>
		<description><![CDATA[&#34;&#8230;premature optimization is the root of all evil&#34;. &#8212; Donald Knuth I agree with the fact that we must do our source code level optimizations when we have finshed the construction stage or it is almost complete. I was searching articles and papers about optimizing C source code to be applied on my programs and [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>
<i>&quot;&#8230;premature optimization is the root of all evil&quot;</i>.<br />
<i style='align: right;'>&mdash; Donald Knuth</i>
</p></blockquote>
<p>I agree with the fact that we must do our source code level optimizations when we have finshed the construction stage or it is almost complete. I was searching articles and papers about optimizing C source code to be applied on my programs and libraries. I&#8217;ve collected some of those optimizations. But you must not confuse algorithm optimization, source code optimization and compiler optimization, since the first one refers to <i>algorithm design</i> and the second one just refers to the <i>algorithm implementation</i>, and both are sharing just few common approaches to formal reductions.</i><span id="more-589"></span></p>
<p>Usually the source code optimization just applies well known formal reductions. We will not treat those formalities in this article. Instead we will take a look on some examples that I&#8217;ve collected, allowing a common reasoning about how to optimize the source code. Most ideas for source code optimizations comes from &eta;-conversions using &lambda; equivalences, allowing for example reductions from <img src="http://coder.cl/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_992.5_109bdcfacfe30bd05b191cfd2e7c3612.png" style="vertical-align:-7.5px; display: inline-block ;" alt="O(log ~n) ~left~ O(n)" title="O(log ~n) ~left~ O(n)"/>. Also, some optimizations without an apparent &eta;-conversion, since most is done at low level, as those which are taken by the compiler and translated to less assembler instructions, such as function inlining and parameter reduction. Most &eta;-conversions which implies &eta;-reductions, and are called <i>strength reductions</i>. But we have also the opposed side, where we are &mdash; instead of doing reductions &mdash; populating our programs with more lines of code, including repeated code, such as the loop unrolling optimization.</p>
<p><br/></p>
<h3>inline code</h3>
<p>C supports both <i>macros</i> and <i>inlining functions</i>. Both features are reaching the same effect, when the code is compiled, all <i>inlined</i> instructions are placed when we call the macro or the inline function. For example, a typical approach, is a <tt>max(a, b)</tt> function or a <tt>MAX(a, b)</tt> macro.</p>
<pre name="code" class="c">
/* the slowest expression, compiling and running */
int
max(int a, int b)
{
	if (a &gt; b)
		return a;
	else
		return b;
}

/* normal expression with inlining */
inline int
max(int a, int b)
{
	return ((a &gt; b) ? a : b);
}

/* the faster expression using macros */
#define MAX(a, b)			((a &gt; b) ? a : b)
</pre>
<p>The <i>inline</i> and the <i>macro</i> definitions both are similar. The macro places every occurrence of <tt>MAX(var1, var2)</tt> expressions with the <tt>((var1 > var2) ? var1 : var2)</tt> expression. The <i>inline</i> does the same, and places every occurrence of <tt>max(var1, var2)</tt> with the <i>result</i> of the expression <tt>((var1 > var2) ? var1 : var2)</tt>. So, the macro usage is oriented to replace entire blocks of code, instead of inline functions which are oriented to replace calls and skip the assembler <i>call</i> instruction and its derivates. We may look examples of the <i>call</i> opcode in typical system calls on operating systems, such as FreeBSD system calls.</p>
<p><br/></p>
<h3>parameter reduction</h3>
<p>Reducing parameters implies less assembler instructions. C calling convention typically push parameters into the stack, which implies that for each parameter a <i>push</i> opcode call is made. For example you can group function arguments &mdash; if they are use subsequently by a group of functions &mdash; under <tt>struct</tt> forms. Think a little, each <i>push</i> instruction in his family takes 2 clocks, varying to 18 clocks on x86 architecture &mdash; depending on vendor and model. For 8 arguments, it will take from 16 to 36 clocks, against 2 to 18 clocks with one argument. This approach on argument reduction may be applied to those functions which are not inlined.</p>
<pre name='code' class='c'>
/* slower version */
int
my_function(int arg1, int arg2, int arg3, int arg4)
{
	/* do something... */
}

/* faster version */
struct myargs
{
	int arg1; int arg2; int arg3; int arg4;
};

int
my_function(struct myargs *args)
{
	/* do something... */
}
</pre>
<p><br/></p>
<h3>practical reductions</h3>
<p>We do <i>reduction</i> when we remove unnecessary steps in our functions. We can do most reductions just by thinking a little on the code, and also there are some well known reductions which can be used as optimizations.</p>
<h4>removing else</h4>
<pre name='code' class='c'>
/* with else, smaller code, but slower one */
inline int
test(int a)
{
	return a &gt; 0 ? 1 : 0;
}

/* without else, large code but faster one */
inline int
test(int a)
{
	if (a &gt; 0)
		return 1;
	/* implied else */
	return 0;
}
</pre>
<p>On this optimization, we are removing <tt>jmp</tt> and <tt>jxx</tt> family of instructions, where most of them takes near to 7 clocks on x86 architecture and also the required instruction to setup the proper context for the following instruction in the program sequence. This is like the <i>spartan programming</i> style, where most code is minimized through reductions and similar programming tasks.</p>
<h4>bitwise operations</h4>
<p>Bitwise operations are cheaper than other operations. For example, curiously, a shift operation and plus operations have less clocks than multiplication and division operations. The happens to logical evaluations. In other post, I&#8217;ve wrote about <a href='http://coder.cl/2008/12/29/minimization-patterns/'>logical minimizations</a>. A complement to what I&#8217;ve said, is the fact that <tt>mul</tt> instruction takes from 10 to 40 clocks and <i>div</i> instruction takes from 15 to 40 clocks on x86 architecture, against <tt>add</tt>, <tt>sub</tt>, <tt>shr</tt>, <tt>shl</tt> and similar instruction that are taking from 2 to 7 clocks. Remember that the number clocks used by some instruction is vendor and model dependent. For example if we do:</p>
<pre name='code' class='c'>
/* we take a call to the math.h function pow() */
n = y * pow(2.0, x);

/* we can replace it by */
n = y &lt;&lt; x;
</pre>
<p>In other words, the <tt>x &lt;&lt; y</tt> operation is equivalent to <img src="http://coder.cl/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_994.5_975cf26e16a8e396b3e831896513a495.png" style="vertical-align:-5.5px; display: inline-block ;" alt="y * 2 ^ x" title="y * 2 ^ x"/>. You can find other math equivalences too. From this basic approach, we can reach other types of optimizations through the proper maths. You can take a look on the <a href='http://www.jjj.de/bitwizardry/bitwizardrypage.html'>bit wizardry</a> page from <i>Jörg Arndt</i> if you want to seek for more bitwise operations and reductions.</p>
<h4>reversing counter loops</h4>
<p>Usually we do one step loops for fixed set of counters. The following example shows a reduction which can be used every time we can do a reverse loop.</p>
<pre name='code' class='c'>
/* for loop coded usually */
for (c = 0; c &lt; MAX_C_VALUE; c++) {
	/* do something... */
}

/* for reversed loop */
for (c = MAX_C_VALUE; c--; /* we do not do nothing here */ ) {
	/* do something... */
}
</pre>
<h4>table lookups</h4>
<p>A table lookup is the technique where we create an array and kind related structures to lookup for data, usually previously calculated data or simply, we are looking for concrete data that we want to use.</p>
<pre name='code' class='c'>
/* we can have a switch statement */
ourtype_t *varn = NULL;
switch (var1) {
case 0:
	varn = value1; break;
case 1:
	varn = value2; break;
case 2:
	varn = value3; break;
default:
	varn = value1;
}

/* or have an if/else statement */
if (var1 == 0)
	varn = value1;
else if (var1 == 1)
	varn = value2;
else if (var2 == 2)
	varn = value3;
else
	varn = value1;

/* so we can simply replace those values using arrays */
ourtype_t mapsvalues[] = { value1, value2, value3 };
varn = mapsvalues[var1];
</pre>
<p>Also we usually can setup reductions by creating <i>table lookups</i> and <i>state machines</i>, so we can create the proper map between certain variable data and certain <i>function</i>. State machines are a powerful abstraction which allows us to code different states inside data structures.</p>
<p>We can have predefined values in our table lookup tasks. Then we are using <a href='http://en.wikipedia.org/wiki/Lazy_evaluation'>lazy evaluation</a>. Every time we have a constant value which is requested and not calculated each time we work with it, we are doing lazy evaluation.</p>
<h4>register keyword</h4>
<pre name='code' class='c'>
/* using the register keyword should help creating faster code */
register int counter;
</pre>
<p><br/></p>
<h3>reduce data access computation</h3>
<p>If we have deep constructed data structures (<tt>struct</tt> in C), every time we access most deep nodes, we are using <i>pointer arithmetics</i>, which implies basic math operations to access certain parts of our structures. Here we can do tow tasks: <i>alias creation and usage</i> and <i>padding adjustment</i>. Alias usage, means that we must use an internal pointer to access directly a structure member, so we omit pointer calculation each time we access it. Padding adjustment, is just about to create the proper data structure member order.</p>
<pre name='code' class='c'>
/* structure without the proper padding */
struct my_struct {
	char *a;
	void *b;
	int c;
	double n;
	char *x;
};

/* the same structure with the proper padding */
struct my_struct {
	double n;
	int c;
	char *a;
	char *x;
	void *b;
};
</pre>
<p>Also the data access computation is reduced on assembler level code, not the C code. Here we have an implied &eta;-reduction and invisible one. For deeply and nested data structures, we have the same issue. We should have as rule that the structure size must have an ideal size of <img src="http://coder.cl/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_994.5_2d815e98c648cc714c03be5dad8ec434.png" style="vertical-align:-5.5px; display: inline-block ;" alt="~s = ~n^2" title="~s = ~n^2"/>, with <img src="http://coder.cl/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_995_6ded80df32818a359c9e6e317b4a741b.png" style="vertical-align:-5px; display: inline-block ;" alt="~s" title="~s"/> as the structure size and <img src="http://coder.cl/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_995_7f9468a4201f228dc27a50d25c44c696.png" style="vertical-align:-5px; display: inline-block ;" alt="~n" title="~n"/> as the padding adjustemnt to power of two.</p>
<pre name='code' class='c'>
/* some structs with nested members */
struct a {
	int m1;
};

struct b {
	int m2;
	struct a *m3;
}

struct c {
	int m4;
	struct b *m5;
}

/* the non cheaper version to access its members */
struct c *x = some_function_returning_c();
x-&gt;m5-&gt;m3-&gt;m1 = some_other_function();
if (x-&gt;m5-&gt;m3-&gt;m1 != 0) {
	another_function(x-&gt;m5-&gt;m3-&gt;m1);
}

/* the cheaper version to access its members
   using aliases */
struct c *x = some_function_returning_c();
struct b *p;
b = x-&gt;m5-&gt;m3;
b-&gt;m1 = some_other_function();
if (b-&gt;m1 != 0) {
	another_function(b-&gt;m1);
}
</pre>
<p><br/></p>
<h3>loop unrolling</h3>
<p>Each step on a loop repeats some instructions. For example if we have a fixed size array, where we must treat each element with certain function, we can use unrolled loops.</p>
<pre name='code' class='c'>
/* normal iteration over fixed size array */
for (i = 0; i &lt; 100; i++) {
	call_some_function(my_array[i]);
}

/* applied loop unrolling and reverse loop */
for (i = 100; i--;) {
	call_some_function(my_array[i]);
	call_some_function(my_array[--i]);
	call_some_function(my_array[--i]);
	call_some_function(my_array[--i]);
	call_some_function(my_array[--i]);
}
</pre>
<p>Note that here we have a fixed size array. In other case is hard to know the array size. Also we can use our compiler optimization to unroll each loop, if our compiler has the proper option. For example <i>GCC</i> supports automatic loop unrolling by using the <i>-funroll-loops</i> flag.</p>
<p><br/></p>
<h3>loop jamming</h3>
<p>Reusing blocks of code inside loops matters.</p>
<pre name='code' class='c'>
/* here we have two loops for something that can
   be done one loop */
for (i = 0; i &lt; 100; i++) {
	some_function_a(my_array[i]);
}
for (i = 0; i &lt; 100; i += 10) {
	some_function_b(my_array[i]);
}

/* here we have two loops for something that can
   be done one loop */
for (i = 0; i &lt; 100; i++) {
	some_function_a(my_array[i]);
	if ((i % 10) == 0) {
		some_function_b(my_array[i]);
	}
}
</pre>
<p>On the example above we have the proper loop doing the same tasks with less operations, so we have reduced the steps of that loop from <img src="http://coder.cl/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_992.5_7b1dc71d185484895c3d041d16d3e12c.png" style="vertical-align:-7.5px; display: inline-block ;" alt="O(2n)" title="O(2n)"/> to <img src="http://coder.cl/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_992.5_125ef5dbfb16f87edc57260c2f532793.png" style="vertical-align:-7.5px; display: inline-block ;" alt="O(n)" title="O(n)"/> &mdash; note that <img src="http://coder.cl/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_992.5_7b1dc71d185484895c3d041d16d3e12c.png" style="vertical-align:-7.5px; display: inline-block ;" alt="O(2n)" title="O(2n)"/> is just symbolic and not strict.</p>
<p><br/></p>
<h3>bit padding matters</h3>
<p>It depends on the architecture. Processing data types shorter or larger than the register size do not have a cheaper cost than using them. For example if we use <tt>char</tt> or <tt>short</tt>, we are not using a complete register, which is more hard to handle than register length variables, such as <tt>int</tt> and <tt>long</tt>.</p>
<p><br/></p>
<h3>references</h3>
<ul>
<li>Michael E. Lee, <a href='http://leto.net/docs/C-optimization.php'>&quot;Optimization of Computer Programs in C&quot;</a>, Ontek Corporation.</li>
<li>Adrian Barnetts, <a href='http://www.abarnett.demon.co.uk/tutorial.html'>&quot;C optimisation tutorial&quot;</a>.</li>
<li>Paul Hsieh, <a href='http://www.azillionmonkeys.com/qed/optimize.html'>&quot;Programming Optimization&quot;</a>.</li>
<li>Koushik Ghosh, <a href='http://www.codeproject.com/KB/cpp/C___Code_Optimization.aspx'>Writing Efficient C and C Code Optimization</a>, The Code Project.</li>
<li><a href='http://www.eventhelix.com/realtimemantra/basics/optimizingcandcppcode.htm'>Optimizing C and C++ Code</a>. EventHelix.</li>
<li>Cris H. Pappas and William H. Murray, <i>&quot;386 Microprocessor Handbook</a>&quot;</i>, McGraw Hill.</li>
</ul>



share this article at: 


	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fsource-code-optimization-in-c%2F&amp;title=source%20code%20optimization%20in%20c&amp;source=coder+.+cl+system+programmer+%26amp%3B+web+developer&amp;summary=%0D%0A%26quot%3B...premature%20optimization%20is%20the%20root%20of%20all%20evil%26quot%3B.%0D%0A%26mdash%3B%20Donald%20Knuth%0D%0A%0D%0A%0D%0AI%20agree%20with%20the%20fact%20that%20we%20must%20do%20our%20source%20code%20level%20optimizations%20when%20we%20have%20finshed%20the%20construction%20stage%20or%20it%20is%20almost%20complete.%20I%20was%20searchin" title="LinkedIn"><img src="http://coder.cl/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fsource-code-optimization-in-c%2F&amp;title=source%20code%20optimization%20in%20c&amp;notes=%0D%0A%26quot%3B...premature%20optimization%20is%20the%20root%20of%20all%20evil%26quot%3B.%0D%0A%26mdash%3B%20Donald%20Knuth%0D%0A%0D%0A%0D%0AI%20agree%20with%20the%20fact%20that%20we%20must%20do%20our%20source%20code%20level%20optimizations%20when%20we%20have%20finshed%20the%20construction%20stage%20or%20it%20is%20almost%20complete.%20I%20was%20searchin" title="del.icio.us"><img src="http://coder.cl/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fsource-code-optimization-in-c%2F&amp;title=source%20code%20optimization%20in%20c&amp;bodytext=%0D%0A%26quot%3B...premature%20optimization%20is%20the%20root%20of%20all%20evil%26quot%3B.%0D%0A%26mdash%3B%20Donald%20Knuth%0D%0A%0D%0A%0D%0AI%20agree%20with%20the%20fact%20that%20we%20must%20do%20our%20source%20code%20level%20optimizations%20when%20we%20have%20finshed%20the%20construction%20stage%20or%20it%20is%20almost%20complete.%20I%20was%20searchin" title="Digg"><img src="http://coder.cl/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fsource-code-optimization-in-c%2F&amp;title=source%20code%20optimization%20in%20c" title="Reddit"><img src="http://coder.cl/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fsource-code-optimization-in-c%2F&amp;t=source%20code%20optimization%20in%20c" title="Facebook"><img src="http://coder.cl/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=source%20code%20optimization%20in%20c%20-%20http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fsource-code-optimization-in-c%2F" title="Twitter"><img src="http://coder.cl/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fsource-code-optimization-in-c%2F&amp;title=source%20code%20optimization%20in%20c&amp;annotation=%0D%0A%26quot%3B...premature%20optimization%20is%20the%20root%20of%20all%20evil%26quot%3B.%0D%0A%26mdash%3B%20Donald%20Knuth%0D%0A%0D%0A%0D%0AI%20agree%20with%20the%20fact%20that%20we%20must%20do%20our%20source%20code%20level%20optimizations%20when%20we%20have%20finshed%20the%20construction%20stage%20or%20it%20is%20almost%20complete.%20I%20was%20searchin" title="Google Bookmarks"><img src="http://coder.cl/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/><br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2009 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2009. | <a href="http://coder.cl/2009/12/source-code-optimization-in-c/">Permalink</a> | <a href="http://coder.cl/2009/12/source-code-optimization-in-c/#comments">One comment</a><br/>Post tags: <br/></small></p>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2009/12/source-code-optimization-in-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>java mutexes</title>
		<link>http://coder.cl/2009/12/java-mutexes/</link>
		<comments>http://coder.cl/2009/12/java-mutexes/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 11:25:27 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=548</guid>
		<description><![CDATA[Java synchronization is usually made through the synchronized keyword. Synchronized allow users to create a mutex around certain variable, class or method, where a mutex allows concurrent access to it. By concurrent access we should understand access from multiple threads. If an operation is atomic, there one and only one process or thread executing it. [...]]]></description>
			<content:encoded><![CDATA[<p>Java synchronization is usually made through the <i>synchronized</i> keyword. Synchronized allow users to create a mutex around certain variable, class or method, where a mutex allows concurrent access to it. By concurrent access we should understand <i>access from multiple threads</i>. If an operation is <i>atomic</i>, there one and only one process or thread executing it. Then, mutex based operations are atomic.</p>
<p><span id="more-548"></span></p>
<p>In Java, thread synchronization made using the <i>synchronized</i> keyword can create a heavy &mdash; with a high number of threads &mdash; overhead in two main cases, the first one is when it is used on classes and the second one when it is used in methods. Then we must think a way to create small locks, mainly if we are using design patterns like <i>singletons</i>.</p>
<pre name="code" class="java">
/* BAD CASE 1, throws NullPointerException */
class BadMutexBaseClass {
	private static BadMutexBaseClass singletonInstance;
	public static BadMutexBaseClass getInstance(void) {
		synchronized (singletonInstance) {
			if (singletonInstance == null) {
				singletonInstance = new BadMutexBaseClass();
			}
			return singletonInstance;
		}
	}
}
</pre>
<pre name="code" class="java">
/* BAD CASE 2, heavy overhead */
class BadMutexBaseClass {
	private static BadMutexBaseClass singletonInstance;
	public synchronized static BadMutexBaseClass getInstance(void) {
		if (singletonInstance == null) {
			singletonInstance = new BadMutexBaseClass();
		}
		return singletonInstance;
	}
}
</pre>
<p>Both cases are wrong, we must use mutex object, without touching the singleton member and allowing the program to access the singleton atomically. We can use a basic <i>Object</i> instance to create the proper mutex.</p>
<pre name="code" class="java">
/* MUTEX BASED CASE */
class MutexBaseClass {
	private static Object mutex = new Object();
	private static MutexBaseClass singletonInstance;
	public static MutexBaseClass getInstance(void) {
		synchronized (mutex) { /* critical section */
			if (singletonInstance == null) {
				singletonInstance = new MutexBaseClass();
			}
			return singletonInstance;
		}
	}
}
</pre>
<p>By creating a <i>dummy</i> object, we can use it as mutex in our program. With a more low level perspective, this technique is similar to the one used with <a href="http://www.opengroup.org/onlinepubs/000095399/functions/pthread_mutex_lock.html">pthread_mutex_lock(P)</a> techniques while we are programming with threads in <b>C</b>. An interesting point is the fact that <i>non-blocking algorithms</i> are faster than locking ones. The mutex technique is a blocking technique. Non-blocking techniques, such as lock-free and obstruction-free, can allow the user to implement faster &mdash; but more complex &mdash; code.</p>
<p><b>GCC</b> has <a href="http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html">built-in atomic</a> operations to allow the creation of such code, like <i>CAS</i> operations, allowing the use of <i>lock-free</i> techniques. For example in the code bellow &mdash; which is using the __sync_bool_compare_and_swap atomic operation &mdash; we can see that the  <i>CAS</i> or <i>Compare and Swap</i> operation is made around the number of transactions with <i>old value</i> and <i>old value plus one</i>.</p>
<pre name="code" class="c">
do {
	old = vproc_shmem->vp_shmem_transaction_cnt;

	if (unlikely(old &lt; 0)) {
		if (vproc_shmem->vp_shmem_flags &amp; VPROC_SHMEM_EXITING) {
			_exit(0);
		} else {
			__crashreporter_info__ = &quot;Unbalanced: vproc_transaction_begin()&quot;;
		}
		abort();
	}
} while( !__sync_bool_compare_and_swap(&amp;vproc_shmem->vp_shmem_transaction_cnt, old, old + 1) );
</pre>
<p>I hope that Java will include kind that <i>atomic operations</i> to allow the use of non-blocking algorithms and more faster code and since I agree with the fact that we are entering the multi-core era&#8230;</p>



share this article at: 


	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fjava-mutexes%2F&amp;title=java%20mutexes&amp;source=coder+.+cl+system+programmer+%26amp%3B+web+developer&amp;summary=Java%20synchronization%20is%20usually%20made%20through%20the%20synchronized%20keyword.%20Synchronized%20allow%20users%20to%20create%20a%20mutex%20around%20certain%20variable%2C%20class%20or%20method%2C%20where%20a%20mutex%20allows%20concurrent%20access%20to%20it.%20By%20concurrent%20access%20we%20should%20understand%20access" title="LinkedIn"><img src="http://coder.cl/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fjava-mutexes%2F&amp;title=java%20mutexes&amp;notes=Java%20synchronization%20is%20usually%20made%20through%20the%20synchronized%20keyword.%20Synchronized%20allow%20users%20to%20create%20a%20mutex%20around%20certain%20variable%2C%20class%20or%20method%2C%20where%20a%20mutex%20allows%20concurrent%20access%20to%20it.%20By%20concurrent%20access%20we%20should%20understand%20access" title="del.icio.us"><img src="http://coder.cl/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fjava-mutexes%2F&amp;title=java%20mutexes&amp;bodytext=Java%20synchronization%20is%20usually%20made%20through%20the%20synchronized%20keyword.%20Synchronized%20allow%20users%20to%20create%20a%20mutex%20around%20certain%20variable%2C%20class%20or%20method%2C%20where%20a%20mutex%20allows%20concurrent%20access%20to%20it.%20By%20concurrent%20access%20we%20should%20understand%20access" title="Digg"><img src="http://coder.cl/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fjava-mutexes%2F&amp;title=java%20mutexes" title="Reddit"><img src="http://coder.cl/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fjava-mutexes%2F&amp;t=java%20mutexes" title="Facebook"><img src="http://coder.cl/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=java%20mutexes%20-%20http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fjava-mutexes%2F" title="Twitter"><img src="http://coder.cl/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fjava-mutexes%2F&amp;title=java%20mutexes&amp;annotation=Java%20synchronization%20is%20usually%20made%20through%20the%20synchronized%20keyword.%20Synchronized%20allow%20users%20to%20create%20a%20mutex%20around%20certain%20variable%2C%20class%20or%20method%2C%20where%20a%20mutex%20allows%20concurrent%20access%20to%20it.%20By%20concurrent%20access%20we%20should%20understand%20access" title="Google Bookmarks"><img src="http://coder.cl/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/><br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2009 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2009. | <a href="http://coder.cl/2009/12/java-mutexes/">Permalink</a> | <a href="http://coder.cl/2009/12/java-mutexes/#comments">No comment</a><br/>Post tags: <br/></small></p>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2009/12/java-mutexes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[ann] pyxser-1.3r-p1 [updated]</title>
		<link>http://coder.cl/2009/12/ann-pyxser-13r-p1/</link>
		<comments>http://coder.cl/2009/12/ann-pyxser-13r-p1/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 04:17:30 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[c]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[pyxser]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=533</guid>
		<description><![CDATA[Dear pyxser users, I&#8217;m pleased to announce that I&#8217;ve released pyxser-1.3r. The current ChangeLog for this release is as follows (Update: There was bug in the pyxser-1.3r release, it is patched and working in pyxser-1.3r-p1): 1.3r (2009.11.30): Daniel Molina Wegener &#60;dmw@coder.cl&#62; * pyxser_tools.c: Removed bug concerning deserialization of collection elements; pyxser now can handle extension [...]]]></description>
			<content:encoded><![CDATA[<p>Dear <a href="http://coder.cl/products/pyxser/">pyxser</a> users, I&#8217;m pleased to announce that I&#8217;ve released <b>pyxser-1.3r</b>. The current <i>ChangeLog</i> for this release is as follows (<strong>Update: There was bug in the pyxser-1.3r release, it is patched and working in pyxser-1.3r-p1</strong>):</p>
<p><span id="more-533"></span></p>
<pre name="code" class="ChangeLog">
1.3r (2009.11.30):

        Daniel Molina Wegener &lt;dmw@coder.cl&gt;
        * pyxser_tools.c: Removed bug concerning deserialization of
        collection elements; pyxser now can handle extension declared
        classes, such as boost::python ones --- thanks to the
        suggestions made by Daniel Filonik.
        * pyxser.c: Added /selector/ as optional argument used as
        callback to select object attributes to being serialized.
        * pyxser_string.c: Removed bug concerning unicode serialization.

        Thanks pyxser users for your feedback...
</pre>
<p>I want to bring special thanks to <i>Daniel Filonik</i> for his feedback.</p>
<blockquote><p>
First, thank you for a great Python module, I believe it has a lot of potential! I was never quite happy with pickle because of its cryptic format. The XML schema you use is so much nicer to read.
</p></blockquote>
<p><br/></p>
<h3>the selector callback</h3>
<p>An interesting feature requested by <i>Daniel Filonik</i> is to allow the user to <i>select</i> the object attributes to being serialized. So I&#8217;ve added the attribute selector callback as optional argument called <i>selector</i>. As he suggest:</p>
<pre name="code" class="cpp">
PyObject *selector = (PyObject *)NULL;
/* ... */
static char *kwlist[] = {&quot;obj&quot;, &quot;enc&quot;, &quot;depth&quot;, &quot;selector &quot;, NULL};
/* ... */
ok = PyArg_ParseTupleAndKeywords(args, keywds, &quot;Os|iO&quot;, kwlist,
                                 &amp;input, &amp;in_enc, &amp;py_depth, &amp;selector);
/* ... */
sargs.selector = &amp;selector;
</pre>
<p>Then, I use the <i>selector callback</i> in pyxser to obtain a list of the required attributes for the serialization process, and the callback is applied to the given object to being serialized.</p>
<pre name="code" class="cpp">
if (PYTHON_IS_NONE(select)) {
    lstItems = PyObject_GetAttrString(o, pyxser_attr_dict);
} else {
    /* selector must return NULL if there are errors... */
    arglist = Py_BuildValue(&quot;(O)&quot;, o);
    lstItems = PyObject_CallObject(select, arglist);
    Py_XDECREF(arglist);
}
</pre>
<p>And I&#8217;ve implemented the proper method to allow the instantiation of classes which are defined in Python extensions, such as <i>boost::python</i>, by replacing <i>PyInstance_NewRaw()</i> call by the default empty constructor for Python objects:</p>
<pre name="code" class="cpp">
#ifdef OLDCODE
	PyObject *ndict = (PyObject *)NULL;
	/* ... */
	ndict = PyDict_New();
	unser = PyInstance_NewRaw(ct, ndict);
	Py_XDECREF(ndict);
#else
    int ctrl = 0;
    unser = PyObject_CallFunctionObjArgs(ct, NULL);
    attr_name = pyxser_ExtractPropertyName(pyxser_xml_attr_name,
                                           ron);
#endif /* !OLDCODE */
</pre>
<p>I hope that <b>pyxser</b> is neat serializing extension and it is usefull for your transparent and interoperable communications with other platforms in Python.</p>



share this article at: 


	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fann-pyxser-13r-p1%2F&amp;title=%5Bann%5D%20pyxser-1.3r-p1%20%5Bupdated%5D&amp;source=coder+.+cl+system+programmer+%26amp%3B+web+developer&amp;summary=Dear%20pyxser%20users%2C%20I%27m%20pleased%20to%20announce%20that%20I%27ve%20released%20pyxser-1.3r.%20The%20current%20ChangeLog%20for%20this%20release%20is%20as%20follows%20%28Update%3A%20There%20was%20bug%20in%20the%20pyxser-1.3r%20release%2C%20it%20is%20patched%20and%20working%20in%20pyxser-1.3r-p1%29%3A%0D%0A%0D%0A%0D%0A1.3r%20%282009.11.30%29%3A%0D%0A" title="LinkedIn"><img src="http://coder.cl/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fann-pyxser-13r-p1%2F&amp;title=%5Bann%5D%20pyxser-1.3r-p1%20%5Bupdated%5D&amp;notes=Dear%20pyxser%20users%2C%20I%27m%20pleased%20to%20announce%20that%20I%27ve%20released%20pyxser-1.3r.%20The%20current%20ChangeLog%20for%20this%20release%20is%20as%20follows%20%28Update%3A%20There%20was%20bug%20in%20the%20pyxser-1.3r%20release%2C%20it%20is%20patched%20and%20working%20in%20pyxser-1.3r-p1%29%3A%0D%0A%0D%0A%0D%0A1.3r%20%282009.11.30%29%3A%0D%0A" title="del.icio.us"><img src="http://coder.cl/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fann-pyxser-13r-p1%2F&amp;title=%5Bann%5D%20pyxser-1.3r-p1%20%5Bupdated%5D&amp;bodytext=Dear%20pyxser%20users%2C%20I%27m%20pleased%20to%20announce%20that%20I%27ve%20released%20pyxser-1.3r.%20The%20current%20ChangeLog%20for%20this%20release%20is%20as%20follows%20%28Update%3A%20There%20was%20bug%20in%20the%20pyxser-1.3r%20release%2C%20it%20is%20patched%20and%20working%20in%20pyxser-1.3r-p1%29%3A%0D%0A%0D%0A%0D%0A1.3r%20%282009.11.30%29%3A%0D%0A" title="Digg"><img src="http://coder.cl/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fann-pyxser-13r-p1%2F&amp;title=%5Bann%5D%20pyxser-1.3r-p1%20%5Bupdated%5D" title="Reddit"><img src="http://coder.cl/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fann-pyxser-13r-p1%2F&amp;t=%5Bann%5D%20pyxser-1.3r-p1%20%5Bupdated%5D" title="Facebook"><img src="http://coder.cl/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=%5Bann%5D%20pyxser-1.3r-p1%20%5Bupdated%5D%20-%20http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fann-pyxser-13r-p1%2F" title="Twitter"><img src="http://coder.cl/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fcoder.cl%2F2009%2F12%2Fann-pyxser-13r-p1%2F&amp;title=%5Bann%5D%20pyxser-1.3r-p1%20%5Bupdated%5D&amp;annotation=Dear%20pyxser%20users%2C%20I%27m%20pleased%20to%20announce%20that%20I%27ve%20released%20pyxser-1.3r.%20The%20current%20ChangeLog%20for%20this%20release%20is%20as%20follows%20%28Update%3A%20There%20was%20bug%20in%20the%20pyxser-1.3r%20release%2C%20it%20is%20patched%20and%20working%20in%20pyxser-1.3r-p1%29%3A%0D%0A%0D%0A%0D%0A1.3r%20%282009.11.30%29%3A%0D%0A" title="Google Bookmarks"><img src="http://coder.cl/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/><br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2009 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2009. | <a href="http://coder.cl/2009/12/ann-pyxser-13r-p1/">Permalink</a> | <a href="http://coder.cl/2009/12/ann-pyxser-13r-p1/#comments">One comment</a><br/>Post tags: <br/></small></p>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2009/12/ann-pyxser-13r-p1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>caffeine ipc messaging facility</title>
		<link>http://coder.cl/2009/09/caffeine-ipc-messaging-facility/</link>
		<comments>http://coder.cl/2009/09/caffeine-ipc-messaging-facility/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 22:58:08 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[c]]></category>
		<category><![CDATA[caffeine]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=255</guid>
		<description><![CDATA[I&#8217;ve recently designed the IPC Messaging facility for caffeine. I&#8217;ve integrated the data packer module with the state machine module, plus the core IPC Messaging routines. The process itself is quite simple, you load a state machine, or build one on runtime, to process IPC messages, and you just define an IPC messaging service, which [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently designed the <i>IPC Messaging</i> facility for <a href='http://coder.cl/software/caffeine'>caffeine</a>. I&#8217;ve integrated the <i>data packer</i> module with the <i>state machine</i> module, plus the core <i>IPC Messaging</i> routines. The process itself is quite simple, you load a state machine, or build one on runtime, to process IPC messages, and you just define an <i>IPC messaging service</i>, which hold the proper information to allow your applications to work within those facilities. I&#8217;m thinking to use a similar approach to build <i>networking</i> support for <b>caffeine</b>. Since the IPC Messaging Facility is thinked to work on top of the <i>Process Pool</i> facility, you need to define statically the proper service structure on your applications, and instead of random IPC keys, you must use a static one for each Messaging service.</p>
<p><span id="more-255"></span></p>
<p></p>
<h3>service definition</h3>
<p>Each service is created with the <i>caf_msg_svc_t</i> structure. It holds a message seed of type <i>caf_msg_t</i>. The message seed has the IPC key, and related IPC data, and it is used as template for other messages sent by through this facility. Each session has a u_long identifier, which is processed by the master process in the <i>session_inc</i> member. And both <i>snd_inc</i> and <i>rcv_inc</i> keep tracking the sent and received messages respectively. The <i>machine</i> pointer holds the <i>state machine</i> pointer, and its type is defined by the type structure member. Each error on the process of managing the messaging facility is hold on the <i>errno_v</i>, which allows you to know which error is produced internally on those routines, so you can check for your operating system alerts. Each session is stored in the <i>deque</i> member <i>sessions</i>.</p>
<p><textarea name="code" class="c" cols="80" rows="43"><br />
/* this code is part of caffeine and is licensed under LGPLv3 */<br />
struct caf_msg_svc_s {<br />
    /** Seed and sample message */<br />
    caf_msg_t *seed;<br />
    /** Session identifier increment */<br />
    u_long session_inc;<br />
    /** Sender identifier increment */<br />
    u_long snd_inc;<br />
    /** Receiver identifier increment */<br />
    u_long rcv_inc;<br />
    /** List of sessions */<br />
    lstdl_t *sessions;<br />
    /** Processing Machine */<br />
    void *machine;<br />
    /** Processing Machine Type */<br />
    caf_msg_svc_sm_t type;<br />
    /** The Packet parser using Data Packer @see caf_data_packer */<br />
    caf_packet_t *parser;<br />
    /** errno value for common operations */<br />
    int errno_v;<br />
};<br />
</textarea></p>
<p>The idea is to process each <i>session</i> &mdash; as list that is &mdash; through the <i>lstdl_map</i> function, which, which uses the <i>machine</i> structure member by passing processing session item to the packet parser by using the <i>caf_packet_parse_machine()</i> caffeine function, and then hold the parsed packet to next processing functions in the state machine. The only one state machine that can not be converted by caffeine from a normal state machine to a packet processing state machine is the <i>static</i> one, the others two machines, both the <i>plugable</i> and the <i>dynamic</i> one can be converted to packet processing ones. The difference between the state machines is the fact that the static is build on top of arrays, and this means that that each state in it would be made statically on compile time, the plugable one is created on runtime and is using a pointer instead of arrays, and the dynamic one uses a deque as state storage.</p>
<p></p>
<h3>session definition</h3>
<p>Each session has a pointer to its parent service, and it is assigned while it is created. This allows the state machines and service processing routines to setup and identify which packets can be received through the binding IPC keys. The IPC key is bounded to the <i>session_id</i> member, and the structure itself keeps tracking both sent and received packets count through the <i>snd_cnt</i> and <i>rcv_cnt</i> respectively. The <i>snd_id</i> and the <i>rcv_id</i> are both made to setup the sender and receiver identifiers, which both will be used as endpoints identifiers. The service will be kept receiving messages and it will identify its senders through the <i>snd_id</i> identifier in its sessions.</p>
<p><textarea name="code" class="c" cols="80" rows="43"><br />
/* this code is part of caffeine and is licensed under LGPLv3 */<br />
struct caf_msg_session_s {<br />
    /** Session identifier */<br />
    u_long session_id;<br />
    /** Sender identifier */<br />
    u_long snd_id;<br />
    /** Receiver identifier */<br />
    u_long rcv_id;<br />
    /** Messages sent counter */<br />
    u_long snd_cnt;<br />
    /** Messages received counter */<br />
    u_long rcv_cnt;<br />
    /** Session message size */<br />
    size_t sz;<br />
    /** Client PID */<br />
    pid_t client;<br />
    /** Server PID */<br />
    pid_t server;<br />
    /** Lock */<br />
    int locked;<br />
    /** Message storage */<br />
    caf_msg_t *msg;<br />
    /** Service holder */<br />
    caf_msg_svc_t *svc;<br />
};<br />
</textarea></p>
<p>On each created session, you must setup the <i>client pid_t</i> and the <i>server pid_t</i> for further use. Also the message size is setup when the machine is used though the parsing facility. Each time a session is being used, it is locked, through the lock member &mdash; yeah, I know, I&#8217;m using locking on it, but I&#8217;m thinking to change it by CAS operations &mdash; and the service member structure is used to hold data about the message template and useful information about the service. Since IPC communications are thinked to share small amounts of data, you can not setup messages which are too wide.</p>
<p>At the other side, the implementation is not completely finished but the initial algorithm is implemented. I will use it as initial algorithm to implement the networking facility implementation. As further works, I will implement ASN.1, XDR and SDXF binary formats to allow standardized data format processing for networking protocols. It will allow more interoperability with other systems. I know that there is a lot of work forward, but I&#8217;m going fine with my works on caffeine. Also, I&#8217;m not using text based data formats, such as JSON, YAML or XML, since those formats generate a huge overhead by processing them, and really is so hard to implement <i>thread safe text parsers</i>, and all my work on caffeine is &mdash; yet &mdash; <i>thread safe</i>. Since its conception caffeine is build with multicore in mind&#8230;</p>
<p></p>
<h3>processing model</h3>
<p>The processing model is quiet old, the use of state machines is. We can see them on device drivers, memory management, VFS implementations and a lot of examples more. You must worry on designing the proper packets for communicating your processes and write them through the caffeine facilities and plug those components. The steps for building an IPC messaging implementation through caffeine are as follows:</p>
<ol>
<li>Define a packet parser for your implementation.</li>
<li>Create the service in the master process.</li>
<li>Copy the service in each session on fork, keep it on the master process.</li>
<li>Begin processing the service sessions.</li>
</ol>
<p>Since it is planned as <i>thread safe</i> implementation &mdash; yet I must look at the <i>&quot;_r&quot;</i> suffixed POSIX and C99 functions to use &mdash; you can keep a thread working on the message processing. A similar model, but using lock-free and similar techniques is going to be implemented on the protocol stack for caffeine. And some other features will be applied on further works on it, always with multicore, distribution, parallelism and lock-free some other nice computing things in mind.</p>
<p>Honestly, I&#8217;m quiet anxious to implement the other features and enhance the current ones in caffeine. The main problem is time to develop it and since I have researched enough and good features for it, it keeps me more anxious&#8230;</p>



share this article at: 


	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F09%2Fcaffeine-ipc-messaging-facility%2F&amp;title=caffeine%20ipc%20messaging%20facility&amp;source=coder+.+cl+system+programmer+%26amp%3B+web+developer&amp;summary=I%27ve%20recently%20designed%20the%20IPC%20Messaging%20facility%20for%20caffeine.%20I%27ve%20integrated%20the%20data%20packer%20module%20with%20the%20state%20machine%20module%2C%20plus%20the%20core%20IPC%20Messaging%20routines.%20The%20process%20itself%20is%20quite%20simple%2C%20you%20load%20a%20state%20machine%2C%20or%20build%20one%20on%20" title="LinkedIn"><img src="http://coder.cl/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fcoder.cl%2F2009%2F09%2Fcaffeine-ipc-messaging-facility%2F&amp;title=caffeine%20ipc%20messaging%20facility&amp;notes=I%27ve%20recently%20designed%20the%20IPC%20Messaging%20facility%20for%20caffeine.%20I%27ve%20integrated%20the%20data%20packer%20module%20with%20the%20state%20machine%20module%2C%20plus%20the%20core%20IPC%20Messaging%20routines.%20The%20process%20itself%20is%20quite%20simple%2C%20you%20load%20a%20state%20machine%2C%20or%20build%20one%20on%20" title="del.icio.us"><img src="http://coder.cl/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F09%2Fcaffeine-ipc-messaging-facility%2F&amp;title=caffeine%20ipc%20messaging%20facility&amp;bodytext=I%27ve%20recently%20designed%20the%20IPC%20Messaging%20facility%20for%20caffeine.%20I%27ve%20integrated%20the%20data%20packer%20module%20with%20the%20state%20machine%20module%2C%20plus%20the%20core%20IPC%20Messaging%20routines.%20The%20process%20itself%20is%20quite%20simple%2C%20you%20load%20a%20state%20machine%2C%20or%20build%20one%20on%20" title="Digg"><img src="http://coder.cl/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fcoder.cl%2F2009%2F09%2Fcaffeine-ipc-messaging-facility%2F&amp;title=caffeine%20ipc%20messaging%20facility" title="Reddit"><img src="http://coder.cl/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fcoder.cl%2F2009%2F09%2Fcaffeine-ipc-messaging-facility%2F&amp;t=caffeine%20ipc%20messaging%20facility" title="Facebook"><img src="http://coder.cl/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=caffeine%20ipc%20messaging%20facility%20-%20http%3A%2F%2Fcoder.cl%2F2009%2F09%2Fcaffeine-ipc-messaging-facility%2F" title="Twitter"><img src="http://coder.cl/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fcoder.cl%2F2009%2F09%2Fcaffeine-ipc-messaging-facility%2F&amp;title=caffeine%20ipc%20messaging%20facility&amp;annotation=I%27ve%20recently%20designed%20the%20IPC%20Messaging%20facility%20for%20caffeine.%20I%27ve%20integrated%20the%20data%20packer%20module%20with%20the%20state%20machine%20module%2C%20plus%20the%20core%20IPC%20Messaging%20routines.%20The%20process%20itself%20is%20quite%20simple%2C%20you%20load%20a%20state%20machine%2C%20or%20build%20one%20on%20" title="Google Bookmarks"><img src="http://coder.cl/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/><br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2009 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2009. | <a href="http://coder.cl/2009/09/caffeine-ipc-messaging-facility/">Permalink</a> | <a href="http://coder.cl/2009/09/caffeine-ipc-messaging-facility/#comments">No comment</a><br/>Post tags: <br/></small></p>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2009/09/caffeine-ipc-messaging-facility/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Re: vmsplice() + SPLICE_F_GIFT flag ??</title>
		<link>http://coder.cl/2009/08/re-vmsplice-splice_f_gift-flag/</link>
		<comments>http://coder.cl/2009/08/re-vmsplice-splice_f_gift-flag/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 13:06:11 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[c]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=104</guid>
		<description><![CDATA[On the post from Eduardo Silva: &#34;vmsplice() + SPLICE_F_GIFT flag ??&#34;, he&#8217;s asking about the problem of EINVAL errno value on calling vmsplice(2) system call on Linux systems. does anybody know why the linux syscall vmsplice() doesn&#8217;t work with the SPLICE_F_GIFT flag ?, per manual page it should be supported but i get the following [...]]]></description>
			<content:encoded><![CDATA[<p><!--:en-->
<p>On the post from Eduardo Silva: <i>&quot;<a href="http://edsiper.linuxchile.cl/blog/?p=190">vmsplice() + SPLICE_F_GIFT flag ??</a>&quot;</i>, he&#8217;s asking about the problem of <b>EINVAL</b> errno value on calling <b>vmsplice(2)</b> system call on Linux systems.</p>
<blockquote><p>
does anybody know why the linux syscall vmsplice() doesn&#8217;t work with the SPLICE_F_GIFT flag ?, per manual page it should be supported but i get the following error:
</p></blockquote>
<p><!--:--><span id="more-104"></span><!--:en--></p>
<p>My answer is as follows &mdash; seems that the blog of Eduardo is cutting the paragraphs &mdash; is quiet simple, and I&#8217;m doing the reasoning as C programmer regarding the manual page, without looking at the code.</p>
<pre>
We have the next declaration:

long vmsplice(int fd, const struct iovec *iov,
unsigned long nr_segs, unsigned int flags);

According to the manual page, an EINVAL or "Invalid Argument"
error is generated in two cases:

1. The number of chunks to supply to the kernel as nr_segs
number of blocks is greater than IOV_MAX. If IOV_MAX &lt; nr_segs
EINVAL is thrown. Check for the value of IOV_MAX and nr_segs.

2. io_base addresses are not aligned in the iovec array:
If we have iovec[4] as:
iovec[0]->io_base equal to 0×080ed000;
iovec[1]->io_base equal to 0×080ee024; (aligned in 1024 bytes)
iovec[2]->io_base equal to 0×080ef048; (aligned in 1024 bytes)
iovec[3]->io_base equal to 0×080f0090; (aligned in 1048 bytes)*

The alignment of 1048 bytes differs from the base alignment of
1024 bytes, and EINVAL is thrown. You must ensure that the GIFT
blocks are aligned.
</pre>
<p>The complete explanation on the answer can redacted in a few lines. The declaration of the <b>vmsplice(2)</b> system call receives a file descriptor <i>fd</i>, an array of iovec structures <i>iov</i>, the number of iovec structures in the array <i>nr_segs</i> and the flags which are passed to the system call. The subject is the <b>EINVAL</b>, aka &#8220;Invalid Argument&#8221; errno value. For the first instance we have that nr_segs, or <i>number of segments</i> argument, can not be greater than IOV_MAX. If it is greater than this value, the EINVAL errrno value is raised. The number of segments is limited to IOV_MAX, we can not <i>gift</i> more segments than IOV_MAX permits. The IOV_MAX macro is defined in the &lt;limits.h&gt; header.</p>
<p>The second issue with the <b>SPLICE_F_GIFT</b> flag, is the fact that memory chunks that we <i>gift</i> to the kernel must be a range of byte aligned bytes with the same size and continuous blocks. In the example we have three continuous blocks of 1024 bytes, but the last block, the 4th of them, is aligned at the byte 1048 with a hole of 24 bytes between the two last blocks. This will cause <b>EINVAL</b> errno value to be raised. Other interesting case, are blocks of different size, they also must be byte aligned. In other case, one byte of difference in the memory alignment, will cause the <b>EINVAL</b> errno value to be raised.</p>
<p>The <b>EBADF</b> errno value is also interesting. You must create a pipe through <b>pipe(2)</b> or <b>socketpair(2)</b> system calls or the <b>popen(3)</b> C library routine. The file descriptor that those functions returns must be passed to the <b>vmsplice(2)</b> system call. The file descriptor <i>fd</i> must refer to a pipe. Finally on success, the system call returns the number of bytes transferred.</p>
<p>Now I&#8217;m thinking on threaded applications. What happens to those memory blocks pointed by the iovec array when those bytes are protected to other threads through the <b>pthread_key_create(P)</b> system call on Linux systems?. This may be an interesting subject to study. I think that I can discover interesting things on key implementation on POSIX threads on Linux systems, mainly because the Linux kernel do not have a separate implementation for threads. For the Linux kernel, everything is a procces, even if it is a user process or a process thread. I think that this issue, in conjunction with the <i>O(1)</i> Linux scheduler will be the matter for my next studying chapter.</p>
<p><!--:--></p>



share this article at: 


	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Fre-vmsplice-splice_f_gift-flag%2F&amp;title=Re%3A%20vmsplice%28%29%20%2B%20SPLICE_F_GIFT%20flag%20%3F%3F&amp;source=coder+.+cl+system+programmer+%26amp%3B+web+developer&amp;summary=On%20the%20post%20from%20Eduardo%20Silva%3A%20%26quot%3Bvmsplice%28%29%20%2B%20SPLICE_F_GIFT%20flag%20%3F%3F%26quot%3B%2C%20he%27s%20asking%20about%20the%20problem%20of%20EINVAL%20errno%20value%20on%20calling%20vmsplice%282%29%20system%20call%20on%20Linux%20systems.%0D%0A%0D%0A%0D%0Adoes%20anybody%20know%20why%20the%20linux%20syscall%20vmsplice%28%29%20doesn%27t%20w" title="LinkedIn"><img src="http://coder.cl/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Fre-vmsplice-splice_f_gift-flag%2F&amp;title=Re%3A%20vmsplice%28%29%20%2B%20SPLICE_F_GIFT%20flag%20%3F%3F&amp;notes=On%20the%20post%20from%20Eduardo%20Silva%3A%20%26quot%3Bvmsplice%28%29%20%2B%20SPLICE_F_GIFT%20flag%20%3F%3F%26quot%3B%2C%20he%27s%20asking%20about%20the%20problem%20of%20EINVAL%20errno%20value%20on%20calling%20vmsplice%282%29%20system%20call%20on%20Linux%20systems.%0D%0A%0D%0A%0D%0Adoes%20anybody%20know%20why%20the%20linux%20syscall%20vmsplice%28%29%20doesn%27t%20w" title="del.icio.us"><img src="http://coder.cl/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Fre-vmsplice-splice_f_gift-flag%2F&amp;title=Re%3A%20vmsplice%28%29%20%2B%20SPLICE_F_GIFT%20flag%20%3F%3F&amp;bodytext=On%20the%20post%20from%20Eduardo%20Silva%3A%20%26quot%3Bvmsplice%28%29%20%2B%20SPLICE_F_GIFT%20flag%20%3F%3F%26quot%3B%2C%20he%27s%20asking%20about%20the%20problem%20of%20EINVAL%20errno%20value%20on%20calling%20vmsplice%282%29%20system%20call%20on%20Linux%20systems.%0D%0A%0D%0A%0D%0Adoes%20anybody%20know%20why%20the%20linux%20syscall%20vmsplice%28%29%20doesn%27t%20w" title="Digg"><img src="http://coder.cl/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Fre-vmsplice-splice_f_gift-flag%2F&amp;title=Re%3A%20vmsplice%28%29%20%2B%20SPLICE_F_GIFT%20flag%20%3F%3F" title="Reddit"><img src="http://coder.cl/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Fre-vmsplice-splice_f_gift-flag%2F&amp;t=Re%3A%20vmsplice%28%29%20%2B%20SPLICE_F_GIFT%20flag%20%3F%3F" title="Facebook"><img src="http://coder.cl/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Re%3A%20vmsplice%28%29%20%2B%20SPLICE_F_GIFT%20flag%20%3F%3F%20-%20http%3A%2F%2Fcoder.cl%2F2009%2F08%2Fre-vmsplice-splice_f_gift-flag%2F" title="Twitter"><img src="http://coder.cl/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Fre-vmsplice-splice_f_gift-flag%2F&amp;title=Re%3A%20vmsplice%28%29%20%2B%20SPLICE_F_GIFT%20flag%20%3F%3F&amp;annotation=On%20the%20post%20from%20Eduardo%20Silva%3A%20%26quot%3Bvmsplice%28%29%20%2B%20SPLICE_F_GIFT%20flag%20%3F%3F%26quot%3B%2C%20he%27s%20asking%20about%20the%20problem%20of%20EINVAL%20errno%20value%20on%20calling%20vmsplice%282%29%20system%20call%20on%20Linux%20systems.%0D%0A%0D%0A%0D%0Adoes%20anybody%20know%20why%20the%20linux%20syscall%20vmsplice%28%29%20doesn%27t%20w" title="Google Bookmarks"><img src="http://coder.cl/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/><br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2009 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2009. | <a href="http://coder.cl/2009/08/re-vmsplice-splice_f_gift-flag/">Permalink</a> | <a href="http://coder.cl/2009/08/re-vmsplice-splice_f_gift-flag/#comments">2 comments</a><br/>Post tags: <br/></small></p>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2009/08/re-vmsplice-splice_f_gift-flag/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>pyxser 1.2 release</title>
		<link>http://coder.cl/2009/08/pyxser-1-2-release/</link>
		<comments>http://coder.cl/2009/08/pyxser-1-2-release/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 17:27:55 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[c]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[pyxser]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=94</guid>
		<description><![CDATA[Today I&#8217;ve released pyxser-1.2r my Python Object to XML serializer/deserializer. To get more information about this project, visit the pyxser web page. This release has with byte string encoding for Unicode strings. This means that all Unicode strings are serialized in a human readable form, and also a better form to use pyxser with other [...]]]></description>
			<content:encoded><![CDATA[<p><!--:en-->
<p>Today I&#8217;ve released <b>pyxser-1.2r</b> my Python Object to XML serializer/deserializer. To get more information about this project, visit <a href="http://coder.cl/software/pyxser/">the pyxser web page</a>. This release has with byte string encoding for Unicode strings. This means that all Unicode strings are serialized in a human readable form, and also a better form to use pyxser with other platforms, since the encoding regards a better interoperability with byte encoded string handlers.</p>
<p><!--:--><span id="more-94"></span><!--:en--></p>
<p>Another interesting issue, is the fact that the source code is more ordered and it was refactored to get better reading on it. The disadvantage is that pyxser still is using the indirect recursion to serialize certain objects. I hope that it will change in a near future, but it do not harm the stack, because it is using pointer as parameters and not enough bytes to cause a stack overflow.</p>
<p>useful links for pyxser:</p>
<ul>
<li><a href="http://coder.cl/software/pyxser/">pyxser home page</a></li>
<li><a href="http://sourceforge.net/projects/pyxser/">sourceforge project hosting</a></li>
<li><a href="http://pypi.python.org/pypi?:action=3Ddisplay&amp;name=3Dpyxser&amp;version=">pypi entry</a></li>
</ul>
<p>I you want to participate, just mail me <img src='http://coder.cl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><!--:--></p>



share this article at: 


	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Fpyxser-1-2-release%2F&amp;title=pyxser%201.2%20release&amp;source=coder+.+cl+system+programmer+%26amp%3B+web+developer&amp;summary=Today%20I%27ve%20released%20pyxser-1.2r%20my%20Python%20Object%20to%20XML%20serializer%2Fdeserializer.%20To%20get%20more%20information%20about%20this%20project%2C%20visit%20the%20pyxser%20web%20page.%20This%20release%20has%20with%20byte%20string%20encoding%20for%20Unicode%20strings.%20This%20means%20that%20all%20Unicode%20string" title="LinkedIn"><img src="http://coder.cl/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Fpyxser-1-2-release%2F&amp;title=pyxser%201.2%20release&amp;notes=Today%20I%27ve%20released%20pyxser-1.2r%20my%20Python%20Object%20to%20XML%20serializer%2Fdeserializer.%20To%20get%20more%20information%20about%20this%20project%2C%20visit%20the%20pyxser%20web%20page.%20This%20release%20has%20with%20byte%20string%20encoding%20for%20Unicode%20strings.%20This%20means%20that%20all%20Unicode%20string" title="del.icio.us"><img src="http://coder.cl/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Fpyxser-1-2-release%2F&amp;title=pyxser%201.2%20release&amp;bodytext=Today%20I%27ve%20released%20pyxser-1.2r%20my%20Python%20Object%20to%20XML%20serializer%2Fdeserializer.%20To%20get%20more%20information%20about%20this%20project%2C%20visit%20the%20pyxser%20web%20page.%20This%20release%20has%20with%20byte%20string%20encoding%20for%20Unicode%20strings.%20This%20means%20that%20all%20Unicode%20string" title="Digg"><img src="http://coder.cl/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Fpyxser-1-2-release%2F&amp;title=pyxser%201.2%20release" title="Reddit"><img src="http://coder.cl/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Fpyxser-1-2-release%2F&amp;t=pyxser%201.2%20release" title="Facebook"><img src="http://coder.cl/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=pyxser%201.2%20release%20-%20http%3A%2F%2Fcoder.cl%2F2009%2F08%2Fpyxser-1-2-release%2F" title="Twitter"><img src="http://coder.cl/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Fpyxser-1-2-release%2F&amp;title=pyxser%201.2%20release&amp;annotation=Today%20I%27ve%20released%20pyxser-1.2r%20my%20Python%20Object%20to%20XML%20serializer%2Fdeserializer.%20To%20get%20more%20information%20about%20this%20project%2C%20visit%20the%20pyxser%20web%20page.%20This%20release%20has%20with%20byte%20string%20encoding%20for%20Unicode%20strings.%20This%20means%20that%20all%20Unicode%20string" title="Google Bookmarks"><img src="http://coder.cl/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/><br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2009 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2009. | <a href="http://coder.cl/2009/08/pyxser-1-2-release/">Permalink</a> | <a href="http://coder.cl/2009/08/pyxser-1-2-release/#comments">No comment</a><br/>Post tags: <br/></small></p>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2009/08/pyxser-1-2-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>interpreting valgrind messages</title>
		<link>http://coder.cl/2009/08/interpreting-valgrind-messages/</link>
		<comments>http://coder.cl/2009/08/interpreting-valgrind-messages/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 00:20:50 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[c]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=87</guid>
		<description><![CDATA[In other posts I&#8217;ve presented you some ways to detect memory leaks, conceptually rather than practically, but enough to understand them and solve those programming issues. Normally, valgrind messages. There are some posts about valgrind and well documented user guides, such as the guide written by Alex Ott. This article is about on how to [...]]]></description>
			<content:encoded><![CDATA[<p><!--:en-->
<p>In other posts I&#8217;ve presented you some ways to detect memory leaks, conceptually rather than practically, but enough to understand them and solve those programming issues. Normally, valgrind messages. There are some posts about valgrind and well documented user guides, such as <a href="http://xtalk.msk.su/~ott/en/writings/prog-checking/Valgrind.html">the guide</a> written by Alex Ott. This article is about on how to interpret <a href="http://www.valgrind.org/">valgrind</a> messages while you are using it as memory allocation debugger.</p>
<p><!--:--><span id="more-87"></span><!--:en--></p>
<p>First of all, I want to share a small script with the flags that I&#8217;m using with valgrind. Here is a small script which runs valgrind on the given program and creates a log with the valgrind output. You can find the explanation on the flags in the Alex&#8217;s article and the valgrind documentation.</p>
<div style="text-align: center;">
<img src="http://coder.cl/uploads/2009/08/ivm-bug1.jpg" border="0" alt="bug..." />
</div>
<pre name="code" class="bash" cols="80" rows="43">
#!/bin/bash

if test &quot;$#&quot; &quot;&lt;&quot; &quot;1&quot;; then
    echo &quot;$0: too few arguments&quot;
    exit 1
fi

VLG=`which valgrind`
VLG_LOG=`basename $PWD`
VLG_LOG=&quot;log.$VLG_LOG&quot;
VLG_OPTS=&quot;$VLG_OPTS --verbose&quot;
VLG_OPTS=&quot;$VLG_OPTS --trace-children=yes&quot;
VLG_OPTS=&quot;$VLG_OPTS --track-fds=yes&quot;
VLG_OPTS=&quot;$VLG_OPTS --run-libc-freeres=yes&quot;
VLG_OPTS=&quot;$VLG_OPTS --logfile-fd=1&quot;
VLG_OPTS=&quot;$VLG_OPTS --num-callers=100&quot;
VLG_OPTS=&quot;$VLG_OPTS --error-limit=no&quot;
VLG_OPTS=&quot;$VLG_OPTS --show-below-main=yes&quot;
VLG_OPTS=&quot;$VLG_OPTS --pointercheck=yes&quot;
VLG_OPTS=&quot;$VLG_OPTS --demangle=yes&quot;
VLG_OPTS=&quot;$VLG_OPTS --leak-check=yes&quot;

export VLG VLG_LOG VALGRIND_OPTS

if test -r &quot;$VLG_LOG&quot;; then
        echo &quot;$0: removing $VLG_LOG&quot;
        rm -f -v &quot;$VLG_LOG&quot;
fi
$VLG $VLG_OPTS $* 2&gt;&amp;1 | tee &quot;$VLG_LOG&quot;
</pre>
<p>This <a href="http://en.wikipedia.org/wiki/Shell_script">shell script</a> the call to valgrind &mdash; IMO &mdash; with the best options that some programs can have to debug them. This command line will generate a large trace on your command and as I&#8217;ve posted in a <a href="http://coder.cl/2009/07/19/foreign-system-call-simulations-on-freebsd/">previous topic</a>, valgrind replaces the <i>allocation system calls</i> with his own group of system calls, wrapping the original ones, just track those calls.</p>
<p></p>
<h3>invalid read of size <i>nnnn</i></h3>
<div style="text-align: center;">
<img src="http://coder.cl/uploads/2009/08/ivm-bug2.jpg" border="0" alt="bug..." />
</div>
<p>Your pointer arithmetics are bad. Yes, this message means that the program is accessing an invalid address by reading <i>nnnn</i> bytes from it. The code bellow &mdash; that seems to be ridiculous, but is not different that the error that you have in your code &mdash; would throw this message.</p>
<pre name="code" class="c" cols="80" rows="43">
#include &lt;stdio.h&gt;
int
main (int c, char **argv) {
    char test[] = &quot;hola mundo!&quot;;
    printf (&quot;%s\n&quot;, (char *)(test + 20));
    return 0;
}
</pre>
<p></p>
<p>The message obtained is as follows.</p>
<pre><code>
==22111== 1 errors in context 1 of 1:
==22111== Invalid read of size 1
==22111==    by 0x3010A4E0: vfprintf (in /lib/libc.so.6)
==22111==    by 0x300F6B2F: printf (in /lib/libc.so.6)
==22111==    by 0x8048571: main (test-invalid-read.c:11)
</code></pre>
<p>As you, see in the backtrace, the part where it reaches the invalid address is inside the <b>printf(3)</b> function, but the previous step is on the <i>line 11</i> of the file <i>test-invalid-read.c</i>.</p>
<p></p>
<h3>use of uninitialised value of size <i>nnnn</i></h3>
<div style="text-align: center;">
<img src="http://coder.cl/uploads/2009/08/ivm-bug3.jpg" border="0" alt="bug..." />
</div>
<p>By default, there is no automatic variable initialization for certain kinds of variables, all depends on the compiler implementation and the <a href="http://es.wikipedia.org/wiki/Lenguaje_de_programación_C#C99">C99</a> standard reveals it as undefined behavior. Since that condition, is required that you initialize all your variables to ensure code portability.</p>
<pre name="code" class="c" cols="80" rows="43">
#include &lt;string.h&gt;
#include &lt;stdio.h&gt;

int
main (int c, char **argv) {
    char *tst;
    printf (&quot;%s\n&quot;, tst);
    return 0;
}
</pre>
<p>The code above will produce the next error messages on valgrind.</p>
<pre><code>
==22309== 1 errors in context 1 of 6:
==22309== Use of uninitialised value of size 4
==22309==    at 0x30039DC0: memcpy (in /usr/local/lib/valgrind/vgpreload_memcheck.so)
==22309==    by 0x3010A4E0: vfprintf (in /lib/libc.so.6)
==22309==    by 0x300F6B2F: printf (in /lib/libc.so.6)
==22309==    by 0x804854B: main (test-invalid-read.c:8)
==22309==
==22309== 1 errors in context 2 of 6:
==22309== Conditional jump or move depends on uninitialised value(s)
==22309==    at 0x30039DAF: memcpy (in /usr/local/lib/valgrind/vgpreload_memcheck.so)
==22309==    by 0x3010A4E0: vfprintf (in /lib/libc.so.6)
==22309==    by 0x300F6B2F: printf (in /lib/libc.so.6)
==22309==    by 0x804854B: main (test-invalid-read.c:8)
</code></pre>
<p>Both errors are pointing to the same programming error. The variable <i>tst</i> was not initialized, and then you operate &mdash; and what makes one of the most ugliest errors on programming &mdash; using it as address reference. Also, by default <i>gcc</i> has automatic initialization of those pointers to <b>null</b>, and then you get <a href="http://qconlondon.com/london-2009/presentation/Null+References:+The+Billion+Dollar+Mistake"><i>&quot;Null References: The Billion Dollar Mistake&quot;</i></a> pointed by <a href="http://en.wikipedia.org/wiki/Tony_Hoare">Tony Hoare</a>. Remember that variable initialization is an undefined behavior according to the current C standard. Reference verification and initialization is an important task, recently was <a href="http://bertrandmeyer.com/tag/void-safety/">announced</a> a new version of <a href="http://en.wikipedia.org/wiki/Eiffel_(programming_language)">Eiffel</a> &mdash; a pure object oriented paradigm based language &mdash; that is <a href="http://docs.eiffel.com/sites/default/files/void-safe-eiffel.pdf">avoiding null deferencing</a>.</p>
<p></p>
<h3>process terminating with default action of signal <i>nn</i> (<i>SIGNAME</i>): dumping core</h3>
<div style="text-align: center;">
<img src="http://coder.cl/uploads/2009/08/ivm-bug4.jpg" border="0" alt="bug..." />
</div>
<p>Here the valgrind execution stops. Why? the program receives a <a href="http://en.wikipedia.org/wiki/Signal_(computing)">signal</a> and is terminated by the operating system. Take a look on the <b>signal(3)</b> manual page for more details.</p>
<p>The operating system generates a <a href="http://en.wikipedia.org/wiki/Core_file">core file</a>, from where you can get the proper information about the crashing instruction. All depends on the signal that the program was catching, a <tt>SIGBUS</tt> or <i>bus error</i>, means that you are writing bytes to wrong address. The code bellow shows that <i>bug</i>.</p>
<pre name="code" class="c" cols="80" rows="43">
#include &lt;string.h&gt;
#include &lt;stdio.h&gt;

int
main (int c, char **argv) {
    char tst[10];
    const char hl[] = &quot;hola mundo!&quot;;
    memset (tst, 0, sizeof(tst));
    memcpy (tst, hl, strlen(hl) + 1);
    return 0;
}
</pre>
<p>The <b>memset(3)</b> instruction sets the memory buffer pointed by <i>tst</i> to zero and it is OK. The size of <i>tst</i> is known, and since the operator <i>sizeof</i> is a compile time operator, there is no problem. If tst is a pointer instead of an array of bytes &mdash; I mean <i>&quot;char *tst&quot;</i> declaration &mdash; we can&#8217;t use <i>sizeof</i> and using it is like to get <i>sizeof(NULL)</i> &mdash; have noticed that every pointer has the same size?. If we <a href="http://www.gnu.org/software/gdb/documentation/">extract the backtrace from the core file</a>, we can reach the line of code which have the error. Depending on the signal, we can reach different kinds of errors, you must read your system documentation to know to what specific error refers it.</p>
<p></p>
<h3>other valgrind errors</h3>
<div style="text-align: center;">
<img src="http://coder.cl/uploads/2009/08/ivm-bug5.jpg" border="0" alt="bug..." />
</div>
<p>Depending on your operating system implementation, other errors can occur, if there is no proper memory protection. For example, you can have a <i>conditional jump</i> error and then an <i>invalid write</i> error. If you mix both of them and the system is not capable to protect itself of those errors, valgrind will report them. In other case, the proper <i>signal</i> will be thrown to your process and possibly a core file will be generated, then you must use the traditional debugging techniques to reach the <a href="http://en.wikipedia.org/wiki/Software_bug">bug</a>.</p>
<p></p>
<h3>conclusion</h3>
<p>You must consider learning <a href="http://en.wikipedia.org/wiki/Assembly_language">assembly language</a> and <a href="http://en.wikipedia.org/wiki/Computer_architecture">computer architecture</a> if you want to work at this level. Nowdays, by <i>C programming</i> most people understand a <i>low level</i> programming. By the years that I was studying, <i>C programming</i> was just another <i>high level language</i>, and I got the basics of programming on it, but just before I was introduced to it by reading some books &mdash; about 5 to 7 books on <i>C programming</i> &mdash; I was capable to build stronger programs.</p>
<p>Everything is important on <i>C programming</i>, from the basic techniques to complex data structures and algorithms. Most operating systems and user interfaces are made with <b>C</b> as the main programming language and also with <b>C++</b>. The applications of this language are not only applied to low level tasks. There are many programs implementing their algorithms in C and assembler to reach optimal performance, just look at <a href="http://math-atlas.sourceforge.net/">ATLAS</a>, <a href="http://www.netlib.org/blas/">BLAS</a> and some other interesting projects.</p>
<p><!--:--></p>



share this article at: 


	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Finterpreting-valgrind-messages%2F&amp;title=interpreting%20valgrind%20messages&amp;source=coder+.+cl+system+programmer+%26amp%3B+web+developer&amp;summary=In%20other%20posts%20I%27ve%20presented%20you%20some%20ways%20to%20detect%20memory%20leaks%2C%20conceptually%20rather%20than%20practically%2C%20but%20enough%20to%20understand%20them%20and%20solve%20those%20programming%20issues.%20Normally%2C%20valgrind%20messages.%20There%20are%20some%20posts%20about%20valgrind%20and%20well%20docu" title="LinkedIn"><img src="http://coder.cl/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Finterpreting-valgrind-messages%2F&amp;title=interpreting%20valgrind%20messages&amp;notes=In%20other%20posts%20I%27ve%20presented%20you%20some%20ways%20to%20detect%20memory%20leaks%2C%20conceptually%20rather%20than%20practically%2C%20but%20enough%20to%20understand%20them%20and%20solve%20those%20programming%20issues.%20Normally%2C%20valgrind%20messages.%20There%20are%20some%20posts%20about%20valgrind%20and%20well%20docu" title="del.icio.us"><img src="http://coder.cl/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Finterpreting-valgrind-messages%2F&amp;title=interpreting%20valgrind%20messages&amp;bodytext=In%20other%20posts%20I%27ve%20presented%20you%20some%20ways%20to%20detect%20memory%20leaks%2C%20conceptually%20rather%20than%20practically%2C%20but%20enough%20to%20understand%20them%20and%20solve%20those%20programming%20issues.%20Normally%2C%20valgrind%20messages.%20There%20are%20some%20posts%20about%20valgrind%20and%20well%20docu" title="Digg"><img src="http://coder.cl/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Finterpreting-valgrind-messages%2F&amp;title=interpreting%20valgrind%20messages" title="Reddit"><img src="http://coder.cl/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Finterpreting-valgrind-messages%2F&amp;t=interpreting%20valgrind%20messages" title="Facebook"><img src="http://coder.cl/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=interpreting%20valgrind%20messages%20-%20http%3A%2F%2Fcoder.cl%2F2009%2F08%2Finterpreting-valgrind-messages%2F" title="Twitter"><img src="http://coder.cl/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Finterpreting-valgrind-messages%2F&amp;title=interpreting%20valgrind%20messages&amp;annotation=In%20other%20posts%20I%27ve%20presented%20you%20some%20ways%20to%20detect%20memory%20leaks%2C%20conceptually%20rather%20than%20practically%2C%20but%20enough%20to%20understand%20them%20and%20solve%20those%20programming%20issues.%20Normally%2C%20valgrind%20messages.%20There%20are%20some%20posts%20about%20valgrind%20and%20well%20docu" title="Google Bookmarks"><img src="http://coder.cl/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/><br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2009 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2009. | <a href="http://coder.cl/2009/08/interpreting-valgrind-messages/">Permalink</a> | <a href="http://coder.cl/2009/08/interpreting-valgrind-messages/#comments">No comment</a><br/>Post tags: <br/></small></p>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2009/08/interpreting-valgrind-messages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>emacs and integrating ecb with cscope</title>
		<link>http://coder.cl/2009/08/emacs-and-integrating-ecb-with-cscope/</link>
		<comments>http://coder.cl/2009/08/emacs-and-integrating-ecb-with-cscope/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 17:54:45 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[c]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=85</guid>
		<description><![CDATA[Emacs is a powerful editor, the most powerful and the fastest programmable editor that I know. Emacs uses a Lisp dialect to create configurations, functions and modes. My favorite mode on Emacs is ECB, a powerful code browsing one, like many IDEs that I know. The difference is that ECB, do not does code indexing [...]]]></description>
			<content:encoded><![CDATA[<p><!--:en-->
<p><a href="http://www.gnu.org/software/emacs/">Emacs</a> is a powerful editor, the most powerful and the fastest <i>programmable editor</i> that I know. Emacs uses a <a href="http://en.wikipedia.org/wiki/Lisp">Lisp</a> dialect to create configurations, functions and <a href="http://tldp.org/HOWTO/Emacs-Beginner-HOWTO-3.html">modes</a>. My favorite mode on Emacs is <a href="http://ecb.sourceforge.net/">ECB</a>, a powerful code browsing one, like many IDEs that I know. The difference is that ECB, do not does code indexing until you configure it. For large C projects, I like to use external tools, but not <i>ctags</i> or <i>etags</i>, instead I prefer to use <a href="http://cscope.sourceforge.net/">cscope</a>. But you may ask <i>&quot;how can I integrate cscope and Emacs running the ECB mode?&quot;</i>. Well, in this post I will try to explain how to integrate both, cscope and Emacs.</p>
<p><!--:--><span id="more-85"></span><!--:en--></p>
<p>To know more about <a href="http://ecb.sourceforge.net/">ECB</a>, <a href="http://cedet.sourceforge.net/">CEDET</a> and related Emacs modes you can look some articles on the Internet, such as <a href="http://xtalk.msk.su/~ott/en/writings/emacs-devenv/EmacsCedet.html">&quot;A Gentle introduction to Cedet&quot;</a>, by Alex Ott. All of them would help a lot on configuring both, Emacs and ECB. Also the CEDET &mdash; the base package for ECB &mdash; and ECB itself are well documented.</p>
<p>The cscope mode that I&#8217;m using is the cscope mode contributed to the cscope source tree. It&#8217;s called <i>xcscope.el</i> and comes with a small cscope indexing script called <i>cscope-indexer</i>.</p>
<p>On ECB there is a <i>hook</i> that runs on every time that you change your working directory by using the directory navigator. The hook is called <i>ecb-after-directory-change-hook</i>. For my C and C++ projects I use various indentation settings, depending on the project that I&#8217;m working on. Then, I&#8217;ve created a <i>hook function</i> to <i>ecb-after-directory-change-hook</i> that sets the indenting style depending on the project that I&#8217;m working on. I&#8217;ve created the <i>dmw-ecb-directory-change-alist</i> variable, and it holds the project path and the indenting style to be applied to the project.</p>
<pre name="code" class="lisp" cols="80" rows="43">
(defvar dmw-ecb-directory-change-alist
  '((&quot;/work/dmw/c/caffeine&quot; caffeine-c-mode-hook)
    (&quot;/work/dmw/c/pyxser&quot; python-c-mode-hook)
    (&quot;/work/dmw/cxx/caffeine++&quot; caffeine-c++-mode-hook)
    (&quot;/work/dmw/cxx/qstats&quot; caffeine-c++-mode-hook)
    (&quot;/usr/src/sys&quot; knf)
    (&quot;/current/usr/src/sys&quot; knf)))
</pre>
<p></p>
<p>Then, I&#8217;ve created the hook to apply the indenting style.</p>
<pre name="code" class="lisp" cols="80" rows="43">
(defun dmw-ecb-directory-change-hook (dirold dirnew)
  (dolist (prji dmw-ecb-directory-change-alist)
    (let ((prj-name (first prji))
          (prj-match (string-match (concat (first prji) &quot;.*&quot;) dirnew)))
      (if (numberp prj-match)
          (progn
            ;; run hooks and functions related to
            ;; relative path matching on directory browsing
            (if (&gt;= prj-match 0)
                (dolist (h (last prji))
                  (run-hook-with-args h)))
            ;; run hooks and functions related to
            ;; full path matching on directory browsing
            (if (string= prj-name dirnew)
                (let ((newpath (concat dirnew &quot;/cscope.out&quot;))
                      (dirnew dirnew))
                  (progn
                    (setq cscope-database-file newpath
                          cscope-do-not-update-database nil
                          cscope-use-relative-path t
                          cscope-initial-directory dirnew)
                    (cscope-index-files dirnew))))
            )))))
</pre>
<p></p>
<p>What does this hook? See the documentation for <i>ecb-after-directory-change-hook</i>. On every directory change on the directory browsing window, the hook runs passing the old directory and the new directory as it&#8217;s arguments.</p>
<blockquote><p>
Hook which run directly after the selected directory has changed. This means not only after a click onto a directory in the directory-window of ECB but it means this hook runs always when the current directory changes regardless of the trigger of this change[...]
</p></blockquote>
<p>Then, when the hook matches my C and C++ projects, it pass by the <i>(if (>= prj-match 0)</i> expression and setup the indenting style configured in <i>dmw-ecb-directory-change-alist</i>. If the directory pass by the <i>(if (string= prj-name dirnew)</i> expression, then it runs the block related to the new directory bellow the if sentence. What it does? It sets the <i>cscope-database-file</i> variable to the <i>newpath</i> local variable, which have the value of the new directory concatenated with <i>&quot;/cscope.out&quot;</i>, also set some variable to ensure that the cscope database is updated, to enable cscope to use relative paths &mdash; this enables that cscope can lookup on different directories if the path changes &mdash; and set the initial directory to the new directory. Then, it runs the <i>cscope-indexer</i>. In few words, this hooks refresh the cscope database, and sets a permanent database location relative to the project that I&#8217;m working on.</p>
<p>Then, somewhere in your <i>.emacs</i> file, you should put your ECB variables as follows.</p>
<pre name="code" class="lisp" cols="80" rows="43">
(add-hook 'ecb-after-directory-change-hook
          'dmw-ecb-directory-change-hook)
</pre>
<p></p>
<p>Then, just setup the keybinding to use the cscope mode &mdash; I do a lot of C programming under emacs, that&#8217;s the reason that I&#8217;ve configured the keybinding as global, and not local to the C programming mode. Those keybindings bellow are a little bit tricky, you can search for C symbols just by typing <i>Ctrl + Meta + Down</i>. <img src='http://coder.cl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<pre name="code" class="lisp" cols="80" rows="43">
;; cscope keys
(define-key global-map [(control meta s)] 'cscope-set-initial-directory)
(define-key global-map [(control meta u)] 'cscope-unset-initial-directory)
(define-key global-map [(control meta f)] 'cscope-find-this-symbol)
(define-key global-map [(control meta g)] 'cscope-find-global-definition)
(define-key global-map [(control meta x)] 'cscope-find-global-definition-no-prompting)
(define-key global-map [(control meta m)] 'cscope-pop-mark)
(define-key global-map [(control meta n)] 'cscope-next-symbol)
(define-key global-map [(control meta N)] 'cscope-next-file)
(define-key global-map [(control meta p)] 'cscope-prev-symbol)
(define-key global-map [(control meta P)] 'cscope-prev-file)
(define-key global-map [(control meta c)] 'cscope-display-buffer)
(define-key global-map [(control meta C)] 'cscope-display-buffer-toggle)
</pre>
<p>I prefer <i>cscope</i> since it have the capability of searching symbols on many ways that other code indexer do not do, and large IDEs like eclipse with CDT gets leaked with large projects like the kernel sources &mdash; CDT takes just a few <i>hours</i> to index the complete kernel! &mdash; and since cscope is purely made in C and runs really fast.</p>
<p><!--:--></p>



share this article at: 


	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Femacs-and-integrating-ecb-with-cscope%2F&amp;title=emacs%20and%20integrating%20ecb%20with%20cscope&amp;source=coder+.+cl+system+programmer+%26amp%3B+web+developer&amp;summary=Emacs%20is%20a%20powerful%20editor%2C%20the%20most%20powerful%20and%20the%20fastest%20programmable%20editor%20that%20I%20know.%20Emacs%20uses%20a%20Lisp%20dialect%20to%20create%20configurations%2C%20functions%20and%20modes.%20My%20favorite%20mode%20on%20Emacs%20is%20ECB%2C%20a%20powerful%20code%20browsing%20one%2C%20like%20many%20IDEs%20tha" title="LinkedIn"><img src="http://coder.cl/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Femacs-and-integrating-ecb-with-cscope%2F&amp;title=emacs%20and%20integrating%20ecb%20with%20cscope&amp;notes=Emacs%20is%20a%20powerful%20editor%2C%20the%20most%20powerful%20and%20the%20fastest%20programmable%20editor%20that%20I%20know.%20Emacs%20uses%20a%20Lisp%20dialect%20to%20create%20configurations%2C%20functions%20and%20modes.%20My%20favorite%20mode%20on%20Emacs%20is%20ECB%2C%20a%20powerful%20code%20browsing%20one%2C%20like%20many%20IDEs%20tha" title="del.icio.us"><img src="http://coder.cl/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Femacs-and-integrating-ecb-with-cscope%2F&amp;title=emacs%20and%20integrating%20ecb%20with%20cscope&amp;bodytext=Emacs%20is%20a%20powerful%20editor%2C%20the%20most%20powerful%20and%20the%20fastest%20programmable%20editor%20that%20I%20know.%20Emacs%20uses%20a%20Lisp%20dialect%20to%20create%20configurations%2C%20functions%20and%20modes.%20My%20favorite%20mode%20on%20Emacs%20is%20ECB%2C%20a%20powerful%20code%20browsing%20one%2C%20like%20many%20IDEs%20tha" title="Digg"><img src="http://coder.cl/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Femacs-and-integrating-ecb-with-cscope%2F&amp;title=emacs%20and%20integrating%20ecb%20with%20cscope" title="Reddit"><img src="http://coder.cl/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Femacs-and-integrating-ecb-with-cscope%2F&amp;t=emacs%20and%20integrating%20ecb%20with%20cscope" title="Facebook"><img src="http://coder.cl/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=emacs%20and%20integrating%20ecb%20with%20cscope%20-%20http%3A%2F%2Fcoder.cl%2F2009%2F08%2Femacs-and-integrating-ecb-with-cscope%2F" title="Twitter"><img src="http://coder.cl/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fcoder.cl%2F2009%2F08%2Femacs-and-integrating-ecb-with-cscope%2F&amp;title=emacs%20and%20integrating%20ecb%20with%20cscope&amp;annotation=Emacs%20is%20a%20powerful%20editor%2C%20the%20most%20powerful%20and%20the%20fastest%20programmable%20editor%20that%20I%20know.%20Emacs%20uses%20a%20Lisp%20dialect%20to%20create%20configurations%2C%20functions%20and%20modes.%20My%20favorite%20mode%20on%20Emacs%20is%20ECB%2C%20a%20powerful%20code%20browsing%20one%2C%20like%20many%20IDEs%20tha" title="Google Bookmarks"><img src="http://coder.cl/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>


<br/><br/><br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2009 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2009. | <a href="http://coder.cl/2009/08/emacs-and-integrating-ecb-with-cscope/">Permalink</a> | <a href="http://coder.cl/2009/08/emacs-and-integrating-ecb-with-cscope/#comments">No comment</a><br/>Post tags: <br/></small></p>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2009/08/emacs-and-integrating-ecb-with-cscope/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
