<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>知識 : Knowledge</title>
	<atom:link href="http://govzlearnings.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://govzlearnings.wordpress.com</link>
	<description>Ang aking pinag-aaralang katarantaduhan :)</description>
	<lastBuildDate>Wed, 21 Oct 2009 07:27:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='govzlearnings.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>知識 : Knowledge</title>
		<link>http://govzlearnings.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://govzlearnings.wordpress.com/osd.xml" title="知識 : Knowledge" />
	<atom:link rel='hub' href='http://govzlearnings.wordpress.com/?pushpress=hub'/>
		<item>
		<title>File Descriptor Leaks</title>
		<link>http://govzlearnings.wordpress.com/2009/10/21/file-descriptor-leaks-part-1/</link>
		<comments>http://govzlearnings.wordpress.com/2009/10/21/file-descriptor-leaks-part-1/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 07:27:19 +0000</pubDate>
		<dc:creator>govz</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Embedded]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programmin]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://govzlearnings.wordpress.com/?p=294</guid>
		<description><![CDATA[Sorry to have kept you waiting. I had been very very busy recently. For starters, I am trying to complete parts of my creative writing exercise in govz.wordpress.com. Anyways, a number of people from other countries (USA,Romania,Korea,China,India) have been hitting this blog entry for quite some time now. When I checked this blog&#8217;s history, a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=294&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sorry to have kept you waiting. I had been very very busy recently. For starters, I am trying to complete parts of my creative writing exercise in <a title="LightBearer" href="http://govz.wordpress.com/2009/10/08/heretic-origins-lucifer-the-light-bearer/"><span style="color:#ffffff;">govz.wordpress.com</span></a>. Anyways, a number of people from other countries (USA,Romania,Korea,China,India)  have been hitting this blog entry for quite some time now. When I checked this blog&#8217;s history, a rather interesting set of questions or search filters were raised. Here are a few of them :</p>
<p style="padding-left:30px;"><span style="color:#ffffff;"><em>- &#8220;multi-thread file descriptor open close&#8221;<br />
- &#8220;fork / clone file descriptor&#8221;<br />
- &#8220;file descriptor leak debug&#8221;<br />
- &#8220;creating a file descriptor&#8221;<br />
- &#8220;how to reinitialize file descriptor c++&#8221;</em></span></p>
<p>In a way, I feel happy because, though this is an unsavory topic for most, it turns out this is also important to someone else, somewhere in the world. And by fate, they have somehow gained access to my blog and my mundane musings. I Just a want to repeat this again though, I am not and will never be a supreme-level engineer (the likes of<span style="color:#ffffff;"> </span><span style="color:#ffffff;"><strong><span style="color:#ffffff;"><a title="Dan Saks" href="http://www.dansaks.com/">Dan Saks</a>, <a title="Bjarne Stroustrup" href="http://en.wikipedia.org/wiki/Bjarne_Stroustrup"><span id="main" style="visibility:visible;"><span id="search" style="visibility:visible;">Bjarne Stroustrup</span></span></a>, <a title="Dennis Ritchie" href="http://en.wikipedia.org/wiki/Dennis_Ritchie">Dennis Ritchie</a>, <a title="Jon Postel" href="http://en.wikipedia.org/wiki/John_Postel">Jon B. Postel</a>, <a title="Paul Vixie" href="http://en.wikipedia.org/wiki/Paul_Vixie"> Paul Vixie</a>, <a title="Steve Wozniak" href="http://en.wikipedia.org/wiki/Steve_Wozniak">Steve W.</a></span> </strong></span>etc&#8230;), I am still a tremendous work in progress. Should you find my data suspect of flaw, please do leave a message. After all, ｌearning is fun when more heads come together. <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Also please take into consideration that the following discussion is</p>
<ol>
<li> limited to user-land level programming (meaning not within your Operating System or kernel)</li>
<li> limited to systems with kernels which have management mechanisms for all types of resources (i.e memory, descriptors, etc&#8230;).</li>
<li>limited to systems which frees all used resources on process termination.</li>
<li> limited to UNIX or UNIX-like systems. (Sorry,  windows developers. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  )</li>
</ol>
<p>Ok? <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  Here we go, <strong><span style="color:#ffffff;"><a title="Star Trek" href="http://en.wikipedia.org/wiki/Beam_me_up,_Scotty">&#8220;beam us up, scotty&#8221;</a></span></strong>. (Sorry, for a moment there, I missed, Kirk , Spock, Data, T-Pol and Janeway of Star Trek).</p>
<pre><code>
</code></pre>
<h4><span style="color:#ffffff;">I. File Descriptor Fundamentals</span></h4>
<p>Before we finally close the sample code of the <a title="Govz Learnings File Descriptor" href="http://govzlearnings.wordpress.com/2009/08/05/files-and-file-descriptors/">previous blog</a>, it is imperative that we are capable of understanding certain fundamentals about file descriptors.</p>
<p><strong>A. In the beginning, there was and is the trinity.</strong></p>
<p>Did you know that, when you start an ordinary program, you automatically open three file descriptors? These file descriptors are embedded within the streams are known to us, <span style="color:#ffffff;"><a title="Standard Streams" href="http://en.wikipedia.org/wiki/Standard_streams">as stdin (standard input), stdout (standard output), and stderr (standard error)</a></span>. In an ordinary process, these three streams automatically obtain file descriptor id 0, 1, and 2.</p>
<blockquote><p><span style="color:#ffffff;"><strong>So in a simple application, the maximum usable number of descriptors per process is equal to the process limit minus three.</strong></span></p></blockquote>
<p>Can you close them, yes certainly! &#8220;fclose(stdout)&#8221; closes the standard output. (We use fclose() because stdout is a stream or a FILE* data type.) It is pretty much a valid command. <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  However, once stdout is closed, &#8220;printf&#8221; or &#8220;cout&#8221; will practically be useless, and in some instances, calling stdout-related commands in an stdout-disabled environment MAY cause the crash of an application.</p>
<p>For daemon developers however, if ever you are working on a BSD environment, we can chose to close these three file descriptors by simply setting the &#8220;noclose&#8221; parameter to a non-zero value in the <span style="color:#ffffff;"><a title="BSD Daemon" href="http://www.manpagez.com/man/3/daemon/">&#8220;daemon()&#8221; </a></span>command. Using &#8220;daemon(noclose=1)&#8221; the system points the three streams&#8217; descriptor to &#8220;/dev/null&#8221;, causing all stdout-sent data to be sent safely to a NULL device.<span style="color:#ffffff;"> <a title="Linux Daemon" href="http://www-theorie.physik.unizh.ch/~dpotter/howto/daemonize">Linux daemon-izing </a></span>on the other hand, is quite a tedious task that involves &#8220;forking&#8221; and a lot of other stuff that will eventually re-direct or re-open the three basic streams to a &#8220;/dev/NULL&#8221;.</p>
<p><span style="color:#ffffff;"><a title="IO Redirection" href="http://en.wikipedia.org/wiki/Redirection_%28computing%29">&#8220;Redirection&#8221;</a></span> in this context means that your output or input, is redirected into another device (or a file for that matter) aside from your laptop or PC screen. This is the reason why in any UNIX or UNIX-like systems, executing   &#8220;ls -a &gt; temp.txt&#8221;  saves the result of the &#8220;ls -a&#8221; command to the file &#8220;temp.txt&#8221; . Anyways I just wanted to share some basic idea on IO redirection.</p>
<p><strong>B.  File Descriptor Acquisition Behavior</strong></p>
<p>As far as my experience can take me, commands that generate file descriptors include (but are not limited to : <span style="color:#ffffff;"><a title="Linux Open and Create" href="http://linux.die.net/man/2/open">open(), creat(), </a><a title="Linux fopen" href="http://linux.die.net/man/3/fopen">fopen(),   freopen()</a>,  <a title="BSD Socket" href="http://www.manpagez.com/man/2/socket/">socket(),</a> <a title="BSD Socket Pair" href="http://www.manpagez.com/man/2/socketpair/">socketpair()</a>, <a title="BSD accept" href="http://www.manpagez.com/man/2/accept/">accept()</a>, <a title="Linux Dup" href="http://linux.die.net/man/2/dup">dup(), dup2(),</a></span> and <span style="color:#ffffff;"><a title="BSD fcntl" href="http://www.manpagez.com/man/2/fcntl/">fcntl()</a></span>. Be warned though, that some commands may not be supported in Linux or other UNIX and BSD-flavors.  Also there may be other commands resulting to descriptor generation. My list only includes commands which I am aware of .</p>
<blockquote><p><strong><span style="color:#ffffff;">Now,  as I have said, once we execute any of these commands, a new file descriptor is created and naturally the maximum number of usable descriptors for the process (and the system as a whole) is lessened by 1.</span></strong></p></blockquote>
<p>In almost all of the platforms I have worked with, once we ask the system for a file descriptor, the system usually returns the lowest possible file descriptor. So in normal conditions, where the triumvir streams are not closed, the first file descriptor you will get to acquire will be 3. Or if in case you have daemonized-close-all it, the return value will be file descriptor &#8220;zero&#8221;.</p>
<p><strong>C. Forks, Clones and Virtual forks</strong></p>
<p>For those who have not yet had the experience of<a title="BSD fork" href="http://www.manpagez.com/man/2/fork/"> <span style="color:#ffffff;">&#8220;fork&#8221;ing</span></a>, <span style="color:#ffffff;"><a title="Virtual Fork" href="http://www.manpagez.com/man/2/vfork/">&#8220;vfork&#8221;ing</a></span>, and <span style="color:#ffffff;"><a title="Linux Clone" href="http://linux.die.net/man/2/clone">&#8220;clone&#8221;ing</a></span> then it is a privilege to welcome you to the world of process creation/duplication. Well, at the very least for C and C++. Be mindful again that the above commands may not be supported in your platform. And that threads and processes are entirely different in UNIX and UNIX-like systems. <strong><span style="color:#ffffff;">Anyways fork and other system calls of its kind, are called upon by one process, to create a new or child process.</span> </strong>Its purely assexual though. <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  There are rules and norms covering this &#8220;process forking&#8221; mechanism but I wont discuss them in detail here.  <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  There is only one thing I want to share though.</p>
<blockquote><p><strong><span style="color:#ffffff;">If a parent process, creates a child process via fork (or any of the above commands), the parent&#8217;s file descriptors are inherited by the child.</span></strong></p></blockquote>
<p>This is by design. But personally, I sometimes see this as an &#8220;inherited leak&#8221;.  In a simplistic diagram,  I would like to show you what happens after a child process is called :</p>
<pre><span style="font-size:small;">
                 ( P1 )
                    x -- start
                    |
      [fd1 = open("myfile.txt") = 3]
                    |
           [fd2 = socket() = 4]
                    |
           [fd3 = accept() = 5]
                    |                [child process shares descriptors 0-5]
        [create child :: fork()] - - - - - - - -&gt;   ( child P2 )
                    |                                    |
                    |		         [p2fd1 = open("myfile3.txt") = 6]
                    |                                    |
                    |                                    |
                    x                                    x
</span></pre>
<p>In the diagram above , after a fork() is executed, Process 2 starts and opens another file. In this case the resulting file descriptor for P2&#8242;s open() call, is 6 and not 3. Also if the same file like &#8220;myfile.txt&#8221; is opened again in the child process, depending on the settings of the parent&#8217;s &#8220;open()&#8221; call for &#8220;myfile.txt&#8221;, an error might occur. But anyways, my point is simple, child processes inherit their parent&#8217;s file descriptor table. (Actually this inheritance is useful in shell-command execution as it provides a method for &#8220;piping&#8221; data from the shell to another process.)</p>
<p>But if you have no plans whatsoever to use any of the parent&#8217;s file descriptors, you can use the <a title="close file descriptor" href="http://linux.die.net/man/2/close">&#8220;close()&#8221; </a>command in the child process to close specific file descriptors. Or better yet, you can use the <a title="closefrom" href="http://docs.sun.com/app/docs/doc/816-5168/closefrom-3c?a=view">&#8220;closefrom()&#8221;</a> command, to avoid having to loop the closing of opened descriptors.</p>
<p><strong>D. Process Transformation</strong></p>
<p>Did you know that you can transform processes? If you did not know that,  I welcome you yet again. More often than not, a &#8220;fork&#8221;-er,  an individual who forks his process, has one ultimate desire. He or she desires to execute a different command or program. Converting one process into another program, or process transformation, is done by calling the <span style="color:#ffffff;"><span style="color:#ffffff;"><a title="Execv and Execl" href="http://www.manpagez.com/man/3/execv/">&#8220;execv()&#8221; or &#8220;execl()&#8221;</a></span> </span>family of commands. Take a look at the diagram below. Try it out if you have a UNIX/UNIX-like system with you.</p>
<pre><span style="font-size:small;">
    ( P1 - system() )                       ( P2 - execv())
           x -- start                              x -- start
           |                                       |
           |                         [char *temp[2] = {"-a",NULL};]
           |                                       |
[printf("transforming.");]               [printf("transforming");]
           |                                       |
  [system("ls -a");]                    [execv("ls", temp);]
           |                                       |
 [printf("ls finished.");]           [printf("execv finished.");]
           |                                       |
           x end of program                        x end of program

</span></pre>
<p>I assure you 100% (provided execv has no error), you will never see the message &#8220;execv finished.&#8221; on your screen. Meaning P2 has been completely transformed. But in the <span style="color:#ffffff;"><a title="system()" href="http://linux.die.net/man/3/system">system() </a></span>command, the&#8221;ls&#8221;  is executed and then the parent process is continued. Making you see the &#8220;&#8221;ls -a finished.&#8221; message just after ls-a succeeds.</p>
<p><span style="color:#000000;"><span style="color:#888888;"><strong><span style="color:#ffffff;">But as this blog is not about process transformation<span style="color:#ffffff;">,</span></span></strong><span style="color:#ffffff;"><strong> I would just like to state  that even after process transformation, the file descriptor table data is persistent even after an execv() is called<span style="color:#ffffff;">.</span></strong></span></span><span style="color:#c0c0c0;"> </span></span>Simply put, by default, the file descriptors opened before the execv() call still exists in the transformed process.(This is the default behavior for most systems, and of course if the files were open() -ed with default file-flag settings.)</p>
<p>This however can be avoided by setting the necessary flags via, &#8220;fcntl()&#8221; command. Using &#8220;fcntl()&#8221;, set the opened file descriptor&#8217;s <a title="CLOSE ON EXEC" href="http://linux.die.net/man/2/fcntl"><span style="color:#ffffff;">close-on-exec flag (FD_CLOEXEC)</span> </a> just before you call execv(). With the close-on-exec flag enabled, the system automatically closes all descriptors in the process, whenever  an execv() or execl() is executed.</p>
<p><strong>E. Maxima &#8211; Maximum Descriptor Count</strong><br />
(I suddenly remembered my <a title="Derivatives" href="http://en.wikipedia.org/wiki/Maxima_and_minima">minima-maxima</a> derivative mathematics hahaha &#8230; collectively known as extrema.). Anyways, for almost all UNIX based systems, <span style="color:#ffffff;"><a title="Maximum Descriptor Count" href="http://linux.die.net/man/2/getdtablesize">getdtablesize()</a></span> is supported. If your program needs to know the maximum number of file descriptors a process can open at any time, then you can use the getdtablesize() function.</p>
<p>Remember though that if getdtablesize() is 32, it follows that the lowest possible descriptor you might get is zero and the highest descriptor value you will get is 31.</p>
<pre><code>
</code></pre>
<h4><span style="color:#888888;"><span style="color:#ffffff;">II. File Descriptor Theory Conclusion</span><br />
</span></h4>
<p>By now, I think the information above is enough for all of us to understand the holistic-overviewish-nature of file descriptors. This primer blog may not be complete but I am guessing this is enough to :</p>
<ul>
<li>Spark your curiosity</li>
</ul>
<ul>
<li>Create a semi-complete mental image of file / fd usage in programming</li>
</ul>
<ul>
<li>And hopefully in some parts I have made you aware of some of the different things you can do in C/C++ like process generation and process transformation.</li>
</ul>
<p>Within the next few days, I will upload my next blog, discussing my own file descriptor leak debugging techniques.</p>
<p>For the many C-developers out there, I wish you well. In a way, right now, Java seems to be taking over. But don&#8217;t worry, I think C and  C++ will ALWAYS be around. <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Good Day.</p>
<p><em>Up Next : File Descriptor Leak Debugging</em></p>
<p><a href="http://s03.flagcounter.com/more/S24B"><img src="http://s03.flagcounter.com/count/S24B/bg=050505/txt=FFFFFF/border=CC0411/columns=4/maxflags=20/viewers=Kind+Enough+People+Who+Visited/labels=1/" alt="free counters" border="0"></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/govzlearnings.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/govzlearnings.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/govzlearnings.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/govzlearnings.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/govzlearnings.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/govzlearnings.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/govzlearnings.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/govzlearnings.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/govzlearnings.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/govzlearnings.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/govzlearnings.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/govzlearnings.wordpress.com/294/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/govzlearnings.wordpress.com/294/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/govzlearnings.wordpress.com/294/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=294&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://govzlearnings.wordpress.com/2009/10/21/file-descriptor-leaks-part-1/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6511d1fc22b5bc066e094e6b59505f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">govz</media:title>
		</media:content>

		<media:content url="http://s03.flagcounter.com/count/S24B/bg=050505/txt=FFFFFF/border=CC0411/columns=4/maxflags=20/viewers=Kind+Enough+People+Who+Visited/labels=1/" medium="image">
			<media:title type="html">free counters</media:title>
		</media:content>
	</item>
		<item>
		<title>File Descriptors</title>
		<link>http://govzlearnings.wordpress.com/2009/08/05/files-and-file-descriptors/</link>
		<comments>http://govzlearnings.wordpress.com/2009/08/05/files-and-file-descriptors/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 13:54:28 +0000</pubDate>
		<dc:creator>govz</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Embedded]]></category>
		<category><![CDATA[Programmin]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://govzlearnings.wordpress.com/?p=200</guid>
		<description><![CDATA[Of the four I have stated in the previous blog, I want to discuss first, (if ever there will be a second, I don&#8217;t know yet.) file descriptor leaks. I would like to share with you (or as a note for myself in general), an experience of mine on this type of leak. For the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=200&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Of the four I have stated in the <span style="color:#ffffff;"><a title="OS Resource Leaks" href="http://govzlearnings.wordpress.com/2009/07/15/os-resource-leaks/">previous blog</a></span>, I want to discuss first, (if ever there will be a second, I don&#8217;t know yet.)<span style="color:#ffffff;"> <a title="File Descriptors" href="http://en.wikipedia.org/wiki/File_descriptor">file descriptor</a></span> leaks. I would like to share with you (or as a note for myself in general), an experience of mine on this type of leak. For the most part, I have written this blog so as not to forget what I have learned from the experience. I also wrote this in a way, to share some knowledge I have acquired over it.   <em>i.e the difficulty of file descriptor leak debugging, the techniques I employed to fix and determine it, and the tools I used</em>.  Plus some overall knowledge, I think I have acquired over a UNIX / Unix-like system.</p>
<pre><code>
</code></pre>
<h4><span style="color:#ffffff;">Files, what art thou?</span></h4>
<p>Files are the simplest forms of data storage. Of course, I think even those who don&#8217;t develop software are kinda familiar with this fact. But, (and it is a big BUT!) files are also a convenient and rudimentary method of signaling and/or synchronization. Developers like myself refer to this signaling mechanism famously as <a title="IPC - Inter Process Comunication" href="http://en.wikipedia.org/wiki/Inter-process_communication">IPC &#8211; Inter Process Commnunication</a>. For example, imagine two processes, Process1(P1) and Process2(P2). Let us say that before Process1 starts sending requests Process2 has to be ready.</p>
<p>P1 and P2&#8242;s synchronization mechanism can be simplistically described by the following :</p>
<pre><span style="font-size:small;">    ( P1 )                          ( P2 )
      x -- start                      x -- start
      |                               |
 [initialize]                    [initialize]
      |                               |
      |                      [resource preparation]
      |                               |
      |                              [b] --- announce readiness.
     [a]  wait 'til P2 ready          |
      |                               |
      |                      [wait for requests]
      |                               |
      x -- start sending              x
           requests to  P2</span></pre>
<p>True that with a simple libc::kill() command (yep, &#8220;kill&#8221; does not mean &#8220;terminate&#8221; all the time, my young friends.), P2&#8242;s existence can be checked, but the its state can never be determined (not unless P2 is synch-safe and has a complex signal handler in place). So in the above example, a file can be used for signaling/synchronization. P1 will routinely check for the existence of a certain file via <span style="color:#ffffff;">libc::stat()</span> or <span style="color:#ffffff;">libc::access()</span>, while P2 will be the one to create the file. So if we substitute<span style="color:#ffffff;"> <strong>[a] as &#8220;loop and sleep until the file /ipcs/process2_ready.dat exists&#8221;</strong></span> and<span style="color:#ffffff;"> <strong>[b] as &#8220;create /ipcs/process2_ready.dat until successful&#8221;</strong></span>, it makes a whole lot of sense right? Of course the flow has to be refined more though, but the gist is more or less like that.<span style="color:#ffffff;"> (Doubting Thomas : files are resident aren&#8217;t they? At next start-up, a false positive will occur at P1 since the file is still present.  <strong>answer : that my friend is a trick i have to teach later. </strong>).</span></p>
<pre><code>
</code></pre>
<h4><span style="color:#ffffff;">Files are everything.</span></h4>
<p>In Windows, this paradigm might not ring true. But you see, UNIX or UNIX-like Operating systems (FreeBSD, OpenBSD, Linux, etc&#8230;) have one simple yet fundamental precept. <span style="color:#ffffff;"><strong><span style="color:#ffffff;">&#8220;<span style="color:#ffffff;"><a title="Everything is a file" href="http://www.cs.bgu.ac.il/~arik/usail/concepts/filesystems/everything-is-a-file.html">Everything is a file.</a></span>&#8220;</span> </strong></span>(for Unix-like OS&#8217;es however, it is more like &#8220;Everything is almost a file.&#8221;) It follows too, that any UNIX based developer, has too be wary of each opened file descriptor one has in his process. File descriptors in the UNIX context is not just about &#8220;files&#8221; per se. Like what all those &#8220;better&#8221; guys tell you on the internet, in Unix/Unix-like systems, once you open a device, you have to acquire a file descriptor. When you <em>libc::fork()</em> a process or <em>libc::clone()</em> it, and use<em> libc::pipe()</em>, you use two file descriptors. For some though, this tidbit of knowledge may not be really something important, especially when multi-process-multi-thread operations are unnecessary. But for those who create &#8220;daemons&#8221; or &#8220;timing critical multi-process-multi-thread applications&#8221;, for a living, this piece of trivia might come in very useful.</p>
<pre><code>
</code></pre>
<h4><span style="color:#ffffff;">What then is a file descriptor?</span></h4>
<p>A file desriptor in all its simplicity is a numeric handle/value which represents a file you have opened. To put it in easy terms, a file descriptor is like an the Operating System&#8217;s (OS) translation of a very long file name. Let us take for example, the following file which has a name of :<br />
&#8211;&gt;  &#8220;C:\\directory1\directory2\iamaveryveryveryverydveryveryverylongfilename.txt&#8221;</p>
<p>In the OS layer however, once the above file is opened, file1 is merely the process&#8217; file descriptor : 3. Now wait a minute, why &#8220;3&#8243; and not zero or one? Later I will explain <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . For the moment take it as it is. <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The obnoxiously long file name is converted simply as file number : (3).  In C or C++ it can be done via the following line :</p>
<blockquote><p><strong><span style="color:#ffffff;">fd = open(&#8220;myfile.txt&#8221;, O_CREAT | O_WRONLY);  (C/C++)</span></strong></p></blockquote>
<p>Theoretically, libc::fopen() also does the same thing but the result of such a function is not really a file descriptor. libc::fopen() has a return type of <em>FILE *</em> but there is a way to retrieve its underlying file descriptor, use libc::fileno(). More on this later (when i can get back at it &#8230;. like 10 years from now.)</p>
<pre><code>
</code></pre>
<h4><span style="color:#ffffff;">So What&#8217;s with file opening?</span></h4>
<p>Though syntactically, file descriptor generation looks very simple, there are quite a few intricacies within the kernel / OS operation that goes along with it. The OS actually does a few stuff  during an &#8220;open()&#8221; call. Though I am unsure of the sequence, but in most Unix or Unix-like systems some of open()&#8217;s internal steps are the following :</p>
<p>1. OS checks the system limit of file descriptors and checks if it is full or not.<br />
2. OS checks the process&#8217; file descriptor table if it is full or not.<br />
3. OS retrieves the lowest free index in the process table.<br />
4. OS saves the data to the process table (<em>i.e. file name, file position, etc&#8230;</em>)<br />
5. OS returns the file descriptor to the calling function.</p>
<pre><code>
</code></pre>
<h4><span style="color:#ffffff;">Teaching By Example</span></h4>
<p>&#8220;That&#8217;s easy, for every file you open, you close it.&#8221; The rule is correct. However, the mechanism on how you close and open a file matters more than anything else. Let us analyze the following code. In what case do u think will a file descriptor leak happen? For this exercise, let us assume that the  <em>libc::close()</em> call never fails.</p>
<pre><span style="font-size:small;"><code>/*********************************************************/
/*    Created by      : Gauvin L. Repuspolo
/*    What is this    : File Descriptor Leak Example
/*    My Birthday     : 1977/02/21 [just goofing around]
/*********************************************************/
#include &lt;string.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;unistd.h&gt;
#include &lt;fcntl.h&gt;

#define SAMPLE_LAUGH   "hahahaha"
#define SAMPLE_CRY     "huhuhuhu"

int generic_fd = 0;

/****************************************************
/* name       : write_something
/* parameters : (input) is_laughing
/*              --&gt; &lt;= 0 - write SAMPLE_CRY
/*              --&gt; &gt;  0 - write SAMPLE_LAUGH
/* return     : on succes returns 0
/*            : on failure returns -1
/****************************************************/
int write_something(int is_laughing)
{
   int write_result =  -1;
   /* let us use a temporary pointer */
   const char *temp_ptr = (is_laughing &gt; 0) ? SAMPLE_LAUGH : SAMPLE_CRY;

   generic_fd = open("my_file.txt",O_CREAT | O_RDWR | O_APPEND);
   if (generic_fd &lt; 0) {
      return write_result;
   }
   /* since this is only an example, let's compare directly  */
   if (write(generic_fd, temp_ptr, strlen(temp_ptr)) == strlen(temp_ptr)) {
      write_result = 0;
   }
   close(generic_fd);
   return write_result;
}

int main()
{
     /* let us assume that the  close() call never fails.
     create a sample content of main() that uses write_something()
     and then in the end generate a file descriptor leak.
     good luck .... */
     return 0;
}

</code></span></pre>
<p>Up next<em> &#8230; fixing file descriptor leaks &#8230;<br />
</em><br />
<a href="http://flagcounter.com/more/eI7O"><img src="http://flagcounter.com/count/eI7O/bg=000000/txt=FCFCFC/border=CC0000/columns=5/maxflags=20/viewers=Kind+People+Who+Visited/labels=1/" alt="free counters" border="0"></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/govzlearnings.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/govzlearnings.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/govzlearnings.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/govzlearnings.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/govzlearnings.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/govzlearnings.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/govzlearnings.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/govzlearnings.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/govzlearnings.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/govzlearnings.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/govzlearnings.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/govzlearnings.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/govzlearnings.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/govzlearnings.wordpress.com/200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=200&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://govzlearnings.wordpress.com/2009/08/05/files-and-file-descriptors/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6511d1fc22b5bc066e094e6b59505f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">govz</media:title>
		</media:content>

		<media:content url="http://flagcounter.com/count/eI7O/bg=000000/txt=FCFCFC/border=CC0000/columns=5/maxflags=20/viewers=Kind+People+Who+Visited/labels=1/" medium="image">
			<media:title type="html">free counters</media:title>
		</media:content>
	</item>
		<item>
		<title>OS Resource Leaks</title>
		<link>http://govzlearnings.wordpress.com/2009/07/15/os-resource-leaks/</link>
		<comments>http://govzlearnings.wordpress.com/2009/07/15/os-resource-leaks/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 15:23:53 +0000</pubDate>
		<dc:creator>govz</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Embedded]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programmin]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://govzlearnings.wordpress.com/?p=172</guid>
		<description><![CDATA[Anyone who works on an embedded platform or even in PC applications, should probably by now understand full well the implications of a resource leak.  Before we start delving into this matter however it is imperative that we have a full grasp of what types of resources the Operating System (OS) provides to a &#8220;user-land&#8221; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=172&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Anyone who works on an embedded platform or even in PC applications, should probably by now understand full well the implications of a resource leak.  Before we start delving into this matter however it is imperative that we have a full grasp of what types of resources the Operating System (OS) provides to a &#8220;user-land&#8221; application. For starters let me give you four resources which could possibly be leaked during execution of your program:</p>
<ul>
<li> <strong>Memory leak</strong> &#8211; The most celebrated of all the leaks. Simplistically, the failure to inform the OS that you are finished using a memory area thus making the OS reserve that memory area for as long as the CPU is not reset or a &#8220;memory map&#8221; release is not automatically executed. This applies to malloc(), calloc(), realloc(), opendir(), mmap() and others of the like.</li>
</ul>
<ul>
<li><strong>Thread leak</strong> &#8211; An OS can only allow a certain number of threads running at the same time for a particular process. Exiting (libc::exit()) unnecessary threads, is a MUST. For they share together with the other threads  your process&#8217; precious time quantum. And with special reference to thread-based implementations of server applications (like FTP, HTTP, LDAP, Discovery etc&#8230;), you may end up unable to serve further requests should you fail to properly account for your threads.</li>
</ul>
<ul>
<li><strong>Process leak </strong>-like thread leaks, unnecessary processes should either be &#8220;killed&#8221; or &#8220;SIGTERM&#8221;ed. Don&#8217;t tell me you love rogue processes and good-for-nothing-zombies? Failure to properly end a process may result in an OS executing unecessary context switches for processes that dont really matter. Like threads, when your &#8220;server&#8221; or &#8220;daemon&#8221; application is serving multiple requests via &#8220;fork()&#8221;, &#8220;vfork()&#8221; or &#8220;clone()&#8221;, you might end up unable to server further requests from your clients if unnecessary processes are left to run idly.</li>
</ul>
<ul>
<li><strong>File Descriptor / Handles Leaks </strong>- The operating system also limits the number of files that an application can open simultaneously. So if you have got a leak on this one, you are looking forward to an unnecessary debugging adventure. For starters, some open source libraries, automatically assert() when they fail to take a hold of a valid file descriptor.</li>
</ul>
<p></br></p>
<h4><span style="color:#ffffff;">Why are leaks dangerous?</span></h4>
<p>A leak in the software realm is not like a leaky pipe that eventually floods up your room if left unfixed over long periods of time. (<em>I left our faucet once fully open overnight and the next day the house was really a mess! The water distribution service bill was almost as messy.</em>) A resource leak in software is pretty much the opposite though. Once there are leaks in certain areas of a process, be it memory or something else, that same process or other newly started programs, will eventually find themselves failing in certain system calls which would have succeeded in an otherwise zero-leak running environment.</p>
<blockquote><p>Summarizing, <strong> <span style="color:#ffffff;">&#8220;Leaks result to only one thing, the eventual depletion of resources of an otherwise perfectly &#8220;enough&#8221; system.</span> </strong>&#8220;Enough&#8221; because theoretically, except for some cases, what an OS provides is enough for everything it was designed to do, and that include the facilitation of user-land processes.</p></blockquote>
<p></br></p>
<h4><span style="color:#ffffff;">What are the consequences of leaks? </span></h4>
<p>The thing I hate most about leaks, is that it has the ability to affect other processes.  And in which case if they do, it is almost virtually impossible to detect. Think of a room full of people where somebody suddenly silently farts. Everyone suffers but when and where it happened nobody really knows. (hahahahah! PEACE!)</p>
<p>They too are extremely difficult to debug and it takes an enormous amount of time to pinpoint their exact location. Fixing them is not really the problem in most cases, but finding out where and when they happen is the most difficult of all.  Enumerating some effects :</p>
<ol>
<li> System fails to allocate memory. (libc :: malloc(), calloc(), etc&#8230;)</li>
<li> System fails to start a new thread. (POSIX : pthread_create())</li>
<li> System fails to start a new process. (libc :: fork(), vfork())</li>
<li> System fails to open new files. (libc :: open(), fopen(), dup(), etc&#8230;)</li>
<li> System fails on system calls. (libc :: socket(), pipe(), etc&#8230;.)</li>
<li> Applications start to run really really slow.</li>
<li> Applications suddenly crash due to low level assert().</li>
<li> You enter the debugging twilight zone with a ticket to the universal competition for patience. Just kidding.</li>
</ol>
<p>Probably in simple programs, you dont have to worry too much. But if you are developing an all-too-powerful daemon  which has to exist while the system is online, (or as you morph from intern engineer level to non-assistant level), you have got to be paranoid of leaks. <strong>&#8220;Resource Leaks = MESS&#8221;</strong> remember that.<br />
<br /></br></p>
<h4><span style="color:#ffffff;"><strong>Isn&#8217;t my OS the sky-is-the-limit version?</strong></span></h4>
<p>Yes dudes and dudettes! No OS is &#8220;<em>mugen</em>&#8221; &#8211; meaning &#8220;infinite&#8221; in Japanese.  Let me cite some example just for fun (though completely unrelated and utterly useless) did you know that :</p>
<ul>
<li> A server based encrypted data, is most likely be valid for only 5 minutes?</li>
<li>that the real limit of your system time or the <a title="NTP" href="http://www.eecis.udel.edu/~mills/y2k.html">Y2K bug is &#8220;2/7/2036&#8243;</a>? and the <a href="http://en.wikipedia.org/wiki/Year_2038_problem">UNIX Y2K bug in 2038</a>?</li>
<li> The limit of a USB cable is around 3 &#8211; 5 meters depending on the speed you use?</li>
<li> That  a <a title="WINS" href="http://support.microsoft.com/kb/188001">NETBIOS system</a> browser  has to routinely list the domain every 12 minutes?</li>
</ul>
<p>Now going back to the topic, OS resources are pretty much the same. How they came up with the limits, is I guess an arbitrary science.<strong> <span style="color:#ffffff;">Limits are  most probably based on a careful balance of available memory/actual resources versus the rough average of &#8220;extreme usage&#8221; and &#8220;ordinary usage&#8221;</span></strong>. For the moment, I do not question it because, as they are for me &#8220;enough&#8221;. Plus the fact that so many scientific minds have no major complaints about it, shows that it is well in a way &#8220;enough&#8221;.</p>
<p>Resources like file descriptors for MOST operating systems have process-wide and system-wide limitations. <span style="color:#ffffff;"> <strong>Process-wide</strong></span> means that for each process you create, there is a limited amount of file descriptors it can open simultaneously. Or for multi-threading process,  thread count limit is the maximum amount of threads a process can run simultaneously.  <span style="color:#ffffff;"><strong>System-wide limits</strong></span> however, is the count of all the particular in-use resource, regardless of the parent process.</p>
<p>Let us take for example some older versions of linux which can open up to a maximum of 256 files per process, and roughly 1K system-wide. Therefore, for as long as the 1K system-wide limit is not breached, any process can gain access to 256 files simultaneously at any given time. But should there be 4 other processes, each opening 250 files at the same time, then the 5th process cannot use its full 256 file limit anymore. <a href="http://www.nightmare.com/medusa/descriptor_limits.html">(Check this out.)</a></p>
<p>Anyways, if you happen to be running on top of a unix platform, you might want to try &#8220;ulimit -a&#8221; bash command in your terminal, to see certain limits of your Operating system.<br />
<br /></br></p>
<h4><span style="color:#ffffff;"><strong>Can these limits be changed? </strong></span></h4>
<p>Yes. However, it is important to note here that changing a per-process limit be it a hard or soft limit might require some special process, like recompiling your kernel. For the most part though, commands like setrlimit(), ulimit() or sysctl() (via libc::system() command) can be called within the program to modify certain soft and hard limits. Note also that setting a particular hard limit to an unreasonable value and then allowing a process to go beyond the hard limit might cause the system to break down eventually. <span style="color:#ffffff;"><strong>Besides, setting the limit for a particular resource, will never be a solution for a resource leak!</strong></span></p>
<p><em>Next Up &#8230;  file descriptor leaks &#8230;</em></p>
<p><a href="http://s05.flagcounter.com/more/zhxm"><img src="http://s05.flagcounter.com/count/zhxm/bg=030303/txt=FAFAFA/border=5E0000/columns=4/maxflags=20/viewers=Kind+People+Who+Visited/labels=1/pageviews=1/" alt="free counters" border="0"></a><br />
<em><br />
</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/govzlearnings.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/govzlearnings.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/govzlearnings.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/govzlearnings.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/govzlearnings.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/govzlearnings.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/govzlearnings.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/govzlearnings.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/govzlearnings.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/govzlearnings.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/govzlearnings.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/govzlearnings.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/govzlearnings.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/govzlearnings.wordpress.com/172/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=172&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://govzlearnings.wordpress.com/2009/07/15/os-resource-leaks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6511d1fc22b5bc066e094e6b59505f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">govz</media:title>
		</media:content>

		<media:content url="http://s05.flagcounter.com/count/zhxm/bg=030303/txt=FAFAFA/border=5E0000/columns=4/maxflags=20/viewers=Kind+People+Who+Visited/labels=1/pageviews=1/" medium="image">
			<media:title type="html">free counters</media:title>
		</media:content>
	</item>
		<item>
		<title>Embedded Software Paradigm (1)</title>
		<link>http://govzlearnings.wordpress.com/2009/06/01/embedded-software-paradigm-1/</link>
		<comments>http://govzlearnings.wordpress.com/2009/06/01/embedded-software-paradigm-1/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 08:16:52 +0000</pubDate>
		<dc:creator>govz</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[Embedded]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programmin]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://govzlearnings.wordpress.com/?p=147</guid>
		<description><![CDATA[One day in an undisclosed NASA facility&#8230;.. NASA Boss        : “Can somebody please go to MARS” NASA Engineer    : “What for?” NASA Boss        : “Upgrade the code for the MARS Rover?” (fictional) For the general populace, software is just software, a set of instructions which dictates a computing device’s behavior. However for those [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=147&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<blockquote><p>One day in an undisclosed NASA facility&#8230;..</p>
<p><em>NASA Boss        : “Can somebody please go to MARS”<br />
NASA Engineer    : “What for?”<br />
NASA Boss        : “Upgrade the code for th<span style="color:#ffffff;">e <a title="MARS Rover Video" href="http://www.youtube.com/watch?v=5UmRx4dEdRI"><strong>MARS Rover</strong></a>?”</span> (fictional)<br />
</em></p></blockquote>
<p>For the general populace, software is just software, a set of instructions which dictates a computing device’s behavior. However for those of us who are initiated, &#8220;firmware&#8221;, is a bit different from streamline PC-application-development. Although they are fundamentally the same, I think that firmware development mentality is a bit different. I hope I did not lose you there. And please take note, <span style="color:#ffffff;"><strong>I never said firmware is more difficult.</strong></span></p>
<h4><span style="color:#ffffff;">“A BIT BUT SIGNIFICANTLY DIFFERENT”</span></h4>
<p>PC-Applications and firmware are differentiated by only one aspect. They are differentiated, if not stating the obvious, only by the environment/device on which they should run on. Or more technically what we call as the “target&#8221;. It follows too that firmware, and its development, is subject to the nuances and frailties of an embedded  device. <a title="Embedded Engineering" href="http://govzlearnings.wordpress.com/2009/05/12/embedded-engineering/">Please refer to previous blog&#8217;s [1][2]and [3].</a> And these &#8220;nuances&#8221; have a  direct and significant effect on the development mentality and process. This blog aims to discuss tangibly and simply, certain paradigm adjustments of each &#8220;embedded device limitation&#8221;.</p>
<p><span style="color:#ffffff;"><strong>A. Embedded devices generally, is “lesser” than the PC.</strong></span><br />
The term &#8220;lesser&#8221; here pertains to a multitude of aspects. For the moment let us limit it to computing power, and functional/program memory.</p>
<p><span style="color:#ffffff;"><strong>1. Effect of having Lesser computing power.</strong></span><br />
“Computing power” is really a very difficult subject. If you want to be as technical about it, and if you don&#8217;t mind to nosebleed a little, you can refer to “<a title="Virtual Computing Power" href="http://books.google.com/books?id=cWzSJ2ifBYoC&amp;pg=PT1073&amp;lpg=PT1073&amp;dq=handbook+computing+power&amp;source=bl&amp;ots=GsPvrWyqKj&amp;sig=2KhInKoLMiYu77pV3ogXCRly74c&amp;hl=en&amp;ei=D30jSqSlHcWUkAXR6cCYBQ&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=1">The Computer Engineering Handbook By Vojin G. Oklobdzija</a>”. For the mean time, think of “computing power” as the computer&#8217;s “chi” or life force. The more you have it the more it can pump up the computing process. The lesser you have of it, the slower the system process.</p>
<p>Almost a decade ago, we had a a problem for a <a title="Microcontroller" href="http://www.google.com/search?hl=en&amp;defl=en&amp;q=define:Micro+controller&amp;ei=Sn0jSo7OE5uG6AO7vb3EAw&amp;sa=X&amp;oi=glossary_definition&amp;ct=title">micro-controller</a>. We were to ensure that at any point in time, our design should be able to save whatever temporary data there was inside the buffers into an <a title="EEPROM" href="http://en.wikipedia.org/wiki/EEPROM">EEPROM</a> (Electrically Erasable Programmable Read-Only Memory).  On normal operating conditions we really didn&#8217;t have a problem. The problem however, occurred when the device lost power from its battery source.  Our design was to be good enough save the &#8220;cached&#8221; data.</p>
<p>Our solution then was two fold. (a)Impliment a fast <a title="ISR" href="http://en.wikipedia.org/wiki/Interrupt_handler">Interrupt Service Routine (ISR)</a> which executed the &#8220;save-data&#8221; mechanism and (b) the save-data mechanism was to beat the decay rate of the systems power supply.</p>
<p>Implementing the ISR was not the problem. The problem really was the execution speed of  our &#8220;store-data&#8221; function. Simple analysis showed that the speed of such a &#8220;transaction&#8221; relied mainly on :<br />
1. the speed of the cpu or its computing power. (&#8220;how fast can it execute one command&#8221;)<br />
2. the amount of time for one &#8220;write&#8221; transaction in the EEPROM. (&#8220;write-cycle&#8221;)<br />
3. the amount of cached-data to be saved.</p>
<p>Anyways, I hope you catch my drift. Lesser computing power in the above example was really bane for what we had in mind. If only our micro-controller could execute billions of transactions in one second, then i think we would have had lesser factors to worry about. But then again, a better controller would have skyrocketed the cost of materials.</p>
<p><span style="color:#ffffff;"><strong>2. Embedded devices have lesser functional memory</strong></span></p>
<p>Memory here is categorical and does not refer to the number of images inside your mobile phone or digital SLR, nor the number of emails your <a title="Blackberry" href="http://www.blackberry.com/">Blackberry Smart Phone</a> can keep. “Memory” here refers to the number of features / capabilities a computing device has in its disposal.</p>
<p>To emphasize further, let us say, that the brain remembers all the different skill sets you have. Like riding a bike, treading in water, writing a haiku, so on and so forth. The PC generally speaking, has enough brain space to store all these skill sets (plus more) and thereby allowing it to do a lot of things. Embedded devices on the other hand can only muster three or four. Some can store only one functionality.</p>
<p>A few years back, my boss wanted me to implement one special mechanism in our machine. For confidential purposes let us call it the &#8220;Lightning In A Bottle (LIAB)&#8221; mechanism. However LIAB&#8217;s original implementation was on top of the Java platform. For those unfamiliar with <a title="JAVA" href="http://www.java.com/en/download/whatis_java.jsp">JAVA</a>, simply think of it as the all useful <a title="Velcro" href="http://en.wikipedia.org/wiki/Velcro">VELCRO</a> strap. Wherein if the opposite material is fibrous or &#8220;loop-full&#8221; enough, it will surely adhere to the trusty Velcro &#8220;hooks&#8221;.</p>
<p>Java is like that. A powerful programming base, developed with the &#8220;build / code once, run anywhere&#8221; principle in mind. Once you create a program in JAVA, you are almost ensured that it will run anywhere that supports JAVA. Whether it be MAC or INTEL or <a href="http://en.wikipedia.org/wiki/Sharp_Zaurus">ZAURUS </a>or what have you.</p>
<p>Anyways, during that time, my boss had two proposals for me :<br />
1. Implement a simplified Java Virtual machine (create a special velcro strap)<br />
2. Create my own version of the LIAB mechanism.<br />
Due to the amount of risks option 1 entailed, I told my boss that option 2 is the best.</p>
<p>Bottom line, bar the very small technical disparity in my example,  an embedded device has so limited a functional memory that theoretically,  &#8220;the number of ways to catch a mouse&#8221; is very limited. Needless to say reinventing the wheel is not a &#8220;rare reality&#8221;.</p>
<p><em><span style="color:#ffffff;">*technical disparity</span> &#8211; the differentiation was based on JAVA. But theoretically (&#8220;purist-tically&#8221;) this should be microprocessor  to microprocessor, or architecture versus architecture.</em></p>
<p><a href="http://flagcounter.com/more/b13q"><img src="http://flagcounter.com/count/b13q/bg=000000/txt=FAFAFA/border=C70E0E/columns=4/maxflags=20/viewers=Kind+People+Who+Visited/labels=1/" border="0" alt="free counters" /></a></p>
<p><span style="color:#ffffff;"><em>&#8230; Paradigm changes because Embedded Devices are usage-specific &#8230;</em></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/govzlearnings.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/govzlearnings.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/govzlearnings.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/govzlearnings.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/govzlearnings.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/govzlearnings.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/govzlearnings.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/govzlearnings.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/govzlearnings.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/govzlearnings.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/govzlearnings.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/govzlearnings.wordpress.com/147/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/govzlearnings.wordpress.com/147/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/govzlearnings.wordpress.com/147/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=147&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://govzlearnings.wordpress.com/2009/06/01/embedded-software-paradigm-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6511d1fc22b5bc066e094e6b59505f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">govz</media:title>
		</media:content>

		<media:content url="http://flagcounter.com/count/b13q/bg=000000/txt=FAFAFA/border=C70E0E/columns=4/maxflags=20/viewers=Kind+People+Who+Visited/labels=1/" medium="image">
			<media:title type="html">free counters</media:title>
		</media:content>
	</item>
		<item>
		<title>Embedded Engineering</title>
		<link>http://govzlearnings.wordpress.com/2009/05/12/embedded-engineering/</link>
		<comments>http://govzlearnings.wordpress.com/2009/05/12/embedded-engineering/#comments</comments>
		<pubDate>Tue, 12 May 2009 05:43:38 +0000</pubDate>
		<dc:creator>govz</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Embedded]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://govzlearnings.wordpress.com/?p=99</guid>
		<description><![CDATA[I had been an embedded engineer for the past ten years. For the first half, I was mainly involved in simple hardware  development, and as for software, I delved with Simple programming (Simple Control Loop) specific to particular sets of electronic chips (mainly on ATMEL microcontrollers and  PIC microchips using ANSI-C and Assembly language). And [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=99&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:left;">I had been an embedded engineer for the past ten years. For the first half, I was mainly involved in simple hardware  development, and as for software, I delved with Simple programming (Simple Control Loop) specific to particular sets of electronic chips (mainly on <span style="color:#ffcc99;"><a href="http://www.atmel.com/dyn/Products/product_card.asp?part_id=2004" target="_self">ATMEL</a> </span>microcontrollers and <span style="color:#00ffff;"> <a href="http://ww1.microchip.com/downloads/en/DeviceDoc/30292c.pdf" target="_self">PIC</a> </span>microchips using <span style="color:#ffffff;"><a href="http://en.wikipedia.org/wiki/ANSI_C" target="_self">ANSI-C</a></span> and <span style="color:#ffffff;"><a href="http://en.wikipedia.org/wiki/Assembly_language" target="_self">Assembly language</a></span>). And then the latter 5 years, was mostly spent on embedded software with customized operating systems (<a href="http://searchdatacenter.techtarget.com/sDefinition/0,,sid80_gci213667,00.html" target="_self">RTOS &#8211; Real Time Operating Systems</a>) using mainly the programming languages  C, and <a href="http://en.wikipedia.org/wiki/C%2B%2B" target="_self">C++</a>.</p>
<p>Since my hardware development faculties are rusty, and because I had been in the most part of my short career, an embedded software developer, I would like to share some ideas I have , though little as they may be, on embedded engineering. And hope to contribute in the growth of some who may not have had the opportunity of training as I have had, but wish to learn in this profession. <em>(Bear in mind though that I too am a work in progress. And this blog is written with the intention of continuous improvement.)</em></p>
<p>What is embedded engineering?  Embedded engineering is an applied science that is geared toward the creation of &#8220;embedded devices&#8221;.  Samples of embedded devices are mp3 players, mobile phones, a computer&#8217;s video card, ipod, iphones and well anything that basically acts like a personal computer but is not really one. With so many people creating a lot of sophisticated devices, and the laptop or notebook PC becoming smaller and smaller, sometimes an embedded device is misconstrued as a personal computer. But in this case, size really has no bearing. In my humble opinion (and in no way a universal truth), there are some important items that differentiate embedded equipment from that of its personal computer counterpart. And these are :</p>
<p style="padding-left:30px;"><strong>[1] An embedded device is an electronic device which possesses very limited resource compared to the PC.</strong><br />
- it usually has lesser &#8220;brain&#8221; or computing power.<br />
- it has a smaller &#8220;football field&#8221; for memory.</p>
<p style="padding-left:30px;"><strong>[2] An embedded device is an electronic device which is usage-specific, it cannot compute or process generic PC functions.</strong><br />
- your watch can&#8217;t open nor write document files<br />
- your cant do spread sheet computations on a scanner</p>
<p style="padding-left:30px;"><strong>[3] An embedded device may or may not stand on its own.</strong><br />
- the graphics card of your pc has no use if it is not &#8220;plugged in&#8221;.<br />
- Well you know how it is with the PC.</p>
<p>Aside from these three, there are more finer points that differentiate embedded devices from the personal computer. These finer differences including the ones listed above play critical roles in the development process.</p>
<p>And like the other applied sciences, Embedded engineering too has so many sub-disciplines. However, in my humble opinion, its two fundamental sub-disciplines are <strong>HARDWARE  ENGINEERING (HW)</strong> and <strong>SOFTWARE ENGINEERING (SW)</strong>.</p>
<h3><span style="color:#ffffff;"><strong>HARDWARE EMBEDDED DEVELOPMENT</strong></span></h3>
<p>I may not do justice enough for hardware engineers for I lack the deep &#8220;<a href="http://en.wikipedia.org/wiki/Gaussian_function" target="_self"><em>gaussian-function-iiiish</em></a>&#8221; level hardware expertise. But to give some balance on this article,  from a hardware standpoint, <strong>[2]</strong> stands out because HW engineers have to select the fittest electronic component in light of what needs to be achieved. Think of it as having to select a wall mounted TV, but you don&#8217;t really need a gigantic one because your living room wall space for the TV allows only a 40 inch mounting.  Is it wise then for you to buy a $2000 60-Inch flat panel high definition TV?  In the same light, hardware engineers select, re-select and re-select components to fit their designs. Choosing components with the lowest cost without curtailing <strong>safety</strong>, <strong>quality </strong>and <strong>functionality </strong>is top priority. Sometimes, due to our cost driven environment, HW engineers re-design according to cheaper and available components. Key point <strong>[2]</strong> indirectly governs the overall cost of the device. Which in turn has an effect on final market price or corporate profit.</p>
<p>In the plotting of schematics and creation of a prototype, a hardware guy has to ultimately decide whether his implementation is better than an already available sub-system pre-built by somebody else. In a simplistic analogy, hardware people have to ask &#8220;Do I create a <a href="http://computer.howstuffworks.com/fingerprint-scanner.htm" target="_self">finger print scanner</a> or is it better to buy from somebody else?&#8221;. Of course, the thought process is not as simple as that.  But point <strong>[3]</strong> stands.  <strong>Some embedded devices like finger print scanners can not stand on their own, but they are created because somebody else will need them. </strong>(In hardware, there are times when one has to re-invent the wheel so as not to succumb to pricey components. The risk here is that development might take too much time and resource that the cost of Research and Development (R&amp;D) will be bigger than originally planned.)</p>
<p>Unlike<strong> [2] </strong>and <strong>[3]</strong>, point <strong>[1]</strong> is an effect of the general desire to make the product affordable or to increase corporate profit. Whichever the case, to achieve cost reduction,  hardware engineers are obligated to build a system with very limited resource but can, and will get the job done. (In my personal experience, sometimes a brilliant management team has to step in to stop R&amp;D engineers from over-designing resulting to too much cost and too much loss in time-to-market.)</p>
<h3><span style="color:#ffffff;"><strong>SOFTWARE and FIRMWARE</strong></span></h3>
<p>As I have said, I have for the most part of my short career become an embedded software developer. (More specifically in the development of customized applications, <a href="http://en.wikipedia.org/wiki/Protocol_(computing)" target="_self">networking protocol</a> implementations and partially in the realm of the operating systems.) In the technical world slang, most if not all embedded software developers are dubbed as firmware engineers(<a href="http://books.google.com/books?id=JTYPKxug49IC&amp;pg=PA101&amp;lpg=PA101&amp;dq=Ascher+Opler+firmware&amp;source=bl&amp;ots=C5RcNv_BT4&amp;sig=NJxmi2q0NGFHpb2bHxuUllGAYsY&amp;hl=en&amp;ei=xqAHSqmuGcaHkQWUtKjLCA&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=5" target="_self">Ascher Opler-1967</a>). Simply put, firmware or &#8220;microcode&#8221; is a kind of software which once installed, needs some form of special mechanism for it to be updated or modified. Some even are designed &#8220;NEVER&#8221; to be updated. Firmware codes or programs usually make up the barest essential of the system. Examples of devices that have microcode in them are your digital wrist watches, <a href="http://en.wikipedia.org/wiki/Engine_control_unit" target="_self">Engine Control Unit (ECU) </a>and USB memory sticks.</p>
<p>However, with the advent of new technology which makes core-function upgrade relatively easy (FLASH Technology and UVPROMs ),  Ascher Opler&#8217;s &#8220;softness&#8221; based definition of firmware now needs some reconsideration. And since I am in no position to redefine it yet, I stumbled upon <a href="http://www.cs.clemson.edu/~mark/uprog.html" target="_self">Mark Smotherman&#8217;s A Brief History of Microprogramming&#8221;</a> which provides some clarity to what I think holds ground as to what firmware has evolved as of this time period.</p>
<p>And as for this blog-series however, I would like to refer to firmware as basically a piece of software that is intended for embedded devices.</p>
<p><em>Next &#8230;  (</em><em></em><em>Embedded Software </em><em></em><em>Paradigm </em><em>)</em></p>
<p><a href="http://flagcounter.com/more/173"><img src="http://flagcounter.com/count/173/bg=0A0A0A/txt=FAFAFA/border=F52B0C/columns=4/maxflags=20/viewers=Kind+Enough+People+To+Read/labels=1/" border="0" alt="free counters" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/govzlearnings.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/govzlearnings.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/govzlearnings.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/govzlearnings.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/govzlearnings.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/govzlearnings.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/govzlearnings.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/govzlearnings.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/govzlearnings.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/govzlearnings.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/govzlearnings.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/govzlearnings.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/govzlearnings.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/govzlearnings.wordpress.com/99/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=99&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://govzlearnings.wordpress.com/2009/05/12/embedded-engineering/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6511d1fc22b5bc066e094e6b59505f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">govz</media:title>
		</media:content>

		<media:content url="http://flagcounter.com/count/173/bg=0A0A0A/txt=FAFAFA/border=F52B0C/columns=4/maxflags=20/viewers=Kind+Enough+People+To+Read/labels=1/" medium="image">
			<media:title type="html">free counters</media:title>
		</media:content>
	</item>
		<item>
		<title>Recession:Corporate Defence</title>
		<link>http://govzlearnings.wordpress.com/2009/03/28/recessiondefending-the-world-from-avarice/</link>
		<comments>http://govzlearnings.wordpress.com/2009/03/28/recessiondefending-the-world-from-avarice/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 08:38:05 +0000</pubDate>
		<dc:creator>govz</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Outsourcing]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://govzlearnings.wordpress.com/?p=64</guid>
		<description><![CDATA[People losing jobs, the stock market is down and everybody&#8217;s offering &#8220;Hail Mary&#8217;s&#8221; for this current recession. People are frantic because contrary to the mandate of profitability and expansion, the economy is contracting and profitability is down to the sewers. How could have this happened so fast? Truth is, this reccession is like the Tales [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=64&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>People losing jobs, the stock market is down and everybody&#8217;s offering &#8220;Hail Mary&#8217;s&#8221; for this current recession. People are frantic because contrary to the mandate of profitability and expansion, the economy is contracting and profitability is down to the sewers. How could have this happened so fast?</p>
<p>Truth is, this reccession is like the <a title="Tales of Vesperia" href="http://en.wikipedia.org/wiki/Tales_of_Vesperia">Tales of Vesperia</a> monster, the Adephagos. It has always been there but some form of &#8220;shrine of Zaude&#8221; has shielded it from our eyes. It has happened before during the 1930&#8242;s and 1800&#8242;s and all it required to come back is a spark plug like the sub-prime mortgage problem. This is what I think a reflection of how much greed has gotten around. Think <a title="Bernard Madoff Scandal" href="http://en.wikipedia.org/wiki/Madoff_investment_scandal">Bernard Madoff </a>scandal. Or if you are in Japan, it could be the<a title="L&amp;G Scandal" href="http://www.guardian.co.uk/business/2009/feb/05/japan-kazutsugi-nami-ladies-gentlemen"> L&amp;G Japan Scandal</a>.</p>
<p>Though I agree with <a title="Rich Dad Poor Dad" href="http://en.wikipedia.org/wiki/Rich_Dad,_Poor_Dad">Robert Kiyosaki (Rich Dad Poor Dad) </a>that a part of us has to be subtly greedy, I feel that some people have taken too much from the system and from other people as well. And now that it has come around, I dont know if the same people who have taken too much have the balls to fix it. Oh well, we cant do anything about the past but can hope to do something about what happens next.</p>
<p>For me, I personally feel that this recession is special. Because for me this is my second time around. Back then during the 2001 recession, during <a title="ZTek Telematics Inc." href="http://www.teamasia.com/Media/2002/pn08292002.htm">ZTek</a>&#8216;s time,I was only exposed to a very limited set of professional experiences. Right now I see myself as a little bit more skilled and more seasoned, engineer and technocrat. Moreso, back then I didnt have high speed internet, my own personal laptop and an internet with a fully diversified knowledgebase.  My two cents or 1円(yen) on the great recession of 2009 is as follows :</p>
<p>A.  An Opportunity For Re-Orientation</p>
<p>I see this recession as a time for re-orientation of a company&#8217;s goals and objectives. Mochiron!(Of course.) Any organization, hell even an individual, has a desire to survive. Therefore a recession is a great time to test and see if corporate objectives still meet the demanding times and the probable permanent change in the business scenery.</p>
<p>Lets take for example an outsourcing company. Everyone has his or her own opinion of outsourcing. But in light of this recession, this business is going to evolve. Consider this article <a title="Future of Outsourcing" href="http://www.cio.com/article/452819/Offshore_Outsourcing_What_Role_Will_the_Recession_Play_">&#8220;Offshore Outsourcing: What Role Will the Recession Play?&#8221;</a>. Thank God somebody said out loud what I always wanted to say. In this light, if outsourcing is purely based on &#8220;mancount&#8221;, will it still be dominant in the coming days? I am a firm believer that any service based business, for a business relationship to endure, providers  have to put more value on the table, lesser cost and better communication-cooperation system.  Is more better or is less &#8220;betterer&#8221;? Then which scheme should you pursue?</p>
<p>B. A Time for Team Re-engineering</p>
<p>In line with cost cutting, i think recession in a purely business stand point, is a good time for weeding out. Weeding out because, as the term implies, those who cannot produce and dont like to produce should be &#8220;uninstalled&#8221;. Unlike democracy, corporate leadership is not a popularity contest. There are certain decisions you have to take, unpopular as they may seem. But dont get me wrong, team re-engineering is not just about laying people off. It has several approaches  like :</p>
<p>1. In line of new &#8220;probable&#8221; businesses in sight, who are we going to hire?<br />
2. Or better would be a do-more with same resource kind of outlook. Something like Team Restructuring, based on specialization and expertise. <a title="Venn diagram" href="http://en.wikipedia.org/wiki/Venn_Diagram">Think Venn Diagram</a>. If you have 3 teams let us say A,B,C. Is it possible to create another team with same resource? Say :<br />
a. Group A (Cleaning) Group B (Cooking) Group C (Cash Register)<br />
so : Group D = Serving (1/2 of Group B and 1/4 of Group C depending on time schedule)</p>
<p>For a software company perhaps, call me mean, but it might be time to re-study existing personnel. Qualify and disqualify. Yep, i think it is time to measure the ranks once again and remove long-time-underperforming officers. Of course, if the finances can afford it, provide a judgement period for them to recover their &#8220;mojos&#8221;. How about engineers and foot soldiers, yep they too would be in the list too. But officers cost more, so they should be  &#8220;relatively volatile&#8221;.</p>
<p>C. A Time for Cost Awareness</p>
<p>Undoubtedly, as this recession seems to be for the long haul, there is a genuine requirement to study the &#8220;financials&#8221;. The coffers have to be protected. And if that is so, all have to plan out against costs. Gone are the days of impulsive shopping for employees much as unplanned business trips. During my time with ZTek, Jerry Lopez, our finance officer would always make me create charts showing how I will execute and how much it will cost. Of course, the sales are indicated too. He would always then come up with his own version of the same plan, only that it costs cheaper, sometimes they are better too.</p>
<p>Simple solutions need not be very complex. For one, how about a four-day work week? Is making employees work from 8:00-19:30 so that they can take Friday off impossible?The four day work week makes a lot of sense in my opinion. Of course its obvious effect is there will be no overhead cost on the fifth day (electricity for one.). But if your organization executes an overtime boundary at 22:00 of the day, bottomline, the maximum allowable OT for a day in the week is 2.5 hours right? On the other side of it, you have a well-rested crew, you provide more family time for your team, and most importantly, you can provide them an opportunity to find other means to fight off the recession.</p>
<p>D. A Time for Necessary Creativity and Aikido</p>
<p>As the days go by, there will be a need for more creativity. During this recession, the desire to survive or protect the financials is more emphasized way beyond any other. And that need, grows as the days lag on. When ones back is on the wall, he or she has to fight back. &#8220;A cornered cat becomes a lion.&#8221; In this situation, since the foe is indomitable, we have to learn how to use its strength as our own. &#8220;To discard one&#8217;s strength and win by using the enemy&#8217;s strength.&#8221;,The Spirit of <a title="Aikido" href="http://en.wikipedia.org/wiki/Aikido">Aikido</a>.</p>
<p>The strength of this recession comes from the idea that there is either no money to spend or no one wants to spend. Therefore it is imperative that we make consumers spend by creating an &#8220;imperative someting (like medicine)&#8221;, &#8220;a cool something (like iphone and ipods)&#8221;, and other  somethings. New devices or new services, new uses for existing stuff (think <a title="Swiss Type Claim" href="http://en.wikipedia.org/wiki/Claim_(patent)">Swiss Type Claim</a>) so that we can sell more of them, one-time-single hit wonder solutions for everyday (think <a title="Toothbrush Cleaner" href="http://www.freepatentsonline.com/4915219.html">Disinfecting toothbrush container</a> ), so on and so forth. Why do you think the <a title="Gaming Console Sales" href="http://www.vgchartz.com/">combined sales of WII, PS3 and XBOX</a> is the temporary eighth wonder in the world?  As for PS3, do u really think a sales of 21.4M units is bad? Think again.</p>
<p>For a software guy like myself, well i have my own ideas. (Work In Progress&#8230;)</p>
<p>E. A Time for &#8220;Laborare est orare&#8221;.</p>
<p>I am a bit of a religious man. Just a bit. I believe that this too is a time of prayer. And when I say pray, it means a lot of things. First off let me share this very very <a title="Pilots Imprisoned For Praying" href="http://thelede.blogs.nytimes.com/2009/03/25/court-in-italy-convicts-pilot-who-prayed-before-crash/">interesting story on prayer</a>. Recently I also witnessed some of my officers praying in the same fashion too, resulting to displacement. (thank god not lay-offs!)</p>
<p>I am in the opinion that prayers is not only about genuflecting or making the sign of the cross or facing a wall. <a title="St. Bendict - Work is prayer." href="http://en.wikipedia.org/wiki/Laborare_est_orare"><em>&#8220;Laborare est orare</em>&#8220;</a>, roughly translating to &#8220;Work is Prayer&#8221;,  just like the catholic monk Bernard prescribed, how he lived his life. If we were faced in front of a diety, and we were to be judged by how we pray, wont we be condemned by our diety for spending too much time kneeling? So yeah, this recession is just like that plane crash and the plane is much like our economy, our business unit or probably even our families finances. My point is, act out your prayers harder. Exhaust all means necessary to win your personal or group battle against this real-life <a title="Adephagos" href="http://en.wikipedia.org/wiki/Adephagia">Adephagos (or was this based from adephagia)</a>,  mitigate the probability of failure. Mitigate risks, mitigate risks and mitigate more risks.</p>
<p>And as for the rest of the things that you cant control, leave that to luck, the fates or to your God.  After all, even in my &#8220;most weirdest Japanese translation&#8221; of one of their proverbs, I believe that, &#8220;未来の事を心配したら鬼が笑う&#8221;. (mirai no koto wo shimpaishitara oni ga warau / the devil smiles once we worry so much about the future.) If you are still unsure, you can leave that to me if you want. Just kidding. <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>All in all, this recession is a measurement of two things. One, this recession&#8217;s unfathomable depth and its massive wingspan reflect how much avarice has been running around, how greedy the world has gotten to be. Unfortunately however, that same AVARICE, is here to stay for good. Blame it on human nature.</p>
<p>The second thing about this recession is that surely, there will be people who will rise up and challenge it back, (think <a title="Franklin Delano Roosevelt" href="http://www.nps.gov/archive/elro/glossary/great-depression.htm">Franklin Delano Roosevelt</a>). And in an organizational point of view, officers need to LOOK WITHIN MORE and SEE BEYOND MORE to fight it back. Or else everyone loses their job. This then brings me to the silver lining  of this recession, this time  is also a measurement of the human spirit. And like AVARICE, I assure you that that the INDOMITABLE HUMAN SPIRIT, will always be around.</p>
<p>Good luck and cheers to all those who work for a better economy.</p>
<p><a href="http://s03.flagcounter.com/more/pPJQ"><img src="http://s03.flagcounter.com/count/pPJQ/bg=FFFFFF/txt=000000/border=CCCCCC/columns=2/maxflags=12/viewers=0/labels=0/" border="0" alt="free counters" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/govzlearnings.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/govzlearnings.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/govzlearnings.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/govzlearnings.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/govzlearnings.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/govzlearnings.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/govzlearnings.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/govzlearnings.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/govzlearnings.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/govzlearnings.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/govzlearnings.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/govzlearnings.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/govzlearnings.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/govzlearnings.wordpress.com/64/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=64&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://govzlearnings.wordpress.com/2009/03/28/recessiondefending-the-world-from-avarice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6511d1fc22b5bc066e094e6b59505f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">govz</media:title>
		</media:content>

		<media:content url="http://s03.flagcounter.com/count/pPJQ/bg=FFFFFF/txt=000000/border=CCCCCC/columns=2/maxflags=12/viewers=0/labels=0/" medium="image">
			<media:title type="html">free counters</media:title>
		</media:content>
	</item>
		<item>
		<title>When the procesor Flops (Floating Point Operations)</title>
		<link>http://govzlearnings.wordpress.com/2008/10/31/when-the-procesor-flops-floating-point-operations/</link>
		<comments>http://govzlearnings.wordpress.com/2008/10/31/when-the-procesor-flops-floating-point-operations/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 01:15:47 +0000</pubDate>
		<dc:creator>govz</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[Programmin]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Embedded]]></category>
		<category><![CDATA[floating point]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://govzlearnings.wordpress.com/?p=39</guid>
		<description><![CDATA[One time, a very tired and exhausted friend and former student, needed to hurry up on a meeting and asked some support on the completion of a code. The code asked of him was simple, it was supposed to convert values ranging from 0.01 to 0.99 into its integral (whole number) form. Therefore, 0.01 becomes [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=39&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One time, a very tired and exhausted friend and former student, needed to hurry up on a meeting and asked some support on the completion of a code. The code asked of him was simple, it was supposed to convert values ranging from 0.01 to 0.99 into its integral (whole number) form. Therefore, 0.01 becomes 1 and 0.99 becomes 100&#8230;.oops just kidding 0.99 is 99.  Simplistically this can be done by multiplying the said values to 100.</p>
<p>The question however dawned on me then, why then would anyone need to convert real numbers into their integral form?</p>
<p>To better analyze let us Assume that these three values are to be added :<br />
value 1 : 0.01     Value 2 : 0.2      Value 3 : 0.03</p>
<p>Coding this in C, we will have something like :<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
#include &lt;stdio.h&gt;</p>
<p>int main(void)<br />
{<br />
&nbsp;&nbsp;&nbsp;double val[3] = {1e-2,2e-1,3e-2};<br />
&nbsp;&nbsp;&nbsp;double total_val = 0;<br />
&nbsp;&nbsp;&nbsp;int cntr = 0;</p>
<p>&nbsp;&nbsp;&nbsp;for (cntr=0; cntr&lt;3; cntr++) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;total_val += val[cntr];<br />
&nbsp;&nbsp;&nbsp;}</p>
<p>&nbsp;&nbsp;&nbsp;printf(&#8220;total is : %e \n&#8221;,total_val);<br />
&nbsp;&nbsp;&nbsp;printf(&#8220;total is : %f \n&#8221;,(float)total_val);<br />
&nbsp;&nbsp;&nbsp;return 0;<br />
}</p>
<p>Again let me warn you, my quest here is not to dissuade anybody from using real numbers. Or strictly &#8220;C-speaking&#8221;, dissuading the use of double or float data types. My goal is to learn something here and share what little I have learned. Since I was not from the very start a computer scientist nor systems architect, I take great stride in learning as much as I can to augment whatever learnings I have and become better in my profession.</p>
<p>Going back to the conversation at hand, what we don&#8217;t see in the above C-code is the logic of floating point manipulations. First off before I continue sharing, funny that after so many years in programming, it is only now that I took time to understand what floating points really are. I just treated them before like ordinary data types, just like integer and char. However,  like a shocking horror movie, and much to my surprise, it was not &#8220;just&#8221; a data type.</p>
<p>Simplistically, floating points are real numbers. They are called as such because the decimal point (or radix point) can be found anywhere within the number.  Thus, it is said that the radix point, &#8220;floats&#8221;. For example :</p>
<p style="padding-left:30px;">a. 1.23456 -&gt; radix point is in between 1 and 2<br />
b. 12.3456 -&gt; radix point is in between 2 and 3</p>
<blockquote>
<h4><span style="color:#ffffff;"><strong>Again, why then would anyone need to convert real numbers into their integral form? </strong></span></h4>
</blockquote>
<h4><span style="color:#ffffff;">A. Learning 1 : Floating points are not innate to computing machines therefore, it has to find some extraneous way to preserve the data.</span></h4>
<p>Computers do not operate on real numbers. Most operate on a binary system, the beloved &#8220;1&#8243; and &#8220;0&#8243;. What it does however,  in my very rough understanding of it, is that for computers to express -134.56 it has to save or represent it in an integral manner.  For example :</p>
<p>a. -134.569  can be expressed as : -13456  x (10 exponent -2)</p>
<ul>
<li> According to the mathematical experts : A real number can be expressed as : s x b exponent e</li>
<li>Where &#8220;s&#8221; is the signed number in this case &#8220;-13456&#8243;</li>
<li> Where &#8220;b&#8221; is the base in this case &#8220;10&#8243;</li>
<li> Where &#8220;e&#8221; is the exponent in this case &#8220;-2&#8243;</li>
<li>Therefore, to save float, computers have to preserve s, b and e.</li>
<li>And if a float in an architecture is a 32bit data, parts of the 32 bit will be set for &#8220;b&#8221; and &#8220;e&#8221;</li>
</ul>
<p>Therefore in my coclusion, that by just declaring and initializing a double or a float data, i am led to believe that  some form of procedural or operating cost is automatically incurred when the cpu tries to analyze your input and then save on a bit level the corresponding levels for &#8220;s&#8221;, &#8220;b&#8221;, and &#8220;e&#8221;.</p>
<h4><span style="color:#ffffff;">B. Learning 2 : Floating point operations require more processing power from the PC or microcomputer.</span></h4>
<p>Floating point arithmetic is very difficult for limited resourced computers like embedded systems. For example, if we add 0.01 and 0.2, a simplified flow on how the  computer processes “0.01 + 0.2” is as follows :</p>
<p>1.  Check if the exponents are the same for both operands.  Represent both numbers 0.01 and 0.2 in their respective S x (B ^ e) form :</p>
<ul>
<li> 1 x 10^-2</li>
<li> 2 x 10^-1</li>
</ul>
<p>2.  If not of same exponents, get the lowest exponent value</p>
<ul>
<li> 1 x 10^-2 -&gt; lowest is -2</li>
</ul>
<p>3.  Operate / Shift so as to make both operands use the lowest exponent value.</p>
<ul>
<li> 2 x 10^-1 = 20 x 10^-2</li>
</ul>
<p>4.  Now that they have the same exponents, add the values.</p>
<ul>
<li> 20 x 10^-2 + 1 x 10^2</li>
<li> (20 + 1) x 10^2</li>
<li> 21 x 10^2</li>
</ul>
<p>I dont think I have to expound any further. The above example speaks on how heavy it is to manipulate real numbers, or float / double data types. (Wait till you do floating point multiplication !!! <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ) As the number of floating point operations increase, the overhead acquired from real number usage is increased too.</p>
<p>Though I will no disscuss anymore, one more problem with floating points is its limitation / range problem. Well the “proving” part of this problem, I leave to those who read this blog.</p>
<p>However, though it is very difficult to compute floats, real numbers undeniably exist in the real world. The computer or processor has to comply with this. More so, there are so many benefits that come along speedy and accurate computations. And due to these benefits, some add FPUs (Floating Point Unit) into their computers. It also is now no wonder for me why today&#8217;s supercomputers are rated against Flops -&gt; Floating point operations per second. <em><strong>TRIVIA : At current, as of this writing, IBM&#8217;s Roadrunner holds the record for being first to sustain 1 petaflops (1 quadrillion operations/second).</strong></em></p>
<p>In closing, I finally realized that there was some sense to the instruction given to my friend. I may be wrong here about my conjecture, but I believe that the instruction came from an embedded engineer. I also remembered one of the advices, my previous embedded supervisor (in another company) gave me, “Avoid Floating.”</p>
<blockquote>
<h3><span style="color:#ffffff;">Again as I have said, I am not dissuading anybody from using floating points.</span></h3>
</blockquote>
<p>However, this learning has undoubtedly granted me the following realizations :</p>
<p>1. use floating points sparingly, when creating embedded applications<br />
2. in optimizing and speeding up solutions, check out and minimize the number of float computations<br />
3. should i need a real number, i would be inclined to use double<br />
4. I will always ask for a double cheese burger in McDonalds (hahahahah <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  just kidding &#8230;)</p>
<p>I hope you enjoyed this really really geeky blog from me. Let us enjoy learning together. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Resources :</p>
<p>1. <a href="http://en.wikipedia.org/wiki/IEEE_754">http://en.wikipedia.org/wiki/IEEE_754</a><br />
2. <a href="http://bytes.com/forum/thread161561.html">http://bytes.com/forum/thread161561.html</a><br />
3. <a href="http://pages.cs.wisc.edu/~smoler/x86text/lect.notes/arith.flpt.html">http://pages.cs.wisc.edu/~smoler/x86text/lect.notes/arith.flpt.html</a><br />
4. <a href="http://en.wikipedia.org/wiki/Flops">http://en.wikipedia.org/wiki/Flops</a></p>
<p><a href="http://s02.flagcounter.com/more/24FX"><img src="http://s02.flagcounter.com/count/24FX/bg=FFFFFF/txt=000000/border=CCCCCC/columns=2/maxflags=12/viewers=0/labels=0/" border="0" alt="free counters" /></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/govzlearnings.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/govzlearnings.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/govzlearnings.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/govzlearnings.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/govzlearnings.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/govzlearnings.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/govzlearnings.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/govzlearnings.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/govzlearnings.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/govzlearnings.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/govzlearnings.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/govzlearnings.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/govzlearnings.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/govzlearnings.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=39&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://govzlearnings.wordpress.com/2008/10/31/when-the-procesor-flops-floating-point-operations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6511d1fc22b5bc066e094e6b59505f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">govz</media:title>
		</media:content>

		<media:content url="http://s02.flagcounter.com/count/24FX/bg=FFFFFF/txt=000000/border=CCCCCC/columns=2/maxflags=12/viewers=0/labels=0/" medium="image">
			<media:title type="html">free counters</media:title>
		</media:content>
	</item>
		<item>
		<title>The Multi-Dimensional Software Engineer</title>
		<link>http://govzlearnings.wordpress.com/2008/10/07/the-multi-dimensional-software-engineer/</link>
		<comments>http://govzlearnings.wordpress.com/2008/10/07/the-multi-dimensional-software-engineer/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 07:44:17 +0000</pubDate>
		<dc:creator>govz</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[Programmin]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Embedded]]></category>
		<category><![CDATA[Engineering]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[software career path]]></category>

		<guid isPermaLink="false">http://govzlearnings.wordpress.com/?p=30</guid>
		<description><![CDATA[I am an Electronics and Communications Engineering graduate. When I was 10 or 12, I got fascinated with computers and learned how to code BASIC (Beginners All Purpose Symbolic Instruction Code.). My father introduced me to transistors and electronics by the age of 13 or 14. Nothing impressive as compared to the proteges I read [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=30&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am an Electronics and Communications Engineering graduate. When I was 10 or 12, I got fascinated with computers and learned how to code BASIC (Beginners All Purpose Symbolic Instruction Code.). My father introduced me to transistors and electronics by the age of 13 or 14. Nothing impressive as compared to the proteges I read on the news but good enough I guess to spark the fire within, so to speak.</p>
<p>I am currently deployed in Japan, working as an outsourced engineer. Be it so, I take pride in my job and the skills acquired as an outsourced Japanese speaking / writing engineer. (hahahah my nihongo is really embarassing, but my japanese friends say it is enough for now.)</p>
<p>For the past 7 or 8 years, I had been into firmware programming. I have met some of the most brilliant engineers both in Philippines and Japan. I have evolved from the &#8220;if-then&#8221; ( of BASIC to the &#8220;int main()&#8221; single thread of non-RTOS &#8220;C/C++&#8221; to the more complex multi-process multi-thread world of RTOS. I have coded several firmware specifically geared towards networking and some stuff with the Operating System/Kernel. In my current level of learning, I have come to the following conclusion that :</p>
<blockquote><p><strong>&#8220;A software engineer is multi-dimensional. It is fascinating, dumbfounding and very complex!!!&#8221;</strong></p></blockquote>
<p>I want to be good at what I do. I try to study as much though I may not live long enough to study everything. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  In my long list of things to study, are the following :</p>
<ul>
<li>Basic and Advacned UML &#8211; I know UML but not that great at it, I want to be good at this one.</li>
<li>Extreme Programming &#8211; Need to learn so that I can execute at will.</li>
<li>CMMI &#8211; (Capability Maturity Model Integration) Industry standard on development approaches</li>
<li>Java(SE) &#8211; hahahah my good friend Abraham suggests this. And i think it is time for an upgrade on my part.</li>
</ul>
<p>Before you proceed though, I want to caution you. What you might read here may be impossible to you as of the moment. But I hope you fear not the many challenges that you will face in your journey towards whatever visions you may have. Focus more on the joy of obtaining the skills through hard-earned study and effort. My Physics teacher once taught me, that <em><strong>&#8220;There is no room in learning when there is fear.&#8221; </strong></em>So fear not because it is difficult but hope that you may grow. Never compare yourself with others but compare yourself to yourself the day before yesterday. <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  So what if we all may not learn it all, but for the very least we have done due dilligence over what is asked of us as professional Software developers.</p>
<p>And should you be the type not motivated by optimism, Fear THIS : <strong><em>&#8220;The day will come when you will be measured. And the people hanging on the balance might be your wife and kids or probably a lifestyle you have grown accustomed to. Should you fail on that day, or should you be found wanting in the amount of dignity you put into your profession, I assure you the backlash will be so great that you will never ever grow out of it. An indellible, scar to your sense of professionalism.&#8221; </em></strong>The lack or preparation is the kiss of death, as one of the TV sitcoms (Will and Grace???) once said. Did I scare you enough? <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  hahahah so be OPTIMISTIC. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Do we need to be perfect? Hell NO! I too make tons of mistakes, some really really embarassing. Basic coding misses and vague design specifications are but some of the many mistakes I make on a daily basis. But be that as it may, our will to do things right (never repeating my mistakes) and the conscious effort to learn so that we can do things right, are more important than anything else. And that shines beyond our mistakes.</p>
<p>With that said, as far as I have read and learned personally, I write my learnings here. My learnings I share with those who deem themselves of lower skill level than I am and also for those better than me so that I can correct my viewpoint/s. I share this so that those who aspire for more can use all or parts of it, for their growth.</p>
<p>In my opinion, a software engineer&#8217;s dimension is as follows :</p>
<ol>
<li> <strong>Test Engineer</strong> &#8211; As essential to the design the code and almost everything else.</li>
<li> <strong>Programmer</strong> &#8211; Of syntax and discipline.</li>
<li> <strong>Developer</strong> &#8211; Of designing and planning micro, mini and large scale modules.</li>
<li> <strong>Administration Quality and Process Engineer</strong> &#8211; Of hastening the work flow process and at the same time increasing quality levels</li>
<li> <strong>Architect </strong> &#8211; Of designing micro, mini and super scale architectures on which all other modules will base on</li>
<li> <strong>Inventor</strong> &#8211; Of creating wonderful new technologies.</li>
<li> <strong>Technocrat</strong> &#8211; Being &#8220;THE MAN&#8221;, Defending the business interests with superior technology</li>
</ol>
<p>1.<strong> Test Engineer</strong> &#8211; Any engineer should be a good tester. My point here is simple, testing is an imperative step within the software development life cycle. The ability to create test routines should be fundamental to any engineer. And such tests should cover normal branches and to an EXTREME extent hypothetical cases which may have very low probability of happening. The better the testing mentality of the engineer, the higher the possibility that the code will be robust. Let me set an example :</p>
<p style="padding-left:30px;">/********** Code version 1 ***************/<br />
<strong>int32 SafeStringLen(char *my_string)</strong><br />
{<br />
return strlen(my_string); /* where string<br />
}</p>
<p>Any coder who thinks about test cases even before coding should realize that &#8220;my_string&#8221; has many possible values. And one of those values is NULL. Thus, with the above code, if &#8220;my_string&#8221; is null, strlen will crash into oblivion. My point being is that, the above code, to be able to achieve its best form, must be subjected to some form of mental agitation, a rigid test within the cranial fluids or mental-what-nots of the programmer.</p>
<blockquote>
<h4><strong>One simple rule : EXECUTE WITH A TEST IN MIND!</strong></h4>
</blockquote>
<p><strong>WARNING :</strong> Testing rigidly does not mean we test redundantly and stupidly. For example, in the above code, you dont have to test all possibilities. Basically as my normal rule follows there are four basic points to test.</p>
<ul>
<li> Lower than allowed  &#8211; values BELOW the range</li>
<li> More than allowed  &#8211; values BEYOND the possible range</li>
<li> Normal cases &#8211; valid values / test cases</li>
<li> Exceptions  &#8211; hypothetical cases</li>
</ul>
<p>So if I were to test the above code SafeStringLen():</p>
<ol>
<li>Lower than allowed &#8211; Not Applicable in this case</li>
<li>More than allowed &#8211; In heap I will allocate 2MByte and then fill it up with &#8220;1&#8243;, with last character set to the NULL Terminator. And then test.</li>
<li>Normal cases &#8211; (a) my_string = &#8220;abcde&#8221;  (b) my_string = &#8220;ab&#8221; (1 or 2  normal flow tests will be fine)</li>
<li>Exceptions / Special cases :
<ol>
<li>my_string = NULL</li>
<li>Zero-len string : my_string[0] = &#8221;</li>
<li>my_string = &#8220;abc&#8221; and then place the cross-compiled code in a big endian system ()</li>
</ol>
</li>
</ol>
<p>Remember that tests usually consume alot of time. And time costs money. That is why, any software engineer should be good in testing to minimize cost, while maximize robustness of codes.</p>
<p>2.     <strong>Programmer</strong> &#8211; As far as I am concerned, coding should be a software engineer&#8217;s passion. Coding&#8217;s focus is more on the programming language one is handling. For example if the design asks us to implement a dynamically created data, a coder, at his or her disposal should be intelligent enough to chose which one is best for a particular language. For Example :</p>
<pre>/* C Language create dynamic data */
#include &lt;stdio.h&gt;
#include &lt;malloc.h&gt;
struct MyStruct {
  int32 a;
  int32 b;
};
int main()
{
  struct MyStruct *sample = NULL;
  sample = (struct MyStruct *)calloc(1,sizeof(MyStruct));
  if (!sample) {
      printf("calloc has failed!");
  }
  else {
     printf("calloc has succeeded!");
  }
  return 0;
}</pre>
<p><strong>6 Important points :</strong><br />
1. In the initialization of the pointer, &#8220;= NULL&#8221; is used. (NULL) wont work with pure C compilers.<br />
2. And as a coder, I prefer calloc over malloc.<br />
3. The tester in me knows calloc or malloc can fail that is why I check it.<br />
4. In C compilers  &#8220;/* */&#8221; is the generic form of commenting.<br />
5. main() should never be void, most use integer as return type<br />
6. my current environment supports zero as successful operation so i return 0.</p>
<pre>/* C++ Language create dynamic data */
#include &lt;stdio.h&gt;
#include &lt;new&gt;
struct MyStruct {
  int a;
  int b;
};
int main()
{
  struct MyStruct *sample(NULL);
  sample = new(std::nothrow)(struct MyStruct);
  if (!sample) {
      printf("new has failed!");
  }
  else {
     printf("new has succeeded!");
  }
  return 0;
}</pre>
<p><strong>5 CRITICAL points :</strong><br />
1. sample_struct(NULL) will work this time.<br />
2. new() is used to create dynamic data, without the use of type casting.<br />
3. the test for failure is used by throw(), (try-catch can also be used here)<br />
4. For commenting, &#8220;//&#8221; can be used.<br />
5. &#8220;std::&#8221;,this is in reference to the std namespace of C++</p>
<p>NOTE : I am not really a C++ developer. And the throw part is really new to me. I just learned it today. So from now on I will use it. <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . As for the old codes, I feel guilty about them.</p>
<p>Anyways, this level for me is the hardest to measure. But the bottomline here is that, any coder judges well what commands, impliments and sequences are to be used. He watches out for fork() and execv() calls which messes up processes (and raises zombies) and other system calls/commands with debilitating results (if not done properly). A good coder can easily see through problems within the code, moreso also find other ways to generate the same result with different sets of commands. As in the example above. It is imperative for a software engineer to obtain the discipline of a good coder before he or she progresses to the next level.</p>
<p>In my opinion, the following candidates have good chances in becoming good coders :</p>
<p>1. People with good command of the english language. (Specifications of syntax are almost always in english.)<br />
2. People with good mathematic skills. (Mathematical solutions are architecture independent.)<br />
3. Regardless of 1 and 2, people who aspire to be good coders, who study by reading, reading, reading, coding, and coding. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Note : Recently I took a C/C++ exam. I got a score of 35 / 50. Not bad, but that means i have a great amount of learning ahead of me. The test I took online, was an amalgam of C and C++. Next Time I will take the paid exam. Also, next year I intend to take java certification as I was irked by the sad state of affairs of one of our projects in my organization. And for an upgrade on my part.</p>
<p><em>Next Time : The Continuation &#8230; (well once I have time &#8230; )</em></p>
<p><a href="http://s02.flagcounter.com/more/rdo"><img src="http://s02.flagcounter.com/count/rdo/bg=FFFFFF/txt=000000/border=CCCCCC/columns=2/maxflags=12/viewers=0/labels=0/" alt="free counters" border="0"></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/govzlearnings.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/govzlearnings.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/govzlearnings.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/govzlearnings.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/govzlearnings.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/govzlearnings.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/govzlearnings.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/govzlearnings.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/govzlearnings.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/govzlearnings.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/govzlearnings.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/govzlearnings.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/govzlearnings.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/govzlearnings.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=30&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://govzlearnings.wordpress.com/2008/10/07/the-multi-dimensional-software-engineer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6511d1fc22b5bc066e094e6b59505f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">govz</media:title>
		</media:content>

		<media:content url="http://s02.flagcounter.com/count/rdo/bg=FFFFFF/txt=000000/border=CCCCCC/columns=2/maxflags=12/viewers=0/labels=0/" medium="image">
			<media:title type="html">free counters</media:title>
		</media:content>
	</item>
		<item>
		<title>On Stack :: Starzan and Cheetae Question</title>
		<link>http://govzlearnings.wordpress.com/2008/08/03/starzan-and-cheetae-question/</link>
		<comments>http://govzlearnings.wordpress.com/2008/08/03/starzan-and-cheetae-question/#comments</comments>
		<pubDate>Sun, 03 Aug 2008 11:13:58 +0000</pubDate>
		<dc:creator>govz</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[Programmin]]></category>
		<category><![CDATA[stack]]></category>
		<category><![CDATA[stack guarding]]></category>
		<category><![CDATA[stack overflow]]></category>

		<guid isPermaLink="false">http://govzlearnings.wordpress.com/?p=14</guid>
		<description><![CDATA[Rommel-kun: char Starzan[strlen(Cheetae)]; Rommel-kun: bossing do you remember our conversation regarding the above code? Rommel-kun: What is the weakness of the above code? GovZ Repuspolo: ok game .. in your opinion what is its weakness &#8230; Rommel-kun: hmm &#8230;it is possible to fail if the string is empty&#8230; Rommel-kun: zero&#8230; Rommel-kun: ahhh Rommel-kun: wait i [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=14&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>Rommel-kun: <strong>char Starzan[strlen(Cheetae)];</strong><br />
Rommel-kun: bossing do you remember our conversation regarding the above code?<br />
Rommel-kun: What is the weakness of the above code?<br />
GovZ Repuspolo: ok game .. in your opinion what is its weakness &#8230;<br />
Rommel-kun: hmm &#8230;it is possible to fail if the string is empty&#8230;<br />
Rommel-kun: zero&#8230;<br />
Rommel-kun: ahhh<br />
Rommel-kun: wait i will verify with msdn &#8230;.<br />
GovZ Repuspolo: hahahahah<br />
Rommel-kun: there it is!<br />
Rommel-kun: strlen will return -1 if string contains invalid char<br />
Rommel-kun: haha<br />
Rommel-kun: is that the one?<br />
GovZ Repuspolo: hahahah partially correct<br />
Rommel-kun: partially? hahahaha it is like a new puzzle<br />
GovZ Repuspolo: ok let us try to share the answer on your question &#8230;<br />
GovZ Repuspolo: i will answer via my blog site &#8230;<br />
Rommel-kun: thanks<br />
GovZ Repuspolo:  no problem<br />
</em><br />
For everyone to understand, alwyn, rommel and I had dinner one time and i told them how i hated malloc, calloc and realloc. And as far as I can, I try to stay away from them, for reasons I will disclose further blogs. But for now, please accept the fact I hate the three commands.</p>
<p>In my avoidance of malloc() or any of its forms, I ended up using the following kind of technique :<br />
==============================<br />
/* C++ int32 = 32bit integer int8 = char */<br />
int32 vic_sotto(0);<br />
vic_sotto = function_that_returns_int32(2,5);<br />
int8 jimmy_santos[vic_sotto + 1];<br />
==============================<br />
Assuming the above code is valid according to the coding guidelines, there is an innate flaw to the code. But first let me get back to rommel&#8217;s responses &#8230;</p>
<blockquote><p>1. Rommel-kun: wait i will verify with msdn &#8230;.</p></blockquote>
<p>-&gt; 20 Points for attitude : ANY DEVELOPER SHOULD ALWAYS CHECK HIS OR HER PLATFORMS AUTHORITATIVE MANUAL &#8230; hmmm though this may be overkill, it is imperative, we check what we do not know. Especially windows implementations <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  (i have so many stories about windows interoperability&#8230; hahahah i can write a document about it. nahhh &#8230; not my style <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )</p>
<blockquote><p>2. Rommel-kun: strlen will return -1 if string contains invalid char</p></blockquote>
<p>-&gt; 10 points for attitude : <strong>Be patient until one finds an authoritative answer for a simple or complex question</strong>. In my experience though, most of the times the answer will elude you depending on the question&#8217;s level of difficulty.</p>
<p>However, as I have said, the answer is partially correct. In an embedded platform, and or in Windows for that matter, one should always think that any form of used resource has a limit. In this case, the <strong>STACK IS NOT INFINITE, NOTHING IS INFINITE</strong>. So therefore, aside from having a negative sized allocation, you may end up with something like :</p>
<p>==============================<br />
/* C++ int32 = 32bit integer int8 = char */<br />
int32 vic_sotto(0);<br />
vic_sotto = function_that_returns_int32(2000000,50000000);<br />
/* vic_sotto = 2,000,000,000 */<br />
int8 jimmy_santos[vic_sotto + 1];<br />
==============================</p>
<p>Now what do you think will happen? This is what I call stack failure (<a href="http://en.wikipedia.org/wiki/Stack_buffer_overflow">stack overflow</a>). You see for each process ( or thread or task) we create, the OS allocates a defined size for its <a href="http://en.wikipedia.org/wiki/Stack-based_memory_allocation">stack</a>. (As for the idea of stack, check wiki for it <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) This is where your local variables are stored temporarily. Once the function exits, (or thread/process/task for that matter) it releases the used memory.</p>
<p>The stack is the best place to get memory from, and the fastest. But in my experience it can be really really small in terms of size. For example, in one of the non-RTOS I have worked on, the stack size was only 8Kb. In one of my RTOS adventures, I came across a 2K byte stack. So whether you are in windows or not, or you have a hell of a freeway for stack &#8230; DONT ABUSE YOUR RESOURCES&#8230; its much like life too, never abuse your resources in life. <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So to correct the above code, assuming we still want to do it the same way :<br />
==============================<br />
/* C++ int32 = 32bit integer int8 = char */<br />
int32 vic_sotto(0);<br />
vic_sotto = function_that_returns_int32(2000000,50000000);<br />
/* guard the damn thing with a macro JOEY_DE_LEON = 20 */<br />
if  ((vic_sotto&lt;0) || (vic_sotto + 1 &gt;  JOEY_DE_LEON))  {<br />
return -1; /* function failure */<br />
}<br />
int8 jimmy_santos[vic_sotto + 1];<br />
==============================<br />
<strong><br />
</strong></p>
<blockquote><p><strong>Remember :<br />
1. When you can, if it is ok, use STACK.<br />
2. The STACK is NEVER INFINITE.<br />
3. Apply a guard appropriately.<br />
4. hehehe, for political reasons, follow the damned coding guidelines!!! <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
5. Only the stupid and arrogant think they are perfectly perfect. <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </strong></p></blockquote>
<p><strong></strong></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/govzlearnings.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/govzlearnings.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/govzlearnings.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/govzlearnings.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/govzlearnings.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/govzlearnings.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/govzlearnings.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/govzlearnings.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/govzlearnings.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/govzlearnings.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/govzlearnings.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/govzlearnings.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/govzlearnings.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/govzlearnings.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/govzlearnings.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/govzlearnings.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=14&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://govzlearnings.wordpress.com/2008/08/03/starzan-and-cheetae-question/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6511d1fc22b5bc066e094e6b59505f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">govz</media:title>
		</media:content>
	</item>
		<item>
		<title>Gian and me : Data types And Data sizes</title>
		<link>http://govzlearnings.wordpress.com/2008/07/10/gian-and-me-data-types-and-data-sizes/</link>
		<comments>http://govzlearnings.wordpress.com/2008/07/10/gian-and-me-data-types-and-data-sizes/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 17:07:28 +0000</pubDate>
		<dc:creator>govz</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[Programmin]]></category>

		<guid isPermaLink="false">http://govzlearnings.wordpress.com/?p=12</guid>
		<description><![CDATA[NOTE : Gian is a Java developer for the company I work for. She likes playing the guitar and Japanese songs. Thanks Gian for granting permission to post this. Gian: In C how many bits are there in a long data type? GovZ: I think it is 32 &#8230;. GovZ: Wait, I am checking on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=12&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>NOTE : Gian is a Java developer for the company I work for. She likes playing the guitar and Japanese songs. Thanks Gian for granting permission to post this. </p>
<p>Gian: In C how many bits are there in a long data type?<br />
GovZ: I think it is 32 &#8230;.<br />
GovZ: Wait, I am checking on the rules of c / c++<br />
GovZ: it can be 32 to 64 bits ..<br />
Gian: Is it platform dependent?<br />
GovZ: yup &#8230;<br />
GovZ: factors affecting data type include platform and i think compiler &#8230;<br />
GovZ: there are certain platforms with small sized registers<br />
Gian: Wow&#8230;<br />
GovZ: nahhh, i dont know everything that is why i study a lot &#8230;<br />
GovZ: like you do <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  &#8230;<br />
GovZ: Ok I will post this on my blog &#8230;<br />
GovZ: Gian and me : Data types And Data sizes &#8230;<br />
Gian: Really? &#8230;<br />
GovZ: Yup &#8230;<br />
GovZ: In c &#8230; one has to understand the value of sizeof() &#8230;<br />
GovZ: the command&#8217;s usefulness &#8230;.<br />
GovZ: So if you do not know the size &#8230; Just call sizeof(int)<br />
GovZ: If you want the platform&#8217;s integer size.<br />
GovZ: Hey I am going to make a tuna sandwich &#8230; want one?<br />
Gian: Can you send it via ym? the sandwich?<br />
Gian: haha &#8230;.<br />
Gian: I will not be able to sleep easy tonight &#8230;<br />
GovZ: hahaha it&#8217;s ok  &#8230;<br />
GovZ: save some learnings for tomorrow kid &#8230;.<br />
GovZ: To question fundamental questions &#8230;.<br />
GovZ: Means maturity in our profession &#8230;..<br />
GovZ: That is why we should be tormented souls &#8230;<br />
GovZ: Because it is only in ignorance that we can achieve bliss &#8230;<br />
GovZ: We should chose not to be ignorant &#8230;<br />
GovZ: at least while we are young &#8230;<br />
Gian: Hey GTG now <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Gian: I may not be able to sleep if &#8230;<br />
Gian: I continue to think about this &#8230;<br />
GovZ: nyty<br />
Gian: ok<br />
Gian: gud nyt<br />
Gian has signed out &#8230;.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/govzlearnings.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/govzlearnings.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/govzlearnings.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/govzlearnings.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/govzlearnings.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/govzlearnings.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/govzlearnings.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/govzlearnings.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/govzlearnings.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/govzlearnings.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/govzlearnings.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/govzlearnings.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/govzlearnings.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/govzlearnings.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/govzlearnings.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/govzlearnings.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=govzlearnings.wordpress.com&amp;blog=4077962&amp;post=12&amp;subd=govzlearnings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://govzlearnings.wordpress.com/2008/07/10/gian-and-me-data-types-and-data-sizes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6511d1fc22b5bc066e094e6b59505f8b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">govz</media:title>
		</media:content>
	</item>
	</channel>
</rss>
