<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4233584295994918105</id><updated>2011-08-29T19:30:24.009+05:30</updated><category term='linux'/><category term='vimdiff'/><category term='pexpect'/><category term='rational'/><category term='gdb'/><category term='Linux internals'/><category term='vi'/><category term='debugging'/><category term='seeders'/><category term='web'/><category term='development'/><category term='programming'/><category term='definition'/><category term='bash'/><category term='Linux for You'/><category term='clearcase'/><category term='python'/><category term='leechers'/><category term='torrent'/><category term='c language'/><category term='new technology'/><category term='testing'/><category term='ubuntu'/><category term='automation'/><category term='google'/><category term='tinyurl'/><title type='text'>Notorious Devil</title><subtitle type='html'>The Devil's Workshop</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>58</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-9152721638340703486</id><published>2011-06-10T01:12:00.002+05:30</published><updated>2011-06-10T01:12:04.103+05:30</updated><title type='text'>My new address:   http://freethreads.wordpress.com/</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;This blog has been moved to: http://freethreads.wordpress.com/&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-9152721638340703486?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/9152721638340703486/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=9152721638340703486' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/9152721638340703486'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/9152721638340703486'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2011/06/my-new-address-httpfreethreadswordpress.html' title='My new address:   http://freethreads.wordpress.com/'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-313152282496444159</id><published>2011-05-29T21:01:00.000+05:30</published><updated>2011-05-29T21:01:44.337+05:30</updated><title type='text'>NDMP: An open protocol to backup enterprise data</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;NDMP is an open protocol that enables backup/ restore of data in a heterogeneous environment. A real world case: You have two file servers(filer) from NetApp and EMC. And you want to backup your data without bothering about which filer you'd use.&lt;br /&gt;&lt;br /&gt;Here NDMP comes into play. If both the filers are running an NDMP server, you can seamlessly carry out backup and restore. You just concentrate on your backup operation and leave out the details of :&lt;br /&gt;- How data is stored ( you need to know data format though)&lt;br /&gt;- What operating system is running on the filer&lt;br /&gt;- Add/ remove a filer with no problem&lt;br /&gt;&lt;br /&gt;Extensive information: &lt;span class="f"&gt;&lt;cite&gt;www.&lt;b&gt;ndmp&lt;/b&gt;.org/&lt;/cite&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-313152282496444159?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/313152282496444159/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=313152282496444159' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/313152282496444159'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/313152282496444159'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2011/05/ndmp-open-protocol-to-backup-enterprise.html' title='NDMP: An open protocol to backup enterprise data'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-1559382640814743247</id><published>2011-04-08T23:36:00.000+05:30</published><updated>2011-04-08T23:36:21.197+05:30</updated><title type='text'>VMWare player vs VirtualBox: which is better?</title><content type='html'>I have a Windows XP host machine with guest Ubuntu OS. I started with the latest VMWare player and benefits I noticed:&lt;br /&gt;&lt;br /&gt;1. Hassle-free installation of Ubuntu&lt;br /&gt;2. Seamless integration between guest and host&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; o) You can copy-paste files across host and guest!&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; o) Clipboard is shared bi-directionally&lt;br /&gt;&lt;br /&gt;3. Very good performance: applications, network, and devices (DVD)&lt;br /&gt;4. Display scales well on bigger screen with VMWare tools. &lt;br /&gt;5. Alas! you can have at-max one processor simulated&lt;br /&gt;&lt;br /&gt;VirtualBox&lt;br /&gt;&lt;br /&gt;1. Easy Ubuntu installation&lt;br /&gt;2. Most horrible and pathetic clipboard sharing. Contrary to claimed, it provided one-way clipboard from guest to host. &lt;br /&gt;3. XP clipboard stopped working and never worked till I stopped VirtualBox.&lt;br /&gt;4. Supports VMDK files but it's crappy, buggy and leaves VMDK in an un-usable state. I could never run my VMDK with VMWare later.&lt;br /&gt;5. Can simulate up to 4 cores.&lt;br /&gt;6. Supports shared folder between host and guest. I think it's a generation behind what VMWare provides. &lt;br /&gt;7. Very slow performance: application, system start-up/ shutdown or stand-by. This is the biggest letdown.&lt;br /&gt;&lt;br /&gt;My verdict: VirtualBox has miles to go and I am using VMWare still :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-1559382640814743247?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/1559382640814743247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=1559382640814743247' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1559382640814743247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1559382640814743247'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2011/04/vmware-player-vs-virtualbox-which-is.html' title='VMWare player vs VirtualBox: which is better?'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-4034856358333906763</id><published>2011-03-25T08:31:00.000+05:30</published><updated>2011-03-25T08:31:09.546+05:30</updated><title type='text'>How to Upgrade Ubuntu guest in VmWare?</title><content type='html'>o) Get the ALTERNATE Ubuntu image from UBUNTU website. (I prefer using Torrent to get this file)&lt;br /&gt;A DESKTOP ISO will _NOT_ work! &lt;br /&gt;o) Now, it's a blatant lie that you would not need an Internet connection. You got to have it; if not, go and do something else.&lt;br /&gt;o) Okay, once you got you alternate ISO image ready, do the following:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;pre&gt;sudo mkdir -p /media/cdrom&lt;br /&gt;sudo mount -o loop ~/Desktop/ubuntu-10.10-alternate-i386.iso /media/cdrom&lt;/pre&gt;&lt;span class="anchor" id="line-56"&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;pre&gt;gksu "sh /media/cdrom/cdromupgrade"&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;&lt;copied from="" ubuntu="" website=""&gt;&lt;br /&gt;&lt;/copied&gt;&lt;br /&gt;&lt;br /&gt;o) Yup! that's pretty much you need to do.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-4034856358333906763?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/4034856358333906763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=4034856358333906763' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4034856358333906763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4034856358333906763'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2011/03/how-to-upgrade-ubuntu-guest-in-vmware.html' title='How to Upgrade Ubuntu guest in VmWare?'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-2750468145938406228</id><published>2011-03-23T20:42:00.000+05:30</published><updated>2011-03-23T20:42:48.525+05:30</updated><title type='text'>Corrupted VMWare VMDK file? How to fix?</title><content type='html'>o) Create a new VMWare machine of the same guest OS.&lt;br /&gt;o) Assign the corrupted VMDK file as additional HDD to the new machine. VMWare machine config allows you to add an existing HDD (VMDK file) to a machine.&lt;br /&gt;o) Browse your corrupted virtual HDD. Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-2750468145938406228?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/2750468145938406228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=2750468145938406228' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2750468145938406228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2750468145938406228'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2011/03/corrupted-vmware-vmdk-file-how-to-fix.html' title='Corrupted VMWare VMDK file? How to fix?'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-2536375869088026319</id><published>2011-02-15T23:03:00.000+05:30</published><updated>2011-02-15T23:03:28.342+05:30</updated><title type='text'>Understanding quirks of C: Structures</title><content type='html'>&lt;div class="Standard"&gt;Targeted audience&lt;/div&gt;&lt;div class="Standard"&gt;=============&lt;/div&gt;&lt;div class="Standard"&gt;C programmers&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;System information&lt;/div&gt;&lt;div class="Standard"&gt;==============&lt;/div&gt;&lt;div class="Standard"&gt;Linux ubuntu 2.6.32-25-generic #44-Ubuntu SMP i686 GNU/Linux &lt;/div&gt;&lt;div class="Standard"&gt;gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;Structure are the most popular user-defined data type in C. It allows an user to create new data type by packing different data types and use them with a single name. In this article we will discuss fundamental operations provided by C structures and their internal behavior. We'd use following structure for understanding the concepts.&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;----CODE----&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;struct test{&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp; char c;&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp; int a;&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp; char d;&lt;/div&gt;&lt;div class="Standard"&gt;};&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;----CODE----&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;A variable of type “structure test” would have following memory layout in the process stack. We are assuming that compiler padding is done for a 4-byte boundary.&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-ImVx5dyROac/TVq4g7bvnmI/AAAAAAAAEWA/-HzqgNY4Hes/s1600/mukt2.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="178" src="http://1.bp.blogspot.com/-ImVx5dyROac/TVq4g7bvnmI/AAAAAAAAEWA/-HzqgNY4Hes/s320/mukt2.bmp" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="center" class="Standard" style="text-align: center;"&gt;&amp;nbsp;&lt;b&gt;&lt;u&gt;&lt;span style="font-weight: bold;"&gt;Structure layout in memory&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div align="center" class="Standard" style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;Let's assign values to this structure variable.&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;----CODE----&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;struct test var = {'a', 10, 'b'};&lt;/div&gt;&lt;div class="Standard"&gt;struct test *ptr;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;ptr = &amp;amp;var;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;printf(“%c”, var.d);&lt;/div&gt;&lt;div class="Standard"&gt;printf(“%c”, *(ptr-&amp;gt;d));&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;----CODE----&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;b&gt;&lt;span style="font-weight: bold;"&gt;How do the member access expression “var.d” and “ptr-&amp;gt;d” work?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;“var.i”: This expression is converted by the compiler into two components:&lt;/div&gt;&lt;div class="Standard"&gt;&lt;b&gt;&lt;span style="font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;a) Base address of symbol 'var' and,&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;b&gt;&lt;span style="font-weight: bold;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b) Offset of symbol 'd' in the structure memory layout&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;Base address of the structure variable is “0x0000” in our example. Next, compiler finds the distance of 'd' from the base. The distance is 8 bytes (1+3+4).&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;Similarly, “ptr-&amp;gt;d” is also factored in mentioned manner, and address of member 'd' is returned.&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;b&gt;&lt;span style="font-weight: bold;"&gt;How to calculate a member's byte offset in a given structure&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;In a trivial manner, we can calculate offset of member 'd' by getting the address of &lt;u&gt;first&lt;/u&gt; element of the structure i.e. 'c' and then finding the difference with address of 'd'.&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;----CODE----&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;offset_of_d = (&amp;amp;var.d - &amp;amp;var.c);&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;----CODE----&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;The difference of these two addresses would fetch us the offset of 'd'. “&amp;amp;(var.c)” fetches us the base address of the structure.&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;The statement &amp;amp;(var.d) would be treated as  = (Base address of variable 'var' + distance of 'd' from the base).&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;b&gt;&lt;span style="font-weight: bold;"&gt;Efficient method to find the offset of a structure member&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;i&gt;If we could set the base address to zero in above equation, we would directly get the offset of 'd' i.e. 8.&lt;/i&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;We can accomplish this as follows:&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;----CODE----&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;#define POINTER ((struct test*)(0))&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;int main()&lt;/div&gt;&lt;div class="Standard"&gt;{&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp;  unsigned int x;&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp;  x = &amp;amp;(POINTER-&amp;gt;d);&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp;  printf("\nOffset of d = %d\n", x);&lt;/div&gt;&lt;div class="Standard"&gt;}&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;----CODE----&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;The macro “POINTER” expands to “&amp;amp;(((struct test*) (0))-&amp;gt;d)”.&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;We are typecasting '0' as an address, pointing to type of data 'struct test'. Now when you do “&amp;amp;(((struct test*)(0))-&amp;gt;d)”,  it is fetching the address of 'd' as:&lt;/div&gt;&lt;div class="Standard"&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  (Base address + offset of d in the structure).&lt;/i&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;Since base address is set to zero, we are left with the offset of 'd'. We are tricking the compiler by giving base address as zero.  This trick will work irrespective of compiler's padding scheme.&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;Both the discussed approaches lack portability though, and hence may suffer with incorrect output on different hardware. Another portable way to accomplish the same is with the help of “offsetof” macro, defined in header file stddef.h. The macro 'offsetof' accepts two arguments:&lt;/div&gt;&lt;div class="Standard" style="margin-left: 0pt;"&gt;&lt;span style="font-family: &amp;quot;OpenSymbol&amp;quot;;"&gt;– &lt;/span&gt;The structure definition, so you don't need to create a structure variable&lt;/div&gt;&lt;div class="Standard" style="margin-left: 0pt;"&gt;&lt;span style="font-family: &amp;quot;OpenSymbol&amp;quot;;"&gt;– &lt;/span&gt;The member element, for which the offset is to be calculated. &lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;This macro too takes care of structure padding of elements, performed by the compiler.&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;------CODE------&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;#include "stddef.h"&lt;/div&gt;&lt;div class="Standard"&gt;int main()&lt;/div&gt;&lt;div class="Standard"&gt;{&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp; unsigned int x = offsetof(struct test, d);&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp; printf("\nOffset of d = %d\n", x);&lt;/div&gt;&lt;div class="Standard"&gt;}&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;------CODE--------&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;b&gt;&lt;span style="font-weight: bold;"&gt;How “sizeof” behave in a quaint manner, where syntactically you find a NULL pointer dereference?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;Consider the following code:  &lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;----CODE-----&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;struct test{&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp; char c;&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp; int a;&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp; char d;&lt;/div&gt;&lt;div class="Standard"&gt;};&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;int main()&lt;/div&gt;&lt;div class="Standard"&gt;{&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp;   // Define a dangling pointer of type struct test &lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp;   struct test *p;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp;   // Getting the size of the structure with an uninitialized pointer &lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp;   printf("%u", sizeof(*p));&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp;   printf("%u", sizeof(p));&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp;   // Try it with one of implicit types like 'char' &lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp;   char *i= 'a';&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp;   printf("%u", sizeof(*i)); // Displays 1, as the size needed to store a character&lt;/div&gt;&lt;div class="Standard"&gt;}&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;----CODE----&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;If you dereference a pointer inside “sizeof” operator, it fetches the size of data-type, the pointer is pointing to, i.e. 12 bytes for “struct test”.&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&amp;nbsp;It is because sizeof operator works on “data type”, not data. And interestingly, it works for both internal types and language defined types. So, when you dereference a pointer inside sizeof; you are asking for the number of bytes pointee would need in the memory.&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;----CODE----&lt;/div&gt;&lt;div class="Standard"&gt;char *c;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;// It would fetch you result as 1 byte.&lt;/div&gt;&lt;div class="Standard"&gt;sizeof(*c);&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;----CODE----&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;Remember that it is illegal to dereference a dangling pointer otherwise.  In the mentioned code, you do not dereference the address carried by the pointer, and hence never get a classic segmentation fault error.&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;Hope you enjoyed these interesting facts of C. Please share your comments and suggestions.&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;----References----&lt;/div&gt;&lt;div class="Standard"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="Standard"&gt;[1] &lt;a href="http://en.wikipedia.org/wiki/Offsetof"&gt;http://en.wikipedia.org/wiki/Offsetof&lt;/a&gt;&lt;/div&gt;&lt;div class="Standard"&gt;[2] &lt;a href="http://en.wikipedia.org/wiki/Struct_%28C_programming_language"&gt;http://en.wikipedia.org/wiki/Struct_(C_programming_language&lt;/a&gt;)&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-2536375869088026319?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/2536375869088026319/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=2536375869088026319' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2536375869088026319'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2536375869088026319'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2011/02/understanding-quirks-of-c-structures.html' title='Understanding quirks of C: Structures'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-ImVx5dyROac/TVq4g7bvnmI/AAAAAAAAEWA/-HzqgNY4Hes/s72-c/mukt2.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-828953976420661879</id><published>2011-02-01T22:50:00.000+05:30</published><updated>2011-02-01T22:50:42.659+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='gdb'/><category scheme='http://www.blogger.com/atom/ns#' term='debugging'/><title type='text'>How to debug with GDB: Philosophy</title><content type='html'>Debugging is an art.&lt;br /&gt;&lt;br /&gt;In general, debugging is the most admired tool in the developer's arsenal. My points in this article are related to GNU GDB debugger, for Linux operating system.&lt;br /&gt;&lt;br /&gt;What is your first reaction when you see a core-dump?&lt;br /&gt;&lt;br /&gt;Let's debug it!&lt;br /&gt;&lt;br /&gt;Hold-on. Wait, and first ruminate over the problem. I'd suggest performing a few rituals before treading on to debugging would be helpful in saving time and effort.&lt;br /&gt;&lt;br /&gt;o) Try to reproduce the problem. Ensure problem is consistent.&lt;br /&gt;&lt;br /&gt;o) Check for the logs emitted by the application. If not available, see if you could get the logs.&lt;br /&gt;&lt;br /&gt;o) Note down the application configuration, including the input, system configuration and every tiny detail that makes sense to you.&lt;br /&gt;&lt;br /&gt;o) Okay, check the stack-frames with "backtrace".&lt;br /&gt;&lt;br /&gt;o) You may inquire about frame locals and dig-in parent frames as well.&lt;br /&gt;&lt;br /&gt;o) Also, it's useful to have a look at the code and a 2-3 level dry-run of code to reach at the point of failure. So, say you have a stack-trace as:&lt;br /&gt;    foo()&lt;br /&gt;    bar()&lt;br /&gt;    pop()&lt;br /&gt;    top() --&gt; dumps core&lt;br /&gt;    hop()&lt;br /&gt;&lt;br /&gt;Check how did we reach till top from say bar(). Look out for any ancillary function call in meanwhile and report its side-effect.&lt;br /&gt;&lt;br /&gt;Remember, debugging is more than digging-deep; it's understanding the code tree and it's branches. Always approach to the problem on a high level, think what might have caused this failure.&lt;br /&gt;&lt;br /&gt;Then, just jump in.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-828953976420661879?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/828953976420661879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=828953976420661879' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/828953976420661879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/828953976420661879'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2011/02/how-to-debug-with-gdb-philosophy.html' title='How to debug with GDB: Philosophy'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-5170743713903082917</id><published>2011-01-29T01:44:00.000+05:30</published><updated>2011-01-29T01:44:23.812+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux for You'/><title type='text'>Publication in Linux For You, January, 2011: Python threading and its Caveats</title><content type='html'>My friend and I had got the article "Python threading and its Caveats" published in prestigious Linux for You magazine. The article is part of Jan, 2011 edition.&lt;br /&gt;&lt;br /&gt;What a great treat of new year!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-5170743713903082917?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/5170743713903082917/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=5170743713903082917' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/5170743713903082917'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/5170743713903082917'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2011/01/publication-in-linux-for-you-january.html' title='Publication in Linux For You, January, 2011: Python threading and its Caveats'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-6003627263120696415</id><published>2011-01-29T01:40:00.000+05:30</published><updated>2011-01-29T01:40:43.638+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='c language'/><title type='text'>Best C coding practices: Saving many hours of efforts</title><content type='html'>C code has potential to be very compact, often at a price of losing comprehensibility and maintainability.&lt;br /&gt;&lt;br /&gt;Let's discuss a few tips that might put smile on your face in a distress time.&lt;br /&gt;&lt;br /&gt;o) Always save return value from a function, if available&lt;br /&gt;&lt;br /&gt;if(!myfun()) {...}&lt;br /&gt;&lt;br /&gt;This is very poor coding style. If myfun() can return one out of hundreds of non-zero error codes, it makes sense to save the return value.&lt;br /&gt;&lt;br /&gt;if( (ret = myfun()) != 0 )&lt;br /&gt;&lt;br /&gt;This value would help you in&lt;br /&gt;o) zero down the point of return&lt;br /&gt;o) debugging as  "ret" is now part of the caller's frame and hence available for examination.&lt;br /&gt;&lt;br /&gt;o) An extra log message would cause less harm than being savvy and avoiding it. It is tantamount to have enough log messages embedded in your code at critical points. Trust me, it makes your life so easy. Logging in itself is a vast topic and, I plan to take that separately.&lt;br /&gt;&lt;br /&gt;o) Comments should be added generously. Explain what a file, function is doing. Explain the algorithm, input/output parameters of a function and return types.&lt;br /&gt;If your function allocates dynamic memory, who bears the burden of freeing that memory, be explicit and mention that.&lt;br /&gt;&lt;br /&gt;o) Keep a function "static" unless you need it in other file of the project. This saves linkers effort.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-6003627263120696415?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/6003627263120696415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=6003627263120696415' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/6003627263120696415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/6003627263120696415'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2011/01/best-c-coding-practices-saving-many.html' title='Best C coding practices: Saving many hours of efforts'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-8694458646293600994</id><published>2010-12-01T23:25:00.000+05:30</published><updated>2010-12-01T23:25:19.962+05:30</updated><title type='text'>goto vs return statement: C programming</title><content type='html'>It is a classic conflict of opinion when comes to choosing between goto and return.&lt;br /&gt;&lt;br /&gt;I feel that goto is treated unfairly, biased, and unjustly. Why people are so paranoid about avoiding goto, is beyond my comprehension.&lt;br /&gt;&lt;br /&gt;Let me explain my point with following example:&lt;br /&gt;&lt;br /&gt;void foo()&lt;br /&gt;{&lt;br /&gt;  if{...}&lt;br /&gt;  if{...}&lt;br /&gt;  if{...}&lt;br /&gt;  if{...}&lt;br /&gt;  if{...}&lt;br /&gt;  if{...}&lt;br /&gt;  if{...}&lt;br /&gt;  if{...}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Now if I populate the body of "if" with "return"; it is perfectly okay. It creates problems in later point of time.&lt;br /&gt;&lt;br /&gt;Now, say you allocate a resource in foo(), where would you free it?&lt;br /&gt;&lt;br /&gt;Going with "return" makes you free the resource in all "if" conditions that follow the place where you have allocated the reosurce.&lt;br /&gt;&lt;br /&gt;Now, solve this problem with goto. All "if" should goto a single label, which would be placed at the end of the foo().&lt;br /&gt;&lt;br /&gt;So, the clean-up work can now be placed under this label. This is much better than "return" statements:&lt;br /&gt;&lt;br /&gt;- Code is more exensible. You may add more "if" conditions, without any fear of resource leaks.&lt;br /&gt;&lt;br /&gt;- Avoids code duplication&lt;br /&gt;&lt;br /&gt;- Even if the current function do not need "goto", I propose to use "goto" for future extensibility.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-8694458646293600994?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/8694458646293600994/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=8694458646293600994' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/8694458646293600994'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/8694458646293600994'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/12/goto-vs-return-statement-c-programming.html' title='goto vs return statement: C programming'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-727003332078131647</id><published>2010-11-13T21:41:00.000+05:30</published><updated>2010-11-13T21:41:29.939+05:30</updated><title type='text'>The best virtualization software: VirtualBox v/s VMPlayer</title><content type='html'>I was an avid user of VirtualBox and was pretty happy with it. It gave me freedom to experiment with different OS in a rather safe, transparent, and convenient way. So I used to keep Linux as host and Windows as guest. Performance was good and bugs were non-existent.&lt;br /&gt;&lt;br /&gt;Then I found VMPlayer. It surprised me a lot with following reasons:&lt;br /&gt;&lt;br /&gt;a) It supported ISO images for Ubuntu, my fav Linux disto.&lt;br /&gt;&lt;br /&gt;b) Set up was easier/comparable to VirtualBox.&lt;br /&gt;&lt;br /&gt;c) Unity mode: What a feature! A seemless integration of guest OS with host application. You don't have to click the mouse, you never lose window focus. I can now browse through guest OS with Alt+Tab.&lt;br /&gt;&lt;br /&gt;d) Very stable, good performance, and I am a happy customer.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-727003332078131647?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/727003332078131647/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=727003332078131647' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/727003332078131647'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/727003332078131647'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/11/best-virtualization-software-virtualbox.html' title='The best virtualization software: VirtualBox v/s VMPlayer'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-496612653310438048</id><published>2010-10-20T23:43:00.000+05:30</published><updated>2010-10-20T23:43:52.239+05:30</updated><title type='text'>How tail -f work?</title><content type='html'>"tail -f" is a special command in a way that it polls the specified file for any change and prints the new stuff on the fly. It is very helpful in observing logs and any event based data.&lt;br /&gt;&lt;br /&gt;Ever wondered how tail achieves this?&lt;br /&gt;&lt;br /&gt;"tail" opens the given file and obtains the file-descriptor. It opens it with xfreopen() -&gt; freopen() -&gt; fopen() call. It does its first round of fstat() on the file as well.&lt;br /&gt;&lt;br /&gt;Once it has got the fd, it loops infinitely and do the following:&lt;br /&gt;&lt;br /&gt;It does fstat() of the file and observes the mtime value. If the mtime value is changes from the last time..it dumps the data. To print the latest data, it lseek() the file to the last reported file size.&lt;br /&gt;&lt;br /&gt;Source: http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/tail.c&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-496612653310438048?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/496612653310438048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=496612653310438048' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/496612653310438048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/496612653310438048'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/10/how-tail-f-work.html' title='How tail -f work?'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-6841802694074518188</id><published>2010-09-19T21:56:00.000+05:30</published><updated>2010-09-19T21:56:43.193+05:30</updated><title type='text'>How touchpad of a laptop work?</title><content type='html'>It was a curiosity to know the internal details of one of the most used 6x6 cm2 part of a laptop. My curiosity increased with diffrent behavior of the touchpad with different objects. For example, it works well with fingers but a pen, pin, or paper are not entertained.&lt;br /&gt;&lt;br /&gt;So how does it work?&lt;br /&gt;&lt;br /&gt;It is based on concept of capacitive difference on two parallel plates. Each of these plates have a grid of conductors. When we put our finger on the surface, it creates a charge difference on this surface and the difference of capacitance is sensed by the hardware.&lt;br /&gt;&lt;br /&gt;This difference is mapped to mouse motion on our screen.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-6841802694074518188?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/6841802694074518188/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=6841802694074518188' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/6841802694074518188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/6841802694074518188'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/09/how-touchpad-of-laptop-work.html' title='How touchpad of a laptop work?'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-2249317639772093741</id><published>2010-09-16T00:29:00.000+05:30</published><updated>2010-09-16T00:29:45.379+05:30</updated><title type='text'>MeeGo: Marriage of Nokia and Intel</title><content type='html'>Nokia and Intel are merging their Linux based intiatives: Meamo and Moblin = Meego&lt;br /&gt;&lt;br /&gt;* Open source platform to serve mobiles, notebook, TV, and tablets.&lt;br /&gt;* Hosted under Linux Foundation&lt;br /&gt;* Support x86 and ARM&lt;br /&gt;* Visit http://meego.com for more information&lt;br /&gt;&lt;br /&gt;But why would people use this new OS? What's wrong with Andriod? How is it better than Symbion, Android, Windows Mobile or BADA?&lt;br /&gt;&lt;br /&gt;We already have Linux based mobile OS, so it'd be hard for this new guy to find a decent place.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-2249317639772093741?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/2249317639772093741/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=2249317639772093741' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2249317639772093741'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2249317639772093741'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/09/meego-marriage-of-nokia-and-intel.html' title='MeeGo: Marriage of Nokia and Intel'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-1366038570592321454</id><published>2010-09-06T22:37:00.000+05:30</published><updated>2010-09-06T22:37:59.097+05:30</updated><title type='text'>Uninterrupted Linux session : screen command</title><content type='html'>Have you ever faced losing connections to a remote machine(e.g. from a putty) and you happened to be in middle of a script that took ten hours to complete. So what would you do??&lt;br /&gt;&lt;br /&gt;Restart the script after re-connecting.&lt;br /&gt;&lt;br /&gt;Not anymore...&lt;br /&gt;&lt;br /&gt;Linux screen solves this problem with providing a terminal that runs on server and just exported to your putty/Terminal client. In simple terms, you are running your putty on remote machine and watching the output on your local client.&lt;br /&gt;&lt;br /&gt;Now, if you client goes down, just chill!&lt;br /&gt;&lt;br /&gt;Screen is running your script on remote machine.&lt;br /&gt;&lt;br /&gt;To start a screen session:&lt;br /&gt;- Login to remote machine with as you may wish.&lt;br /&gt;- Run $screen&lt;br /&gt;- Do you stuff&lt;br /&gt;&lt;br /&gt;Power cut and, no net connection and your client is down.&lt;br /&gt;&lt;br /&gt;Once power is back, just re-login to remote machine.&lt;br /&gt;and issue:&lt;br /&gt;$screen -r&lt;br /&gt;&lt;br /&gt;It'll list all screen sessions running on the remote machine. Get attached to one of the session with:&lt;br /&gt;&lt;br /&gt;$session -r &lt;screen_session_&gt;&lt;br /&gt;&lt;br /&gt;Now,&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-1366038570592321454?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/1366038570592321454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=1366038570592321454' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1366038570592321454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1366038570592321454'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/09/uninterrupted-linux-session-screen.html' title='Uninterrupted Linux session : screen command'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-7999724181487455259</id><published>2010-08-21T21:11:00.001+05:30</published><updated>2010-08-21T21:11:12.829+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='automation'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><category scheme='http://www.blogger.com/atom/ns#' term='pexpect'/><title type='text'>Expect Pexpect: Python module to help you automate interactive tests</title><content type='html'>Many a times we encounter writing a code that requires user input to proceed. Testing and validating such an application can become tedious and frustating. Python implements an elegant solution to cut down the effort needed to "talk to application".&lt;br /&gt;&lt;br /&gt;This is called pexpect module, borrowed from Tcl "expect". Pexpect is a tool for controlling and automoating programs. It simple "fools" the application with an user input. It runs the program and monitors the output. When output matches a given pattern, it respond to application mimicking the human intervention.&lt;br /&gt;&lt;br /&gt;Pexpect can be extensively used in testing and automation. I found it particularly useful for interacting with application like ssh, ftp, passwd, telnet etc.&lt;br /&gt;&lt;br /&gt;It comes packaged with standard Ubuntu 9.10. The version of Python used by me is:&lt;br /&gt;&lt;br /&gt;$python --version&lt;br /&gt;Python 2.6.4rc2&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-7999724181487455259?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/7999724181487455259/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=7999724181487455259' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/7999724181487455259'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/7999724181487455259'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/08/expect-pexpect-python-module-to-help.html' title='Expect Pexpect: Python module to help you automate interactive tests'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-8798331040942599073</id><published>2010-07-31T20:22:00.000+05:30</published><updated>2010-07-31T20:22:15.366+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='development'/><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><title type='text'>Half century of technical know-how sharing</title><content type='html'>It's 50th post on this blog. I am happy with my contribution. Learning is a continuous process and I am an active participant. Today's post will talk of something that I had never imagined to do in my development career: Testing.&lt;br /&gt;&lt;br /&gt;Testing of the product is an interesting job, especially when you are a new user. Past two weeks, I am testing the product I'd be developing.&lt;br /&gt;&lt;br /&gt;I'm sharing my experience here: &lt;br /&gt;&lt;br /&gt;- Don't test just for sake of doing it; Understand the ecosystem in which your product would be working.&lt;br /&gt;- Take generous logs of your testing.&lt;br /&gt;- Keep an eye on what you can improve: Be it a process or a feature.&lt;br /&gt;- Try to automate processes if possible.&lt;br /&gt;- Try feeding weird input to your product. &lt;br /&gt;- Testing is learning. You become a very good user of your product.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-8798331040942599073?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/8798331040942599073/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=8798331040942599073' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/8798331040942599073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/8798331040942599073'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/07/half-century-of-technical-know-how.html' title='Half century of technical know-how sharing'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-1449419153591661374</id><published>2010-06-18T00:58:00.001+05:30</published><updated>2010-06-18T00:58:33.905+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='vi'/><category scheme='http://www.blogger.com/atom/ns#' term='bash'/><title type='text'>Bash Command fo you</title><content type='html'>Once again, I am sharing a few good commands with you.&lt;br /&gt;&lt;br /&gt;a) Run command in a subshell&lt;br /&gt;$(cd /tmp &amp;&amp; ls)&lt;br /&gt;&lt;br /&gt;# You will see the contents of /tmp but will stay in PWD only.&lt;br /&gt;&lt;br /&gt;b) Reusing cscope database&lt;br /&gt;$cscope -d&lt;br /&gt;&lt;br /&gt;c) If you default shell is csh, and you want to move to bash as soon as you login&lt;br /&gt;- Create a file .cshrc in your home directory.&lt;br /&gt;- Edit and add "bash"&lt;br /&gt;- Save and exit.&lt;br /&gt;&lt;br /&gt;d) vi can help you see a split screen with two or more files. Try :vsplit.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-1449419153591661374?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/1449419153591661374/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=1449419153591661374' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1449419153591661374'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1449419153591661374'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/06/bash-command-fo-you.html' title='Bash Command fo you'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-5409594046925994297</id><published>2010-05-19T22:27:00.000+05:30</published><updated>2010-05-19T22:27:49.053+05:30</updated><title type='text'>Ubuntu 9.10 on Windows XP: Virtual Box</title><content type='html'>My office laptop has Windows XP installed and I need Windows for sake of Outlook and Communicator. So I started to look out for alternative for having Linux on my laptop. There were three options suggested by different people:&lt;br /&gt;&lt;br /&gt;- Get Ubuntu installed and run Windows XP as a guest on VirtualBox.&lt;br /&gt;Now my workplace's IT guys do not install Windows on a VM, so they asked me to create an image of the Windows installed on my laptop. I searched for software to accomplish this and tried a few in vain. I tried a software called WinDD to copy Windows image to my portable HDD and since I did not checked thoroughly where it was copying, I got my portable HDD corrupted. It caused me a lot of pain, my important docs and many pics just got shredded.&lt;br /&gt;Well that was it. I dropped this option.&lt;br /&gt;&lt;br /&gt;- Get the Ubuntu on a pen-drive(PD) and make your PD boot-able.&lt;br /&gt;It had a problem that Ubuntu installation was not persistent. Many of my setting could not be saved. Though I got a way to create a persistent image, still it can't save a few things like system time. Verdict: Dropped&lt;br /&gt;&lt;br /&gt;- Get the Ubuntu running as a guest on host Windows.&lt;br /&gt;After installing the guest additions, I am very happy with the screen resolution. I got few glitches with network setting and shared folders help. I got over them and will post the details in the next post.&lt;br /&gt;&lt;br /&gt;So I am a happy man now, seeing my Ubuntu running on XP. All happy and gay!&lt;br /&gt;&lt;br /&gt;PS: I am a fan of VirtualBox and so far have not used any other VM software.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-5409594046925994297?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/5409594046925994297/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=5409594046925994297' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/5409594046925994297'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/5409594046925994297'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/05/ubuntu-910-on-windows-xp-virtual-box.html' title='Ubuntu 9.10 on Windows XP: Virtual Box'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-1418075854024339116</id><published>2010-04-26T21:36:00.000+05:30</published><updated>2010-04-26T21:36:12.868+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='leechers'/><category scheme='http://www.blogger.com/atom/ns#' term='definition'/><category scheme='http://www.blogger.com/atom/ns#' term='torrent'/><category scheme='http://www.blogger.com/atom/ns#' term='google'/><category scheme='http://www.blogger.com/atom/ns#' term='seeders'/><title type='text'>Torrent: Demystified</title><content type='html'>What is a torrent?&lt;br /&gt;&lt;br /&gt;A torrent is like a broker between a customer and a seller. It works in a peer-to-peer setup that means a true democracy; all are equal, no master-no slave.&lt;br /&gt;&lt;br /&gt;So you need to download a classic movie, which may be on a computer(s), located anywhere across the globe.&lt;br /&gt;&lt;br /&gt;How would you know where is it?&lt;br /&gt;&lt;br /&gt;Torrent comes to help you here. You google for a torrent of this movie. Download the torrent and voila!.&lt;br /&gt;&lt;br /&gt;Torrent has three primary components:&lt;br /&gt;&lt;br /&gt;a) Seeders: People that have a copy of the movie you want&lt;br /&gt;b) Leechers: That's you!&lt;br /&gt;c) Torrent file : It has information about seeders and leechers.&lt;br /&gt;&lt;br /&gt;While you are downloading your movie, torrent share the downloaded part with anyone else interested in downloading the same movie. So effectively every leecher becomes a seeder. Now you are even! Hail Democracy!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-1418075854024339116?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/1418075854024339116/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=1418075854024339116' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1418075854024339116'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1418075854024339116'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/04/torrent-demystified.html' title='Torrent: Demystified'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-4416143231156409408</id><published>2010-04-11T22:17:00.000+05:30</published><updated>2010-04-11T22:17:34.854+05:30</updated><title type='text'>Ubuntu 9.10: Wireless network problem with Broadcom Corporation BCM4312</title><content type='html'>Many laptops with Broadcom Corporation BCM4312 802.11b/g hardware shows no response to wireless network with Ubuntu 9.10 Casper.&lt;br /&gt;&lt;br /&gt;I could solve this problem with the following method:&lt;br /&gt;&lt;br /&gt;a) Go to System-&gt; Administration-&gt;Hardware Drivers&lt;br /&gt;   Keep your system on Internet(wired ethernet) while doing this.&lt;br /&gt;&lt;br /&gt;   Install Broadcom 43 and Broadcom STA driver, activate them then.&lt;br /&gt;&lt;br /&gt;b) Reboot and see if it work for you.&lt;br /&gt;&lt;br /&gt;c) If not, then do the following:&lt;br /&gt;&lt;br /&gt;          sudo apt-get --purge remove bcmwl-kernel-source&lt;br /&gt;          sudo apt-get install patch&lt;br /&gt;          sudo apt-get install bcmwl-kernel-source&lt;br /&gt;&lt;br /&gt;This should solve the matter. At least it worked for me :)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Ref: Ubuntu Forum&lt;br /&gt;http://ubuntuforums.org/showthread.php?t=1347483&lt;br /&gt;http://ubuntuforums.org/showthread.php?t=1043168&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-4416143231156409408?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/4416143231156409408/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=4416143231156409408' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4416143231156409408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4416143231156409408'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/04/ubuntu-910-wireless-network-problem.html' title='Ubuntu 9.10: Wireless network problem with Broadcom Corporation BCM4312'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-2247490703808504809</id><published>2010-04-07T12:15:00.000+05:30</published><updated>2010-04-07T12:15:19.378+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><title type='text'>Running Ubuntu 9.10 Casper On your PC</title><content type='html'>A complete solution: Image Writing to Installation&lt;br /&gt;&lt;br /&gt;Ubuntu is a free open source Linux distribution, primarily for desktop users. There are many reasons to use Ubuntu instead of other Linux distro(Just Google for it).&lt;br /&gt;&lt;br /&gt;I am assuming that reader is an Ubuntu user on a x86 system and knows some stuff about Linux.&lt;br /&gt;&lt;br /&gt;o) First thing is get the latest Ubuntu bundle(an .iso file) from Ubuntu website.&lt;br /&gt;o) Now get a pen drive.&lt;br /&gt;o) From "Application" menu, run USB creator.&lt;br /&gt;   Give the path of iso file and click create USB drive.&lt;br /&gt;   + If pendrive is more than 4GB, You would get an error saying "partition not found":&lt;br /&gt;     Just do the following:&lt;br /&gt;     * Install gparted utility with Synopsis Bundle Manger&lt;br /&gt;     * Create a partition table with "gparted" on your pendrive&lt;br /&gt;     * Now create a FAT32 partition of size 1000MB on this pendrive&lt;br /&gt;o) Run USB startup disk creator again.&lt;br /&gt;&lt;br /&gt;o) Voila! You are done&lt;br /&gt;&lt;br /&gt;Benefits:&lt;br /&gt;o) You save money spent on CD/DVD to write Ubuntu image.&lt;br /&gt;o) This method is very fast and reliable, compared to use of optical media.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-2247490703808504809?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/2247490703808504809/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=2247490703808504809' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2247490703808504809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2247490703808504809'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/04/running-ubuntu-910-casper-on-your-pc.html' title='Running Ubuntu 9.10 Casper On your PC'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-7029388527076860637</id><published>2010-03-25T19:37:00.000+05:30</published><updated>2010-03-25T19:37:44.806+05:30</updated><title type='text'>Thread stack in heap (pthreads)</title><content type='html'>I had known that a thread has a stack. But never thought where is this stack lie in the memory?&lt;br /&gt;&lt;br /&gt;Well, it should be process stack. But you can set the thread stack to a heap area.&lt;br /&gt;&lt;br /&gt;How to do that?&lt;br /&gt;&lt;br /&gt;#include "pthread.h"&lt;br /&gt;#include "stdio.h"&lt;br /&gt;#include "unistd.h"&lt;br /&gt;&lt;br /&gt;pthread_mutex_t mutex1;&lt;br /&gt;&lt;br /&gt;void* foo(void *arg)&lt;br /&gt;{&lt;br /&gt;  int arr[1024*8];&lt;br /&gt;&lt;br /&gt;  int x = 0;&lt;br /&gt;  while(x++ &lt; (8*1024) )&lt;br /&gt;    { arr[x] = x; }&lt;br /&gt;&lt;br /&gt;  pthread_mutex_lock(&amp;mutex1);&lt;br /&gt;  puts("Thread created");&lt;br /&gt;  pthread_mutex_unlock(&amp;mutex1);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;  int *p;&lt;br /&gt;  void *ret;&lt;br /&gt;&lt;br /&gt;  p = malloc(1024);&lt;br /&gt;&lt;br /&gt;  free(p);&lt;br /&gt;&lt;br /&gt;  pthread_attr_t attr;&lt;br /&gt;&lt;br /&gt;  pthread_attr_setstack(&amp;attr, p, 2);&lt;br /&gt;&lt;br /&gt;  pthread_t thread1;&lt;br /&gt;&lt;br /&gt;  pthread_create(&amp;thread1, NULL, foo, NULL);&lt;br /&gt;&lt;br /&gt;  pthread_join(thread1, &amp;ret);&lt;br /&gt;&lt;br /&gt;  free(p);&lt;br /&gt;&lt;br /&gt;  return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;But still I am not very sure of this concept.&lt;br /&gt;&lt;br /&gt;Stay tuned for more!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-7029388527076860637?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/7029388527076860637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=7029388527076860637' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/7029388527076860637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/7029388527076860637'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/03/thread-stack-in-heap-pthreads.html' title='Thread stack in heap (pthreads)'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-1038277575660516987</id><published>2010-03-22T16:39:00.002+05:30</published><updated>2010-03-22T16:39:28.805+05:30</updated><title type='text'>Some thoughts on Linux malloc()</title><content type='html'>* Always check for equal number of malloc()/free() calls.&lt;br /&gt;• Use calloc() instead of malloc() + memset()&lt;br /&gt;• Instead of allocation memory in a piece-meal manner, try to allocate a bigger chunk with malloc() and keep on resizing it with realloc() if needed.&lt;br /&gt;• malloc() over-commits the memory i.e. it gives you an address which actually does not exist!&lt;br /&gt;• malloc() grouping &amp; reallocing with "more than you want"&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-1038277575660516987?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/1038277575660516987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=1038277575660516987' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1038277575660516987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1038277575660516987'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/03/some-thoughts-on-linux-malloc.html' title='Some thoughts on Linux malloc()'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-6006900660106763915</id><published>2010-03-11T12:32:00.000+05:30</published><updated>2010-03-11T12:32:19.982+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='tinyurl'/><category scheme='http://www.blogger.com/atom/ns#' term='web'/><title type='text'>Cut short your web-addresses: TinyURL</title><content type='html'>An utility called "tinyurl" makes your life easier with shorter URL without creating an all new website. Many times it become cumbersome(i.e. for a long string) and unsafe(if you miss to copy contents of the link) to send a link to your friend.&lt;br /&gt;&lt;br /&gt;TinyURl helps you with providing an alias for a long link. Concept is very simple but effective.&lt;br /&gt;e.g. a link is: "http://http://www.blogger.com/post-create.g?blogID=4233584295994918105"&lt;br /&gt;&lt;br /&gt;You may get an easier name for this link as: http://tinyurl.com/abc&lt;br /&gt;&lt;br /&gt;Here is more information this:&lt;br /&gt;http://tinyurl.com&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-6006900660106763915?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/6006900660106763915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=6006900660106763915' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/6006900660106763915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/6006900660106763915'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/03/cut-short-your-web-addresses-tinyurl.html' title='Cut short your web-addresses: TinyURL'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-4850275060352984490</id><published>2010-02-20T11:21:00.000+05:30</published><updated>2010-02-20T11:21:53.560+05:30</updated><title type='text'>Exceptional exception handling in C++</title><content type='html'>#include&lt;iostream&gt;&lt;br /&gt;&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;//Global&lt;br /&gt;int a = 20;&lt;br /&gt;&lt;br /&gt;void foo()&lt;br /&gt;try {&lt;br /&gt;  throw a;&lt;br /&gt;}&lt;br /&gt;catch(int &amp;x)&lt;br /&gt;{&lt;br /&gt;  // You can't modify value of "a"&lt;br /&gt;  x = 10;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;  foo();&lt;br /&gt;  cout&lt;&lt;"A="&lt;&lt;a;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;A=20 !!!!&lt;br /&gt;When you write "throw a", an invisible, phantom exception object gets created. You pass reference to that object and hence any change made to original object have no effect.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-4850275060352984490?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/4850275060352984490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=4850275060352984490' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4850275060352984490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4850275060352984490'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/02/exceptional-exception-handling-in-c.html' title='Exceptional exception handling in C++'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-109846260655046231</id><published>2010-02-19T15:05:00.000+05:30</published><updated>2010-02-19T15:05:35.634+05:30</updated><title type='text'>Mutex v/s Semaphore v/s Spinlock</title><content type='html'>Similarity&lt;br /&gt;&lt;br /&gt;- All are used for synchronization&lt;br /&gt;&lt;br /&gt;Difference&lt;br /&gt;&lt;br /&gt;Mutex provides one person to access a resource at a time, others must wait in a queue. Once person is done, the guy next in the queue acquire the resource.&lt;br /&gt;So access is serial, one guy after other.&lt;br /&gt;&lt;br /&gt;Semaphore provides more than one(up to N) guys to access N resources. So it gives you parallel access to a resource.&lt;br /&gt;&lt;br /&gt;Spinlock is an aggressive mutex. In mutex, if you find that resource is locked by someone else, you (the thread/process) switch the context and start to wait(non-blocking).&lt;br /&gt;Whereas spinlocks do not switch context and as soon as resource is free, they go and grab it. In this process of spinning, they consume many CPU cycles. Also, on a uni-processor machine they are useless and perform very badly (do I need to explain that?).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-109846260655046231?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/109846260655046231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=109846260655046231' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/109846260655046231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/109846260655046231'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/02/mutex-vs-semaphore-vs-spinlock.html' title='Mutex v/s Semaphore v/s Spinlock'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-3666109436639560204</id><published>2010-02-04T16:18:00.000+05:30</published><updated>2010-02-04T16:18:26.921+05:30</updated><title type='text'>GL: Question</title><content type='html'>- fun(int, int);&lt;br /&gt;  fun(char, char)&lt;br /&gt;Are they overloaded properly?&lt;br /&gt;&lt;br /&gt;- Using static variable in a member function?&lt;br /&gt;&lt;br /&gt;- Finding the common node of two link lists?&lt;br /&gt;&lt;br /&gt;- Implement BFS, DFS?&lt;br /&gt;&lt;br /&gt;- Inorder, preorder is DFS or BFS?&lt;br /&gt;&lt;br /&gt;- What is a heap?&lt;br /&gt;&lt;br /&gt;- Deleting a node in BST?&lt;br /&gt;&lt;br /&gt;- Difference of memcpy() and strcpy()&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-3666109436639560204?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/3666109436639560204/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=3666109436639560204' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/3666109436639560204'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/3666109436639560204'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/02/gl-question.html' title='GL: Question'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-2944740228110367195</id><published>2010-01-06T19:38:00.001+05:30</published><updated>2010-01-10T14:20:59.578+05:30</updated><title type='text'>C Structures: Calculating offset of an element</title><content type='html'>Let's say we have the following structure:&lt;br /&gt;&lt;br /&gt;struct&lt;br /&gt;{&lt;br /&gt;int  a;&lt;br /&gt;char c;&lt;br /&gt;} example;&lt;br /&gt;&lt;br /&gt;To calculate offset of 'c', we have following ways:&lt;br /&gt;&lt;br /&gt;1. Use the macro offsetof() defined in header file stddef.h.&lt;br /&gt;unsigned int x = offsetof(struct example, c);&lt;br /&gt;This macro takes care of padding of elements done by the compiler.&lt;br /&gt;&lt;br /&gt;2. Other way to get the offset f c is:&lt;br /&gt;// C snippet&lt;br /&gt;example var, example *ptr;&lt;br /&gt;ptr = &amp;var;&lt;br /&gt;offset = &amp;(ptr-&gt;c)- &amp;(ptr-&gt;a)&lt;br /&gt;//&lt;br /&gt;&lt;br /&gt;------|base_addr = 0x0000&lt;br /&gt;int a |&lt;br /&gt;------|addr = (0x0000 + 0x0004)&lt;br /&gt;int c |&lt;br /&gt;------|addr = (0x0004 + 0x0004)&lt;br /&gt;&lt;br /&gt;We are getting the distance of 'c' from base of the structure. So, address &amp;(ptr-&gt;c) should be calcuated by compile as: base_address of var + distance of 'c' from base&lt;br /&gt;If we somehow set base_addr as zero, we will get the offset i.e. 0x0004.&lt;br /&gt;&lt;br /&gt;A hack to accomplish this result is as follows:&lt;br /&gt;#define POINTER = ((struct example*)(0))&lt;br /&gt;unsigned int x = (unsigned int) &amp; (POINTER-&gt;c);&lt;br /&gt;&lt;br /&gt;We are typecasting an address '0' pointing to a type of data 'struct example'.&lt;br /&gt;Now when you do (x)-&gt;c, it is equivalent to: BASE_ADDESS(x) + size_of_data elements preceding 'c'. We are tricking the compiler by giving BASE_ADDRESS as zero.&lt;br /&gt;&lt;br /&gt;This hack may be incorrect if element padding is done by the compiler.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-2944740228110367195?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/2944740228110367195/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=2944740228110367195' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2944740228110367195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2944740228110367195'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2010/01/c-structures-calculating-offset-of.html' title='C Structures: Calculating offset of an element'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-4375777059842278865</id><published>2009-12-15T15:34:00.001+05:30</published><updated>2009-12-15T15:34:46.559+05:30</updated><title type='text'>Signals in Linux</title><content type='html'>- List of signals: $kill -l&lt;br /&gt;- You can't handle SIGSTOP and SIGKILL. You can't priorities which signal to handle.&lt;br /&gt;- Signals are generated by setting the appropriate bit in the task_struct's signal field. If the process has not blocked the signal and is waiting but interruptible (in state Interruptible) then it is woken up by changing its state to Running and making sure that it is in the run queue. (linuxhq.com)&lt;br /&gt;- Signals that are sent to a process if an illegal flow of execution happens, are synchronous. They are also called trap e.g. illegal memory access.&lt;br /&gt;- Asynchronous signals are also called interrupts and are sent from a process to another process or thread-to-thread.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-4375777059842278865?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/4375777059842278865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=4375777059842278865' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4375777059842278865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4375777059842278865'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/12/signals-in-linux.html' title='Signals in Linux'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-1384691486291299905</id><published>2009-12-14T18:15:00.002+05:30</published><updated>2009-12-22T18:48:28.909+05:30</updated><title type='text'>Some useful questions</title><content type='html'>- Access privileges for private functions in C++?&lt;br /&gt;- Controlling exclusive access to a variable with two processor and two threads?&lt;br /&gt;- Pattern substitution with sed?&lt;br /&gt;- What is md5?&lt;br /&gt;- When do you allocate memory for static variables?&lt;br /&gt;- Phases of compiler, AST?&lt;br /&gt;- When do we allocate storage for static?&lt;br /&gt;- Data hiding and encapsulation?&lt;br /&gt;- Is Vtable per class/object?&lt;br /&gt;- Difference between COFF and ELF?&lt;br /&gt;- Compiler phase of function in-lining?&lt;br /&gt;- Difference between macro and function in-lining?&lt;br /&gt;- Types of parsers?&lt;br /&gt;- YACC is which parser?&lt;br /&gt;- How lex and yacc work?&lt;br /&gt;- How does linker gets info about static variables?&lt;br /&gt;- How protected specifier works in C++?&lt;br /&gt;- What is memory leak?&lt;br /&gt;- Accessing static outside its scope?&lt;br /&gt;- How assembler works?&lt;br /&gt;- When do we do semantic analysis?&lt;br /&gt;- You have a file with write-only access, and you have N threads. How would you ensure sharing of this file among these threads considering performance a prime concern?&lt;br /&gt;- Singleton class? A real world example.&lt;br /&gt;- How would you classify a file based on contents of the class? How many search keyword in the file are necessary?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-1384691486291299905?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/1384691486291299905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=1384691486291299905' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1384691486291299905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1384691486291299905'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/12/some-useful-questions.html' title='Some useful questions'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-2663421854863304430</id><published>2009-12-01T09:24:00.001+05:30</published><updated>2009-12-01T12:08:23.166+05:30</updated><title type='text'>Bouquet of questions-3</title><content type='html'>o How can you add attributes in gcc, e.g., changing function call way from cdecl to stdcall?&lt;br /&gt;&lt;br /&gt;GCC allows you to attribute your functions with __attribute__ macro.&lt;br /&gt;This macro allows you to write more readable, clean code. I liked,&lt;br /&gt;&lt;br /&gt;- __attribute__((destructor))&lt;br /&gt;- __attribute__((constructor))&lt;br /&gt;- __attribute__((warning("Function definition is not found)))&lt;br /&gt;&lt;br /&gt;There are plenty of them, check them out at: http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html&lt;br /&gt;&lt;br /&gt;o What does following code do?&lt;br /&gt;&lt;br /&gt;int flag = 2;&lt;br /&gt;int (*fp)(void) __attribute__((cdecl));&lt;br /&gt;void fun() __attribute__((warning("No definition")));&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt;//fun();&lt;br /&gt;fp = main;&lt;br /&gt;puts("called");&lt;br /&gt;while(flag--) {&lt;br /&gt; int x = (*fp)();&lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-2663421854863304430?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/2663421854863304430/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=2663421854863304430' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2663421854863304430'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2663421854863304430'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/12/bouquet-of-questions-3.html' title='Bouquet of questions-3'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-5860929034725313348</id><published>2009-11-29T18:41:00.001+05:30</published><updated>2009-11-29T18:41:08.442+05:30</updated><title type='text'>Bouquet of questions-2</title><content type='html'>o What is a bus error?&lt;br /&gt;&lt;br /&gt;Bus refers to address bus and an error means passing an illegal address to the address bus. There are two signals that can be sent by kernel for an illegal address:&lt;br /&gt;- SIGBUS&lt;br /&gt;- SEGSEGV&lt;br /&gt;&lt;br /&gt;A SIGBUS is issued for an obvious wrong virtual address, there is no address translation and CPU can outright say that address is bogus.&lt;br /&gt;&lt;br /&gt;SIGSEGV is issued when after translating the address, CPU realizes that address is bogus.&lt;br /&gt;&lt;br /&gt;SIGBUS is always better since it avoids address translation. But which signal to issue, depends on CPU.&lt;br /&gt;&lt;br /&gt;o What will be the output?&lt;br /&gt;&lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt;int a[10];&lt;br /&gt;printf("%d", sizeof(a);&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-5860929034725313348?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/5860929034725313348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=5860929034725313348' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/5860929034725313348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/5860929034725313348'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/11/bouquet-of-questions-2.html' title='Bouquet of questions-2'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-4218009563821375555</id><published>2009-11-06T16:31:00.004+05:30</published><updated>2009-11-11T20:32:17.362+05:30</updated><title type='text'>Bouquet of questions</title><content type='html'>o What is a cache line?&lt;br /&gt;&lt;br /&gt;- Smallest unit of data transfer between cache and main memory.&lt;br /&gt;- Finest level of granularity&lt;br /&gt;&lt;br /&gt;o How can I get IPC information over processes?&lt;br /&gt;&lt;br /&gt;- Use $ipcs&lt;br /&gt;&lt;br /&gt;o Tell the value of enum's elements.&lt;br /&gt;&lt;br /&gt;  enum e_tag{ a, b, c, d=20, e, f, g=20, h&lt;br /&gt;  }var&lt;br /&gt;&lt;br /&gt;- a=0, b=1, c=3, d=20, e=21, f=22, g=20, h=21&lt;br /&gt;&lt;br /&gt;o Why use volatile?&lt;br /&gt;&lt;br /&gt;- To avoid compiler optimization on variables involved in two cases:&lt;br /&gt;  + Shared library&lt;br /&gt;  + Value updated implicitly by hardware&lt;br /&gt;&lt;br /&gt;Avoid optimization of Load/Store instructions by the compiler.&lt;br /&gt;e.g., If you have a variable(X) that reads from a shared lib variable(Y), while Y is being updated by other process. Compiler would have no idea of this dependency of external value updates and it may remove these LOAD/STORE instructions during compilation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-4218009563821375555?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/4218009563821375555/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=4218009563821375555' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4218009563821375555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4218009563821375555'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/11/bouquet-of-questions.html' title='Bouquet of questions'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-7790712004313846579</id><published>2009-10-22T18:13:00.004+05:30</published><updated>2009-10-22T18:25:48.569+05:30</updated><title type='text'>Digging Intel Itanium: RSE, Register Stack Engine</title><content type='html'>Itanium processors heralded a new era or processing. Though not very successful commercially, IPF has added many wonderful techniques to computer science. I'll discuss the one I liked the most.&lt;br /&gt;&lt;br /&gt;It is called RSE (Register Stack Engine), a technique to avoid using main memory during function calls and do the stuff in processor register itself. When a function call is made, calling function passes the arguments that are saved in main memory. After this, the return address is saved. Main memory access is slower when compared to processor speed. Itanium has 128 GPR and out of those 96 are available for RSE. These 96 registers take care of function call mechanism, appearing as a register stack frame to the application. This bypasses memory access till all 96 registers are occupied. Interestingly, processor itself is responsible for running this show and also it's transparent to the application.&lt;br /&gt;&lt;br /&gt;More here: http://software.intel.com/en-us/articles/itaniumr-processor-family-performance-advantages-register-stack-architecture&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-7790712004313846579?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/7790712004313846579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=7790712004313846579' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/7790712004313846579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/7790712004313846579'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/10/digging-intel-itanium-rse-register.html' title='Digging Intel Itanium: RSE, Register Stack Engine'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-1978153497815937373</id><published>2009-10-13T16:25:00.002+05:30</published><updated>2009-10-13T16:31:12.648+05:30</updated><title type='text'>Fast hard drives: How?</title><content type='html'>A simple hard drive today is capable of things that sound like some outlandish technology. Just try to do some file I/O in your application and do it with many threads.&lt;br /&gt;Say you have 4 threads, A,B,C, and D. And request to do I/O comes in A then B and so on. If you check the return status of these threads, the ordering might be surprising. Thread D may return before A. How?&lt;br /&gt;&lt;br /&gt;Disk have a technology called Native Command Ordering. So they take your request in and process them on a single, simple logic:&lt;br /&gt;-&gt; Serve the one which you can do fastest.&lt;br /&gt;This depends on the head position of the disk. The request that can be served with minimal movement of head, is served first.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-1978153497815937373?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/1978153497815937373/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=1978153497815937373' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1978153497815937373'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1978153497815937373'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/10/fast-hard-drives-how.html' title='Fast hard drives: How?'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-4286378974049684365</id><published>2009-10-04T15:50:00.003+05:30</published><updated>2009-10-04T16:04:37.621+05:30</updated><title type='text'>A few 'why' answered</title><content type='html'>There are certain 'why' that we may have missed, so I am trying to attend them...one by one.&lt;br /&gt;&lt;br /&gt;o Why do we need hash table?&lt;br /&gt;Of course, for better, faster search. It could even get us an element in O(1).&lt;br /&gt;&lt;br /&gt;But we need to use hash because if given data is in a form which can't be ordered; we need hashing. Example can be images. How will you order a set of images and search any.&lt;br /&gt;Hashing comes to help here. It generates a unique(ideally) hash key for given such data. We save these keys in a hash table. So searching an image is now searching a key in hash table. Keys are generated with a hash function. More about that later.&lt;br /&gt;&lt;br /&gt;To be continued with more whys.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-4286378974049684365?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/4286378974049684365/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=4286378974049684365' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4286378974049684365'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4286378974049684365'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/10/few-why-answered.html' title='A few &apos;why&apos; answered'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-701096103727620400</id><published>2009-09-22T14:22:00.003+05:30</published><updated>2009-09-22T14:35:54.087+05:30</updated><title type='text'>HP Caliper : A Profiler</title><content type='html'>Developer rarely concern for efficiency of their programming logic. It's not a hard-and-fast observation but that's how most of amateur developer write the code. But performance is becoming critical day by day and commercial applications vie for as much performance gain as possible.&lt;br /&gt;&lt;br /&gt;Performance can be hit for motley of reasons but application logic is what we are going to stress here. You may write a code that performs badly with cache system of your hardware or you schedule your threads inappropriately. There may be many reasons that one may not become aware unless someone find it out.&lt;br /&gt;&lt;br /&gt;HP Caliper is one of my favorite tool that can help you with finding many causes of application slowdown. It is an Intel Itanium based tool and runs on HPUX &amp; Linux.&lt;br /&gt;Talk about its feature and I may run out of space. It can make basic profiles like sampled call-graph, flat function profile, CPU events profile. Besides it can provide call-stack profile (critical for I/O bound applications), data cache profile (to help you re-layout the data structures).&lt;br /&gt;&lt;br /&gt;Best part is that it does not need a recompile of application or any library. Just give it a binary or attach it to a process. Run it and there you are with third party insight in to your logic. It comes with a command line interface and GUI.&lt;br /&gt;&lt;br /&gt;Only downside is that it runs on Itanium binaries only so other users have to wait till it become available for them too.&lt;br /&gt;&lt;br /&gt;Happy profiling!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-701096103727620400?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/701096103727620400/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=701096103727620400' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/701096103727620400'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/701096103727620400'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/09/hp-caliper-profiler.html' title='HP Caliper : A Profiler'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-7125022067664160301</id><published>2009-08-28T19:38:00.003+05:30</published><updated>2009-08-28T19:42:52.725+05:30</updated><title type='text'>NUI: Mobile GUI development</title><content type='html'>I found "nui", a C++ based GUI development framework. You can develop iPhone apps as well. It runs on Linux, Windows, Mac.&lt;br /&gt;http://www.libnui.net/&lt;br /&gt;&lt;br /&gt;I also came to know about "enthought" (http://www.enthought.com/). Another GUI development framework. This guy automatically develop the GUI if you provide the class definition.&lt;br /&gt;&lt;br /&gt;I've not tried both of these. But they both sound interesting, so thought of sharing :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-7125022067664160301?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/7125022067664160301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=7125022067664160301' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/7125022067664160301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/7125022067664160301'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/08/nui-mobile-gui-development.html' title='NUI: Mobile GUI development'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-2923153474167787704</id><published>2009-08-17T18:47:00.001+05:30</published><updated>2009-08-18T12:59:52.882+05:30</updated><title type='text'>Python questions for interview</title><content type='html'>Python is a bliss for quick development. It's a mix of C &amp; C++ features and comes in flavor of a script. For a C/C++ developer who happen to work with Python, here are few interview questions that are frequently asked:&lt;br /&gt;&lt;br /&gt;1. what all Python can do for you in OOP?&lt;br /&gt; Python fairly supports OOP principles. You can declare and define classes that follow same philosophy of OOP(similar to C++, Java). Besides features like inheritance, polymorphism are also there.&lt;br /&gt;&lt;br /&gt;2. Does it support operator overloading?&lt;br /&gt; You can have operator overloading also.&lt;br /&gt;&lt;br /&gt;3. What is pickling?&lt;br /&gt; It's an object serialization technique. Very similar to marshaling/un-marshaling that packet data in networks.&lt;br /&gt;&lt;br /&gt;4. Does it support function overloading?&lt;br /&gt;  No.&lt;br /&gt;&lt;br /&gt;5. How do you pass variable number of arguments to a function?&lt;br /&gt;  def foo(*pass_many):&lt;br /&gt;  ...&lt;br /&gt;  In the function you should retrieve the arguments as a tuple.&lt;br /&gt;&lt;br /&gt;6. Difference between a tuple and list?&lt;br /&gt;  You know it. Tuples are immutable objects while list are mutable.&lt;br /&gt;&lt;br /&gt;Highly recommended: http://www.learningpython.com/2008/06/21/operator-overload-learn-how-to-change-the-behavior-of-equality-operators/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-2923153474167787704?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/2923153474167787704/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=2923153474167787704' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2923153474167787704'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2923153474167787704'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/08/python-questions-for-interview.html' title='Python questions for interview'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-2298995091591611919</id><published>2009-07-21T20:48:00.003+05:30</published><updated>2009-07-21T21:07:59.658+05:30</updated><title type='text'>Careful with both hands while using fork!</title><content type='html'>fork() is one of the most useful feature of C/Linux/UNIX. But it's like a double edged sword, so be careful with fork :-)&lt;br /&gt;Of late, I got stuck in a weird problem with one of the client application(A) that interacts with another application(B).  Application A was hanging when used application B; otherwise alone A runs just fine.&lt;br /&gt;Now what to do? We did a thorough examination of both the applications and found that A is waiting on a pipe P. P has its write end with B and A has got the read end. But why this wait? There is no need to keep this pipe open in first place.&lt;br /&gt;So here fork() comes in to picture. Actually A forks B and then B interacts with A. When A fork() B, B gets a copy of all open file descriptors(FD) of A as well. There you go!&lt;br /&gt;After getting these FDs, B does not take care to close them. But A checks if any of its FD is still open. Since the file is open with B, kernel will tell A that some of your files are being accessed. So just wait :( And this wait never ends...&lt;br /&gt;This was it. A simple close() call in B for all FDs worked for us. And B happily got away with A.&lt;br /&gt;&lt;br /&gt;A word of advice: Always call exit() from child. exit() does basic clean up and calls _exit() which more work including closing all files open with child.&lt;br /&gt;&lt;br /&gt;Just to verify, you can use this test program:&lt;br /&gt;&lt;br /&gt;#include "fcntl.h"&lt;br /&gt;#include "stdlib.h"&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;  int fd = -1;&lt;br /&gt;  int status;&lt;br /&gt;  char buf[512];&lt;br /&gt;&lt;br /&gt;  fd = open("abc.txt", O_CREAT);&lt;br /&gt;&lt;br /&gt;  int pid = fork();&lt;br /&gt;&lt;br /&gt;  if(pid == 0) { // Child&lt;br /&gt;    puts("Child says bye");&lt;br /&gt;    exit(status);&lt;br /&gt;  } else { // Parent&lt;br /&gt;    sleep(1);&lt;br /&gt;    int ch = read(fd, buf, 16);&lt;br /&gt;    printf("\nRead returns %d\n", ch);&lt;br /&gt;    exit(status);&lt;br /&gt;  }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-2298995091591611919?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/2298995091591611919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=2298995091591611919' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2298995091591611919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2298995091591611919'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/07/careful-with-both-hands-while-using.html' title='Careful with both hands while using fork!'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-8623977412172337232</id><published>2009-07-02T10:34:00.002+05:30</published><updated>2009-07-02T10:50:27.165+05:30</updated><title type='text'>Lichen: Our first invention</title><content type='html'>We, a group of three friends have got our first ever invention disclosure published today. It's quite a happy moment for all of us. We started with a small idea that eventually got transformed into a serious paper :)&lt;br /&gt;&lt;br /&gt;Title : Lichen: A Framework For Characterizing Sporadic Performance Constrictions In Non-deterministic Applications"&lt;br /&gt;&lt;br /&gt;The idea deals with better profiling of application with a special way of sample collection.&lt;br /&gt;Our paper is published in worldwide publication Research Journal. (http://www.researchdisclosure.com)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-8623977412172337232?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/8623977412172337232/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=8623977412172337232' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/8623977412172337232'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/8623977412172337232'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/07/lichen-our-first-invention.html' title='Lichen: Our first invention'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-2721654249829909269</id><published>2009-07-01T19:31:00.003+05:30</published><updated>2009-07-01T19:39:59.317+05:30</updated><title type='text'>Terminal problem with csh/ksh</title><content type='html'>If you are a bash addict and you have to work in csh/ksh; you may face terminal problem with csh/ksh while using vi/more or any such command. vi expects complete knowledge of the terminal where it's going to display its contents. There is a simple way to fix it.&lt;br /&gt;&lt;br /&gt;1. First get the shell type by: $echo $SHELL&lt;br /&gt;   This is just to confirm that you are in csh/ksh.&lt;br /&gt;&lt;br /&gt;2. Figure out what is the terminal type. If you do not know then ask your system administrator.&lt;br /&gt;&lt;br /&gt;3. If you can't, that's also okay. :-) We'll try to use default terminal emulator type called "vt100".&lt;br /&gt;&lt;br /&gt;4. Now you need to export the terminal type to your csh/ksh.&lt;br /&gt;   $setenv TERM vt100&lt;br /&gt;   $tset&lt;br /&gt;&lt;br /&gt;5. There you go. Try to open a vi session.&lt;br /&gt;&lt;br /&gt;Let me know if you face any issue.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-2721654249829909269?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/2721654249829909269/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=2721654249829909269' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2721654249829909269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2721654249829909269'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/07/terminal-problem-with-cshksh.html' title='Terminal problem with csh/ksh'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-1799946245064499384</id><published>2009-06-03T15:14:00.001+05:30</published><updated>2009-06-15T12:10:30.585+05:30</updated><title type='text'>Installation: Fedora core 9</title><content type='html'>- Installing printer on FC9&lt;br /&gt;  Use 'system-config-printer' command. For more details, refer following link.&lt;br /&gt;  http://foo2zjs.rkkda.com/fedora/hp1020.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-1799946245064499384?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/1799946245064499384/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=1799946245064499384' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1799946245064499384'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/1799946245064499384'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/06/installation-fedora-core-9.html' title='Installation: Fedora core 9'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-2632975723404181870</id><published>2009-06-03T12:25:00.004+05:30</published><updated>2009-06-03T12:48:24.845+05:30</updated><title type='text'>How to install Flashplayer in Firefox on Linux?</title><content type='html'>Firefox on Linux needs manual installation of Flash player. Surprisingly it's bit messy, so here are a few steps to accomplish this task:&lt;br /&gt;&lt;br /&gt;- Get the rpm/deb package downloaded on your system(typically titled adobe-release-i386-1.0-1.noarch.rpm/ flash-plugin-10.0.22.87-release.i386.rpm).&lt;br /&gt;&lt;br /&gt;- Install with YUM/aptget like follows:&lt;br /&gt;   $yum install adobe-release-i386-1.0-1.noarch.rpm&lt;br /&gt;&lt;br /&gt;- Open Firefox browser, and in the address bar type "about:config".&lt;br /&gt;  If you see flash player entry in there, you are fine. Else, go to next step.&lt;br /&gt;&lt;br /&gt;- Run $updatedb&lt;br /&gt;  It'll update the database for "locate" command.&lt;br /&gt;&lt;br /&gt;- Run $locate libflashplayer&lt;br /&gt;  Most probably it will tell you the directory, "/usr/lib/flash-plugin" directory. Here you will  find libflashplayer.so.&lt;br /&gt;&lt;br /&gt;- Copy "libflashplayer.so" to Firefox installation directory (e.g. "/usr/local/bin/firefox/plugins/"). Also copy it to "/usr/lib". This will make this library available to all users.&lt;br /&gt;&lt;br /&gt;- Again check your Firefox browser with "about:config". You should see a couple of flash player entries there.&lt;br /&gt;&lt;br /&gt;That's all. Try running Youtube for verification:-)&lt;br /&gt;&lt;br /&gt;Ref: http://www.linuxquestions.org/questions/linux-software-2/how-to-install-flashplayer-in-firefox-487406/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-2632975723404181870?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/2632975723404181870/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=2632975723404181870' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2632975723404181870'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2632975723404181870'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/06/how-to-install-flashplayer-in-firefox.html' title='How to install Flashplayer in Firefox on Linux?'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-6015025754970408001</id><published>2009-05-29T11:48:00.003+05:30</published><updated>2009-05-29T12:11:28.644+05:30</updated><title type='text'>Windows flavor in Linux, YUM</title><content type='html'>Linux is bad for naive users especially while installing new software. You always see some dependency missing and all. That's what I used to think. But no more. Linux has given a break from messy-dirty way of installing a software to a very very clean and simple way.&lt;br /&gt;&lt;br /&gt;Yes, it's by Fedora 9(New name for good old Redhat), and it's called YUM.&lt;br /&gt;Yum makes installing new RPM(Redhat Packet Manager) butter smooth and a slightly simpler than Windows.&lt;br /&gt;All Yum demands is an Internet connection and lo, you are done.&lt;br /&gt;&lt;br /&gt;Just download your desired RPM and specify it to yum like this:&lt;br /&gt;&lt;br /&gt;$yum install my.rpm&lt;br /&gt;&lt;br /&gt;After asking you for a 'YES', it will take care of everything.&lt;br /&gt;&lt;br /&gt;Simple right!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-6015025754970408001?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/6015025754970408001/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=6015025754970408001' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/6015025754970408001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/6015025754970408001'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/05/windows-flavor-in-linux-yum.html' title='Windows flavor in Linux, YUM'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-7912520238632492821</id><published>2009-05-21T19:42:00.004+05:30</published><updated>2009-05-21T20:00:31.660+05:30</updated><title type='text'>Idiotic scanf() : Scanning whitespaces in a string</title><content type='html'>In C, a few functions are real nasty and scanf() is one of them. It's specially bad for inputting strings.&lt;br /&gt;What will happen if you give a string: &lt;br /&gt;&lt;br /&gt;-&gt; scanf("%s", string)&lt;br /&gt;&lt;br /&gt;-&gt; Input: "C is stupid".&lt;br /&gt;&lt;br /&gt;Well, you will have only "C" in the "string".&lt;br /&gt;&lt;br /&gt;Reason: It happens because scanf() considers white-spaces as delimiter. So "C" being followed by a white space is considered as the only input. Simple, isn't it?&lt;br /&gt;&lt;br /&gt;Remedy: We have something like follows:&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;  char arr[10];&lt;br /&gt;  scanf("%*[ \t\n]%s", arr);&lt;br /&gt;  puts(arr);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;IT DOESN'T WORK!!!&lt;br /&gt;&lt;br /&gt;Only way is this:&lt;br /&gt;&lt;br /&gt;#define SIZE 128&lt;br /&gt;&lt;br /&gt;int main() {&lt;br /&gt;  char arr[SIZE];&lt;br /&gt;  char ch;&lt;br /&gt;  int index = 0;&lt;br /&gt;&lt;br /&gt;  while(ch != '\n' &amp;&amp; index &lt; SIZE)&lt;br /&gt;  {&lt;br /&gt;    ch = getchar();&lt;br /&gt;    arr[index] = ch;&lt;br /&gt;    index++;&lt;br /&gt;  }&lt;br /&gt;  arr[index] = '\0';&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Done!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-7912520238632492821?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/7912520238632492821/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=7912520238632492821' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/7912520238632492821'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/7912520238632492821'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/05/idiotic-scanf-scanning-whitespaces-in.html' title='Idiotic scanf() : Scanning whitespaces in a string'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-7920087552903571809</id><published>2009-04-15T20:11:00.002+05:30</published><updated>2009-04-15T20:15:31.071+05:30</updated><title type='text'>GNU gdb: The toolbox of commands</title><content type='html'>Many a times application throws signals during its execution. By default gdb has some setting for all UNIX defined signals. If this default is "stop" the application, it becomes quite irritating.&lt;br /&gt;To handle a signal: (gdb) handle SIGUSR1 nostop&lt;br /&gt;All available options are:&lt;br /&gt;nostop&lt;br /&gt;GDB should not stop your program when this signal happens. It may still print a message telling you that the signal has come in.&lt;br /&gt;&lt;br /&gt;stop&lt;br /&gt;GDB should stop your program when this signal happens. This implies the print keyword as well.&lt;br /&gt;&lt;br /&gt;pass&lt;br /&gt;noignore&lt;br /&gt;GDB should allow your program to see this signal; your program can handle the signal, or else it may terminate if the signal is fatal and not handled. pass and noignore are synonyms.&lt;br /&gt;&lt;br /&gt;nopass&lt;br /&gt;ignore&lt;br /&gt;GDB should not allow your program to see this signal. nopass and ignore are synonyms.&lt;br /&gt;&lt;br /&gt;(Ref: http://sources.redhat.com/gdb/current/onlinedocs/gdb_6.html#SEC44)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-7920087552903571809?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/7920087552903571809/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=7920087552903571809' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/7920087552903571809'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/7920087552903571809'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/04/gnu-gdb-toolbox-of-commands.html' title='GNU gdb: The toolbox of commands'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-40009874263553062</id><published>2009-04-15T15:01:00.006+05:30</published><updated>2009-04-15T15:19:45.961+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='new technology'/><title type='text'>Ruby on Rails</title><content type='html'>Bored of J2EE? I came across a new web app development framework called Ruby on Rails. Based on Agile development philosophy, it's one of the most popular web framework today. &lt;br /&gt;&lt;br /&gt;As name suggests, it let's you develop your web application faster and conveniently. All you need to know Ruby before getting started.&lt;br /&gt;&lt;br /&gt;Check out more at: http://rubyonrails.org/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-40009874263553062?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/40009874263553062/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=40009874263553062' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/40009874263553062'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/40009874263553062'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/04/rails-new-web-application-development.html' title='Ruby on Rails'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-4239373759108898717</id><published>2009-03-17T13:57:00.002+05:30</published><updated>2009-03-17T14:38:40.224+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux internals'/><title type='text'>Linux Scheduling: A Few Facts</title><content type='html'>- Linux scheduler favors I/O bound processes. It uses dynamic priorities to schedule processes. So a process that has not got CPU for a long time, would get its priority increased and vice verse.&lt;br /&gt;&lt;br /&gt;- Processes are moved to different queues and al processes on ready queue are assigned an 'epoch'. The epoch is relevant for processes in ready queue only.&lt;br /&gt;&lt;br /&gt;- Now each process is assigned a quantum which is the CPU time allotted to a process. If a process is blocked, it does not use its quantum and unused quantum is carry forward to next epoch. An epoch completes as soon as all processes in ready queue complete their quantum.&lt;br /&gt;&lt;br /&gt;- Dynamic priority("goodness") of a process is calculated by base priority and quantum. Hence a I/O bound process which is blocked for a long time, gets its priority improved every time it saves its quantum while it was blocked.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-4239373759108898717?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/4239373759108898717/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=4239373759108898717' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4239373759108898717'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4239373759108898717'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/03/linux-scheduling-few-facts.html' title='Linux Scheduling: A Few Facts'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-5619212141547092504</id><published>2009-02-17T14:23:00.003+05:30</published><updated>2009-02-19T16:22:36.676+05:30</updated><title type='text'>Linux Tips</title><content type='html'>- &lt;span style="font-weight:bold;"&gt;Changing Linux root password&lt;/span&gt;&lt;br /&gt;http://www.paulspoerry.com/2008/09/06/replace-linux-root-password/&lt;br /&gt;&lt;br /&gt;- &lt;span style="font-weight:bold;"&gt;Ways of saying 'Hello! World'&lt;/span&gt; : http://www.fitzrovian.com/hello.html&lt;br /&gt;- sizeof (type) requires parenthese, while sizeof expression&lt;br /&gt;does not.&lt;br /&gt;&lt;br /&gt;- How to easily read a declaration from left to right:&lt;br /&gt; transform function argument types from inside out first&lt;br /&gt; move the base type to the end&lt;br /&gt; add outer parentheses if there's an initial *&lt;br /&gt; change every (*...) to ... -&gt;&lt;br /&gt;  one -&gt; for each *&lt;br /&gt;  move qualifiers, so * const becomes const -&gt;&lt;br /&gt;&lt;br /&gt;Example: const int *(**const x [])()&lt;br /&gt;&lt;br /&gt; *(**const x [])() const int  base type to end&lt;br /&gt; (*(**const x [])()) const int  add outer parens&lt;br /&gt; (**const x [])() -&gt; const int  remove outer ()&lt;br /&gt; x [] const -&gt; -&gt; () -&gt; const int remove inner ()&lt;br /&gt;&lt;br /&gt; array of constant pointers to pointers to functions&lt;br /&gt; returning pointers to constant ints&lt;br /&gt;&lt;br /&gt;- p + 1 == &amp;p [1]&lt;br /&gt;&lt;br /&gt;-&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-5619212141547092504?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/5619212141547092504/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=5619212141547092504' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/5619212141547092504'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/5619212141547092504'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/02/linux-tips.html' title='Linux Tips'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-6253397069144188798</id><published>2009-02-10T14:03:00.003+05:30</published><updated>2009-02-10T14:37:08.586+05:30</updated><title type='text'>Unfolding 2-D array in C</title><content type='html'>Last weekend my friends and I had a discussion on 2-D array in C. Surprisingly it went long as everyone had some points and knowledge to share :) Finally we could gather some important information and understood this pearl of C better.&lt;br /&gt;&lt;br /&gt;I'll clear this idea with C code snippets.&lt;br /&gt;&lt;br /&gt;// Declare an array&lt;br /&gt;int arr[2][3]= {1,2,3,4,5,6};&lt;br /&gt;&lt;br /&gt;It's size is 2*3*sizeof(int) = 24 bytes (Intel x86)&lt;br /&gt;&lt;br /&gt;okay, now what will get printed for following statements:&lt;br /&gt;// Say starting address is 1024&lt;br /&gt;&lt;br /&gt;o) print &amp;a + 1&lt;br /&gt;o) print  a + 1&lt;br /&gt;o) print *a + 1&lt;br /&gt;&lt;br /&gt;To answer these questions better, I'll explain what exactly is a 2-D array. When we declare and define a 2-D array, it's like a new user defined type to C. It's a pointer to a memory location that contiguously contains storage of 6 integers. Logically it's like holding many 1-D array in a followed by one-another.&lt;br /&gt;&lt;br /&gt;Ans 1: When you say '&amp;a' , it implies address of user defined type and it's 1024. Now incrementing it by 1 means moving the pointer by the size of this type which is 24 bytes. Thus it'll print 1048.&lt;br /&gt;&lt;br /&gt;Ans 2: 'a' fetch us address of 1-D array or 0th row of our matrix. a+1 would get us address of next row i.e. 1024 + (3*4) = 1036&lt;br /&gt;&lt;br /&gt;Ans 3: '*a' would get you the 0th element of 0th row which is 1. So *a + 1 would get us 2.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-6253397069144188798?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/6253397069144188798/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=6253397069144188798' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/6253397069144188798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/6253397069144188798'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/02/unfolding-2-d-array-in-c.html' title='Unfolding 2-D array in C'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-7556747017557000886</id><published>2009-01-15T19:25:00.002+05:30</published><updated>2009-01-15T19:55:48.771+05:30</updated><title type='text'>More Linux Tips</title><content type='html'>- Detailed info about system: Actually these are kernel messages and are stored as logs in /bin/dmesg.&lt;br /&gt;$dmesg&lt;br /&gt;&lt;br /&gt;- Determining runlevel {Shows previous &amp; current runlevel}&lt;br /&gt;  $runlevel&lt;br /&gt;0-&gt;Halt 1-&gt;Single User Mode&lt;br /&gt;2-&gt; Multiuser w/o NFS 3-&gt; Full Multiuser 6-&gt; Reboot&lt;br /&gt;&lt;br /&gt;To modify init level-&gt; /etc/inittab&lt;br /&gt;&lt;br /&gt;- To switch runlevels, use init command.&lt;br /&gt;  $init 3&lt;br /&gt;&lt;br /&gt;- Difference between Paging and Swapping&lt;br /&gt; Paging refers to movement of pages to frames on the disk. It's a considerably cheaper operation. Swapping means to move entire address space of a process to disk. This is very expensive operation and happens when a process sleeps or when thrashing occurs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-7556747017557000886?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/7556747017557000886/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=7556747017557000886' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/7556747017557000886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/7556747017557000886'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/01/more-linux-tips.html' title='More Linux Tips'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-4230011131049525299</id><published>2009-01-12T19:16:00.002+05:30</published><updated>2009-01-12T19:40:19.462+05:30</updated><title type='text'>Linux Linker Unveiled: The Secret Services</title><content type='html'>Linux linker does not seem to be a lead actor in play of application. But it work like the script which is essential to success of the play. Linker(ldd) is a piece of software that is primarily responsible for address patching a.k.a. relocation. Object files bear absolute and relative addresses.&lt;br /&gt;&lt;br /&gt;// test.c&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;  foo();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Disassembly of section .text:&lt;br /&gt;&lt;br /&gt;00000000 &lt;main&gt;:&lt;br /&gt;   0:   55                      push   %ebp&lt;br /&gt;   1:   89 e5                   mov    %esp,%ebp&lt;br /&gt;   3:   83 ec 08                sub    $0x8,%esp&lt;br /&gt;   6:   83 e4 f0                and    $0xfffffff0,%esp&lt;br /&gt;   9:   b8 00 00 00 00          mov    $0x0,%eax&lt;br /&gt;   e:   29 c4                   sub    %eax,%esp&lt;br /&gt;  10:   e8 fc ff ff ff          call   11 &lt;main+0x11&gt;&lt;br /&gt;  15:   c9                      leave&lt;br /&gt;  16:   c3                      ret&lt;br /&gt;&lt;br /&gt;# An object file always starts on address 0x0000.&lt;br /&gt;&lt;br /&gt;You can see that addresses are relative to the module and called function is completely unknown to foo. Linker take these object files, relocate their addresses to loading addresses(virtual addresses) and resolve calls to function by a function offset table.&lt;br /&gt;&lt;br /&gt;To get a function offset table:&lt;br /&gt;$objdump -x ./test.o&lt;br /&gt;&lt;br /&gt;RELOCATION RECORDS FOR [.text]:&lt;br /&gt;OFFSET   TYPE              VALUE&lt;br /&gt;00000011 R_386_PC32        foo&lt;br /&gt;&lt;br /&gt;All  functions called from a file are listed in this table and here foo() has got 0x11 offset. Once all object files are there linker patches the offset with virtual address. Though call to foo() has been patched with correct virtual address, offset of the instruction is still the same(main+0x11).&lt;br /&gt;&lt;br /&gt;08048344 &lt;main&gt;:&lt;br /&gt; 8048344:       55                      push   %ebp&lt;br /&gt; 8048345:       89 e5                   mov    %esp,%ebp&lt;br /&gt; 8048347:       83 ec 08                sub    $0x8,%esp&lt;br /&gt; 804834a:       83 e4 f0                and    $0xfffffff0,%esp&lt;br /&gt; 804834d:       b8 00 00 00 00          mov    $0x0,%eax&lt;br /&gt; 8048352:       29 c4                   sub    %eax,%esp&lt;br /&gt; 8048354:       e8 03 00 00 00          call   804835c &lt;foo&gt;&lt;br /&gt; 8048359:       c9                      leave&lt;br /&gt; 804835a:       c3                      ret&lt;br /&gt; 804835b:       90                      nop&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;0804835c &lt;foo&gt;:&lt;br /&gt; 804835c:       55                      push   %ebp&lt;br /&gt; 804835d:       89 e5                   mov    %esp,%ebp&lt;br /&gt; 804835f:       5d                      pop    %ebp&lt;br /&gt; 8048360:       c3                      ret&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-4230011131049525299?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/4230011131049525299/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=4230011131049525299' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4230011131049525299'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4230011131049525299'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/01/linux-linker-unveiled-secret-services.html' title='Linux Linker Unveiled: The Secret Services'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-5310588176748122848</id><published>2009-01-09T17:37:00.004+05:30</published><updated>2009-01-15T12:18:04.003+05:30</updated><title type='text'>Linux Secrets!</title><content type='html'>1. Linux uses COW scheme with virtual memory management.&lt;br /&gt;2. Threads in Linux can be LinuxThreads, NPTL(Redhat). NPTL is more efficient and from kernel 2.6 onwards it'll be used. Using env variable LD_ASSUME_KERNEL you can decide which thread library to choose.&lt;br /&gt;3. Linux kernel do not discriminate between threads and processes while making scheduling decision.&lt;br /&gt;4. Memory allocation of a process can be seen with 'pmap' command.&lt;br /&gt;5. Linux CPU scheduler is O(1) scheduler i.e. regardless of number of processes, it always take a constant time to select a process.&lt;br /&gt;6. Linux memory management for IA-32 can address only 1GB of physical memory. Beyond this memory has to mapped to the 1GB range hence allocation a page beyond 1GB degrades performance.&lt;br /&gt;7. IA64 can address 64-128GB of memory.&lt;br /&gt;8. Linux allocates most part of the disk's free space to swap. This improves the performance of VMM.&lt;br /&gt;9. It follows Buddy System for page allocation which try to keep memory address contiguous. Have a loot at /proc/buddyinfo.&lt;br /&gt;10. If no free page is available, kswapd kernel thread reclaims free pages. This thread is used by buddy system and follows LRU. Kernel pages are never swapped out of memory.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-5310588176748122848?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/5310588176748122848/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=5310588176748122848' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/5310588176748122848'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/5310588176748122848'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/01/linux-secrets_09.html' title='Linux Secrets!'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-654366390219138710</id><published>2009-01-08T19:09:00.003+05:30</published><updated>2009-01-08T19:09:52.616+05:30</updated><title type='text'>Stack Unwinding</title><content type='html'>A very nice explanation of what stack unwinding is and why is it needed.&lt;br /&gt;  http://docs.hp.com/en/B9106-90012/unwind.5.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-654366390219138710?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/654366390219138710/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=654366390219138710' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/654366390219138710'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/654366390219138710'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/01/stack-unwinding.html' title='Stack Unwinding'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-4677541827992302690</id><published>2009-01-07T19:53:00.004+05:30</published><updated>2009-01-07T20:28:25.736+05:30</updated><title type='text'>Linux Memory Management Secrets!</title><content type='html'>Tips to Improve Dynamic Memory Performance&lt;br /&gt;&lt;br /&gt;- Instead of using memset() to initialize malloc()'ed memory, use calloc(). Because when you call memset(), VM system has to map the pages in to memory in order to zero initialize them. It's very expensive and wasteful if you don't intend to use the pages right away.&lt;br /&gt;calloc() reserves the needed address space but does not zero initialize them unless memory is used. Hence it postpones the need to load pages in to memory. It also lets the system initialize pages as they’re used, as opposed to all at once.&lt;br /&gt;&lt;br /&gt;- Lazy allocation: A global(normal variable or a buffer) can be replaced with a static and a couple of functions to allow its access.&lt;br /&gt;&lt;br /&gt;- memcpy() &amp; memmove() needs both blocks to be memory resident. Use them if size of blocks is small(&gt;16KB), you would be using the blocks right away, s/d blocks are not page aligned, blocks overlap.&lt;br /&gt;But if you intend to postpone the use, you would increasing the working set of the application. For small amount of data, use memcpy().&lt;br /&gt;&lt;br /&gt;- To check heap dysfunctional behavior: $ MALLOC_CHECK_=1 ./a.out&lt;br /&gt;  It'll give an address related to each violation of dynamic memory routines.&lt;br /&gt;&lt;br /&gt;- Electric fence : Works very well with gdb&lt;br /&gt;&lt;br /&gt;- Libsafe: for libc routines&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-4677541827992302690?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/4677541827992302690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=4677541827992302690' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4677541827992302690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/4677541827992302690'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2009/01/linux-secrets.html' title='Linux Memory Management Secrets!'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4233584295994918105.post-2155749175919842707</id><published>2008-10-15T15:47:00.005+05:30</published><updated>2008-10-15T16:00:18.268+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='clearcase'/><category scheme='http://www.blogger.com/atom/ns#' term='vi'/><category scheme='http://www.blogger.com/atom/ns#' term='vimdiff'/><category scheme='http://www.blogger.com/atom/ns#' term='rational'/><title type='text'>Rational Clearcase: Some Useful Commands</title><content type='html'>Hi,&lt;br /&gt;  Rational Clearcase is perhaps the most popular version management software across various organizations. Here is my humble attempt to capture most useful commands that can save a lot of your time.&lt;br /&gt;&lt;br /&gt;a) Creating an element&lt;br /&gt;   $cleartool mkelem -eltype{binary, directory etc.} elem_name&lt;br /&gt;&lt;br /&gt;b) Creating many elements at once or say you want to convert your non-clearcase element as versioned.&lt;br /&gt;   - first copy &amp; paste all such files/dir in a destination directory.&lt;br /&gt;     $find -type f/d |xargs cleartool mkelem eltype elem_name&lt;br /&gt;&lt;br /&gt;b) Browsing files in your branch&lt;br /&gt;  $ct find ./ -branch 'brtype(_view_name)' -print&lt;br /&gt;&lt;br /&gt;c) Soft Links&lt;br /&gt;  $cleartool ln -s target link_name&lt;br /&gt;  &lt;br /&gt;   To update a link, remove it first($ cleartool rmname link_name), create a new link with same/different in a checked-out directory.&lt;br /&gt;&lt;br /&gt;d) Merging changes in main branch&lt;br /&gt;You have two options:&lt;br /&gt;1. Use cleartool merge&lt;br /&gt;2. Use diff/patch OR vimdiff&lt;br /&gt;&lt;br /&gt;cleartool merge&lt;br /&gt;---------------&lt;br /&gt;- Checkout file with your changes.&lt;br /&gt;- $cleartool merge -to file_with_your_changes -version main_branch_version&lt;br /&gt;&lt;br /&gt;vimdiff&lt;br /&gt;-------&lt;br /&gt;Amazingly simple and useful.&lt;br /&gt;&lt;br /&gt;- Checkout file with your changes.&lt;br /&gt;- $vimdiff file_with_your_changes file_on_main_branch&lt;br /&gt;- You can make out the changes which are maked with different colors.&lt;br /&gt;- Look the file on right side pane, a red color signifies some change in the line&lt;br /&gt;- Merge changes with :,+1 diffget&lt;br /&gt;- Moreover you can use any vi command.&lt;br /&gt;&lt;br /&gt;Hope these inputs would help people.&lt;br /&gt;&lt;br /&gt;Thanks a lot!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4233584295994918105-2155749175919842707?l=bbluehive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bbluehive.blogspot.com/feeds/2155749175919842707/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4233584295994918105&amp;postID=2155749175919842707' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2155749175919842707'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4233584295994918105/posts/default/2155749175919842707'/><link rel='alternate' type='text/html' href='http://bbluehive.blogspot.com/2008/10/rational-clearcase-some-useful-commands.html' title='Rational Clearcase: Some Useful Commands'/><author><name>Bluehive</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='http://bp1.blogger.com/_ZLO5p0WJ5js/SAiIu5Tw-fI/AAAAAAAABeo/-oXfGhtTwZk/S220/Love-zh.png'/></author><thr:total>0</thr:total></entry></feed>
