<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-18437616</id><updated>2024-10-06T23:20:30.352-07:00</updated><title type='text'>The Extra Space</title><subtitle type='html'>Some interesting stuff I come across</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://theextraspace.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://theextraspace.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>libin_v</name><uri>http://www.blogger.com/profile/06681436264062842278</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-18437616.post-3628708839682857196</id><published>2008-10-01T07:08:00.000-07:00</published><updated>2008-10-01T07:08:00.859-07:00</updated><title type='text'>New/Delete advantages</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;p&gt;Brushing through some basics:&lt;br/&gt;&lt;/p&gt;&lt;br /&gt;      &lt;ul&gt;&lt;li&gt;new/delete invokes constructor/destructor. Malloc/free will not.&lt;br /&gt;        &lt;/li&gt;&lt;li&gt;new does not need typcasting. Malloc requires typcasting the returned pointer.&lt;br /&gt;        &lt;/li&gt;&lt;li&gt;new/delete operators can be overloaded, malloc/free can not.&lt;br /&gt;        &lt;/li&gt;&lt;li&gt;new does not require you to explicitly calculate the quantity of memory required. (Unlike malloc)&lt;br /&gt;        &lt;/li&gt;&lt;/ul&gt;Ref: &lt;a href=&#39;http://www.yolinux.com/TUTORIALS/Cpp-DynamicMemory.html&#39;&gt;C / C++ and Dynamic memory allocation&lt;/a&gt;&lt;br/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://theextraspace.blogspot.com/feeds/3628708839682857196/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/18437616/3628708839682857196' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/3628708839682857196'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/3628708839682857196'/><link rel='alternate' type='text/html' href='http://theextraspace.blogspot.com/2008/10/newdelete-advantages.html' title='New/Delete advantages'/><author><name>libin_v</name><uri>http://www.blogger.com/profile/06681436264062842278</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-18437616.post-5399538451258095950</id><published>2008-09-15T18:59:00.000-07:00</published><updated>2008-09-15T19:06:11.230-07:00</updated><title type='text'>Colour your Eclipse Chrome!</title><content type='html'>&lt;span style=&quot;font-family:verdana;&quot;&gt;To add a browser to eclipse, Go to &lt;b&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;Window -&gt; Preferences -&gt; General -&gt; Web&lt;br /&gt;Browser&lt;/span&gt;&lt;/b&gt; and click &lt;b&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;Add&lt;/span&gt;&lt;/b&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi53_SR6vVteCIhAXjPMcRN3z9eK4rN1ZeEBYDFFcdTICCNDCQZVwo83VHC4gs4WSD4haeacet20smbf7gEymizHWjN9SMWE4dyUWqTcpfC7brvdqci2TZAOfGFb7as2y4nK2bK8Q/s1600-h/ChromeEclipse.png&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi53_SR6vVteCIhAXjPMcRN3z9eK4rN1ZeEBYDFFcdTICCNDCQZVwo83VHC4gs4WSD4haeacet20smbf7gEymizHWjN9SMWE4dyUWqTcpfC7brvdqci2TZAOfGFb7as2y4nK2bK8Q/s320/ChromeEclipse.png&quot; style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi53_SR6vVteCIhAXjPMcRN3z9eK4rN1ZeEBYDFFcdTICCNDCQZVwo83VHC4gs4WSD4haeacet20smbf7gEymizHWjN9SMWE4dyUWqTcpfC7brvdqci2TZAOfGFb7as2y4nK2bK8Q/s320/ChromeEclipse.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5246433290859927090&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;To find the location of your chrome installation, try using the Properties of&lt;br /&gt;the Shortcut Link. &lt;i&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;&lt;b&gt;[Right-Click on Short-Cut -&gt; Properties -&gt; Target]&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;&lt;a href=&quot;http://www.ericdlarson.com/misc/chrome_command_line_flags.html&quot;&gt;More chrome command-line options&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Make sure you have the Chrome browser checked to act as your default Eclipse Browser.&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;font-family:arial;font-size:13;&quot;  &gt;&lt;em style=&quot;font-weight: bold; font-style: normal; text-decoration: inherit;&quot;&gt;&lt;/em&gt;&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://theextraspace.blogspot.com/feeds/5399538451258095950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/18437616/5399538451258095950' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/5399538451258095950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/5399538451258095950'/><link rel='alternate' type='text/html' href='http://theextraspace.blogspot.com/2008/09/colour-your-eclipse-chrome.html' title='Colour your Eclipse Chrome!'/><author><name>libin_v</name><uri>http://www.blogger.com/profile/06681436264062842278</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi53_SR6vVteCIhAXjPMcRN3z9eK4rN1ZeEBYDFFcdTICCNDCQZVwo83VHC4gs4WSD4haeacet20smbf7gEymizHWjN9SMWE4dyUWqTcpfC7brvdqci2TZAOfGFb7as2y4nK2bK8Q/s72-c/ChromeEclipse.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-18437616.post-574833155172184925</id><published>2008-09-12T08:50:00.001-07:00</published><updated>2008-09-15T01:23:32.879-07:00</updated><title type='text'>Setting SVN with HTTP(S) - It&amp;#39;s Simple</title><content type='html'>&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;I was looking into SVN and it was a great experience setting it up.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;svn create --fs-type fsfs &amp;lt;repos-path&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;i&gt;NOTE: &lt;a href=&quot;http://svn.collab.net/repos/svn/trunk/notes/fsfs&quot;&gt;Why FSFS is used ?&lt;/a&gt; &lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;HOMEWORK before start!!!&lt;/b&gt; - For creating new Products and maintain the tags,branches and truck please refer &lt;a href=&quot;http://svnbook.red-bean.com/en/1.4/svn.reposadmin.planning.html#svn.reposadmin.projects.chooselayout&quot;&gt;Strategies for Repository Deployment&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Taking Backup&lt;br /&gt;&lt;/b&gt;&lt;ol&gt;&lt;li&gt;Create Dump File&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;$ svnadmin dump &amp;lt;repos-path&amp;gt; &amp;gt; &amp;lt;dumpfile&amp;gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;Import Backup Dump File&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;$ svnadmin load &amp;lt;repos-path&amp;gt; &amp;lt; &amp;lt;dumpfile&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;/li&gt;&lt;/ol&gt;&lt;b&gt;Access Protocol&lt;/b&gt;: &lt;b&gt;&lt;a href=&quot;http://svnbook.red-bean.com/en/1.4/svn.serverconfig.overview.html#svn.serverconfig.overview.tbl-1&quot;&gt;Suggested&lt;/a&gt; is HTTPS&lt;/b&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Disable svn&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Make sure the svnserve is not running as deamon or inetd process.&lt;br /&gt;OR&lt;/li&gt;&lt;li&gt;Disable read and write through svnserve - Edit the svnserve.conf and set &lt;span style=&quot;font-family:Courier New;&quot;&gt;anon-access=none&lt;/span&gt; and auth-access = none&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Basic Setup&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Load Access Modules in httpd.conf&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;LoadModule dav_module         modules/mod_dav.so&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;LoadModule dav_svn_module     modules/mod_dav_svn.so&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;&amp;lt;Location /repos&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;  DAV svn&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;  SVNPath /absolute/path/to/repository&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;&amp;lt;/Location&amp;gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;Make sure that the repository has read-write permissions for apache&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;chown -R apache &amp;lt;repos-path&amp;gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;Restart server &amp;amp; check&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;User Authentication&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Create a &lt;a href=&quot;http://httpd.apache.org/docs/1.3/programs/htpasswd.html&quot;&gt;htpasswd&lt;/a&gt; file with users&lt;br /&gt;&lt;ul&gt;&lt;li&gt;$ htpasswd -c /path/to/htpasswd/file user - Create User Credential&lt;/li&gt;&lt;li&gt;$ htpasswd /path/to/htpasswd/file user - Append Users to List&lt;/li&gt;&lt;li&gt;$ htpasswd -b /path/to/htpasswd/file user password - Batch mode, password is visible&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Add the below to httpd.conf under the SVN Location&lt;br /&gt;&lt;i&gt;&lt;/i&gt;&lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;AuthType Basic&lt;br /&gt;AuthName &quot;Subversion repository&quot;&lt;br /&gt;AuthUserFile /path/to/htpasswd/file&lt;br /&gt;# only authenticated users may access the repository&lt;br /&gt;Require valid-user&lt;/span&gt;&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;Restart and check&lt;/li&gt;&lt;/ul&gt;NOTE: There is no need to restart server when the htpasswd file changes&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Per-Directory Access Control&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Create an Access control Policy File&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;[groups]&lt;br /&gt;Full-SVN-RO = svnreader&lt;br /&gt;Proj1-RW = user1 user2 user3&lt;br /&gt;Proj1-RO = user4&lt;br /&gt;Proj2-RW = user1 user6 user7&lt;br /&gt;Proj2-RO = user8 user2&lt;br /&gt;EveryOne = @Full-SVN-RO, @Proj1-RW, @Proj1-RO, @Proj2-RW, @Proj2-Ro&lt;br /&gt;&lt;br /&gt;# Access control to whole SVN&lt;br /&gt;[/]&lt;br /&gt;svnadmin = rw    # No Groups allowed to Read-Write the whole SVN Repos&lt;br /&gt;@Full-SVN-RO = are&lt;br /&gt;&lt;br /&gt;# Access to Proj1&lt;br /&gt;[/Proj1]&lt;br /&gt;@Proj1-RW = rw&lt;br /&gt;@Proj1-RO = r&lt;br /&gt;&lt;br /&gt;# Access to Proj2&lt;br /&gt;[/Proj2]&lt;br /&gt;@Proj2-RW = rw&lt;br /&gt;@Proj2-RO = r&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add the below module to httpd.conf&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;LoadModule authz_svn_module   modules/mod_authz_svn.so&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;Add Access control Policy File in Location of SVN&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;AuthzSVNAccessFile /path/to/access/file&lt;/span&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;Restart httpd and check&lt;/li&gt;&lt;/ul&gt;NOTE: There is no need to restart server when the Access control Policy File changes&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Enable SSL&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.securityfocus.com/infocus/1818&quot;&gt;Setup Apache with SSL&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Redirect Request to HTTPS&lt;span style=&quot;font-family:Courier New;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;#Redirect all port 80 requests to 443&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;RewriteEngine On&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;RewriteCond %{SERVER_PORT} !^443$&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [L,R]&lt;/span&gt;&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;Deny if not accessed without SSL. Add the below under the Location of SVN&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;SSLRequireSSL&lt;/span&gt;&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;Restart and check&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Apache logging&lt;br /&gt;&lt;span style=&quot;font-family: courier new;&quot;&gt;&lt;blockquote&gt;CustomLog logs/svn_logfile &quot;%t %u %{SVN-ACTION}e&quot; env=SVN-ACTION&lt;/blockquote&gt;&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;a href=&quot;http://svnbook.red-bean.com/en/1.0/ch05s04.html#svn-ch-5-sect-6.1&quot;&gt;&lt;b&gt;Single Repository vs. Multiple Repository&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;I feel Single Repositories are easy to maintain and administer. Only if there are hundred&#39;s of project then I suggest Multiple Repositories.&lt;br /&gt;&lt;br /&gt;An example of httpd.conf for multiple repositories.&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;&amp;lt;Location /svn/&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;  DAV svn &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;  SVNParentPath /data/subv/repos/ &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;&amp;lt;/Location&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;&amp;lt;Location /svn/testA/&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;# Authenticate a user &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;        AuthType Basic &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;        AuthName &quot;TestA Subversion Repository&quot; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;        AuthUserFile /data/subv-testA/perms/users &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;        Require valid-user &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;# Authenticate permissions &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;        AuthzSVNAccessFile /data/subv-testA/perms/perms &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;# Requires SSL&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;        SSLRequireSSL &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;&amp;lt;/Location&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;&amp;lt;Location /svn/testB/&amp;gt; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;# Authenticate a user &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;        AuthType Basic &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;        AuthName &quot;TestB Subversion Repository&quot; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;        AuthUserFile /data/subv-testB/perms/users &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;        Require valid-user &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;# No permissions &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;#        AuthzSVNAccessFile /data/subv-testB/perms/perms &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;# No SSL&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;#        SSLRequireSSL &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;&amp;lt;/Location&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://theextraspace.blogspot.com/feeds/574833155172184925/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/18437616/574833155172184925' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/574833155172184925'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/574833155172184925'/><link rel='alternate' type='text/html' href='http://theextraspace.blogspot.com/2008/09/setting-svn-with-https-it-simple.html' title='Setting SVN with HTTP(S) - It&amp;#39;s Simple'/><author><name>libin_v</name><uri>http://www.blogger.com/profile/06681436264062842278</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-18437616.post-3076926248001968328</id><published>2008-09-04T05:16:00.001-07:00</published><updated>2008-09-04T05:17:05.860-07:00</updated><title type='text'>Kernel Locking Techniques</title><content type='html'>link: &lt;a class=&quot;moz-txt-link-freetext&quot; href=&quot;http://www.linuxjournal.com/node/5833/&quot;&gt;http://www.linuxjournal.com/node/5833/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;    With the rise of multi-threaded and multi-process programming, the race condition in  many code is becoming evident.&lt;br /&gt;&lt;blockquote&gt;Race Condition&lt;br /&gt;  &lt;big&gt;&lt;span style=&quot;font-size:-1;&quot;&gt;&lt;big&gt;A race hazard (or race condition) is a flaw in a system or process where the output exhibits unexpected critical dependence on the relative timing of events. The term originates with the idea of two signals racing each other to influence the output first. &lt;/big&gt;&lt;/span&gt;&lt;/big&gt;&lt;br /&gt;  &lt;big&gt;&lt;span style=&quot;font-size:-1;&quot;&gt;&lt;big&gt;&lt;span style=&quot;color:#33ffff;&quot;&gt;&lt;a href=&quot;http://www.google.co.in/url?sa=X&amp;amp;start=3&amp;amp;oi=define&amp;amp;ei=SRAMRJLfDomYYO2WzcwB&amp;amp;sig2=LiLwa2sR7PRpMdfoEF9y7g&amp;amp;q=http://en.wikipedia.org/wiki/Race_condition&quot;&gt;en.wikipedia.org/wiki/Race_condition&lt;/a&gt;&lt;/span&gt;&lt;/big&gt;&lt;/span&gt;&lt;/big&gt;&lt;br /&gt;&lt;/blockquote&gt;     This can be solved by using atomic operations or some locking semantics. Getting to understand which shared data is to locked or made atomic, does an interrupt disturb the locking semantics is tough. If the locking semantics are wrongly designed -- deadend, called deadlock.&lt;br /&gt;&lt;blockquote&gt;Deadlock&lt;br /&gt;  &lt;big&gt;&lt;span style=&quot;font-size:-1;&quot;&gt;&lt;big&gt;In operating systems, a situation in which two or more processes are blocked while waiting for resources that the other controls so that none of the affected processes can continue to execute. Also known as the &quot;deadly embrace.&quot;&lt;/big&gt;&lt;/span&gt;&lt;/big&gt;&lt;br /&gt;  &lt;a href=&quot;http://www.google.co.in/url?sa=X&amp;amp;start=12&amp;amp;oi=define&amp;amp;ei=XREMRNiFMcyYYYHqwJ8B&amp;amp;sig2=coq6HI3Os2eemscjvlyTlQ&amp;amp;q=http://www.ssuet.edu.pk/taimoor/books/0-7897-1063-3/appa.htm&quot;&gt;&lt;span style=&quot;color:#008000;&quot;&gt;&lt;span style=&quot;color:#3333ff;&quot;&gt;www.ssuet.edu.pk/taimoor/books/0-7897-1063-3/appa.htm&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/blockquote&gt;     The linux Kernel provides some functions to reduce data races &lt;div class=&quot;simplesect&quot; lang=&quot;en&quot;&gt; &lt;div class=&quot;titlepage&quot;&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Why Do We Need Locking in the Kernel?&lt;br /&gt;&lt;/b&gt;&lt;/u&gt;    Thus the issue here is &quot;&lt;big&gt;&lt;span style=&quot;font-size:-1;&quot;&gt;&lt;big&gt;relative timing of events&quot; or  a synchronization problem.&lt;/big&gt;&lt;/span&gt;&lt;/big&gt; Shared memory, though with it many advantages poses many design issues. A simple i++ (i=2) done by 2 processes will result in an unexpected result 3, when it should have been 4 (increment twice). These critical regions require locking. The Linux kernel provides a family of locking primitives that developers can use to write safe and efficient code.&lt;br /&gt;&lt;blockquote&gt;Critical regions&lt;br /&gt;  &lt;big&gt;&lt;span style=&quot;font-size:-1;&quot;&gt;&lt;big&gt;A critical section is a piece of code that can only be executed by one process at a time. It will usually terminate in fixed time and a process will only have to wait a fixed time to enter it. Some synchronisation mechanism is required at the entry and exit of the critical section to ensure exclusive use, for example a semaphore. &lt;/big&gt;&lt;/span&gt;&lt;/big&gt;&lt;br /&gt;  &lt;big&gt;&lt;span style=&quot;font-size:-1;color:#3333ff;&quot;&gt;&lt;big&gt;&lt;a href=&quot;http://www.google.co.in/url?sa=X&amp;amp;start=5&amp;amp;oi=define&amp;amp;ei=aRMMRP3ZGIrsYPPJ0PsO&amp;amp;sig2=HFG_Qi_AN7bt5EVnJ__scQ&amp;amp;q=http://en.wikipedia.org/wiki/Critical_section&quot;&gt;en.wikipedia.org/wiki/Critical_section&lt;/a&gt;&lt;/big&gt;&lt;/span&gt;&lt;/big&gt;&lt;br /&gt;&lt;/blockquote&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;simplesect&quot; lang=&quot;en&quot;&gt; &lt;div class=&quot;titlepage&quot;&gt;&lt;b&gt;&lt;u&gt;Why is SMP Locks in a Uniprocessor Kernel?&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;    Though you may not have a SMP machine when you write code, others who are using your code may. And the linux maintaners, will never insert any code that does not handle locking issues. SMP and UP kernels are distinct. &quot;This allows certain locks not to exist at all in a UP kernel. Different combinations of CONFIG_SMP and CONFIG_PREEMPT compile in varying lock support. It does not matter, however, to the developer: lock everything appropriately and all situations will be covered.&quot;&lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;simplesect&quot; lang=&quot;en&quot;&gt; &lt;div class=&quot;titlepage&quot;&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Atomic Operators&lt;br /&gt;&lt;/b&gt;&lt;/u&gt;    Atomic Operations are the simplest ways of achieving kernel synchronization. The other locking primitives are built using Atomic operations.&lt;br /&gt;&lt;blockquote&gt;Atomic Operation&lt;big&gt;&lt;span style=&quot;font-size:-1;&quot;&gt;   &lt;li&gt;&lt;big&gt;An operation that cannot be interrupted &lt;span style=&quot;color:#000099;&quot;&gt;&lt;a href=&quot;http://www.google.co.in/url?sa=X&amp;amp;start=0&amp;amp;oi=define&amp;amp;ei=HRUMRIKjL7W6YOOUzMIO&amp;amp;sig2=6_HKgdeHWeHoegYOM72TlQ&amp;amp;q=http://docs.cray.com/books/004-2518-002/html-004-2518-002/zglossaryqkdxjklv.html&quot;&gt;docs.cray.com/books/004-2518-002/html-004-2518-002/zglossaryqkdxjklv.html&lt;/a&gt;&lt;/span&gt;&lt;/big&gt;&lt;/li&gt;   &lt;/span&gt;&lt;span style=&quot;font-size:-1;&quot;&gt;   &lt;li&gt;&lt;big&gt;Operation that executes without interference by other concurrently-executing processes or threads. &lt;span style=&quot;color:#000099;&quot;&gt;&lt;a href=&quot;http://www.google.co.in/url?sa=X&amp;amp;start=1&amp;amp;oi=define&amp;amp;ei=HRUMRIKjL7W6YOOUzMIO&amp;amp;sig2=LzLhWJns3f6BDqcpoBmsXg&amp;amp;q=http://www.cise.ufl.edu/research/ParallelPatterns/PatternLanguage/Background/Glossary.htm&quot;&gt;www.cise.ufl.edu/research/ParallelPatterns/PatternLanguage/Background/Glossary.htm&lt;/a&gt;&lt;/span&gt;&lt;/big&gt;&lt;/li&gt;   &lt;/span&gt;&lt;/big&gt;&lt;/blockquote&gt; Consider the previous example of i++. If we could read i, increment it and write it back to memory in one uninterruptible operation, the race condition discussed above would not be an issue. Atomic operators provide these uninterruptible operations.&lt;/div&gt; &lt;pre class=&quot;programlisting&quot;&gt;&lt;tt&gt;atomic_t v;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;atomic_set(&amp;amp;v, 5);  /* v = 5 (atomically) */&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;atomic_add(3, &amp;amp;v);  /* v = v + 3 (atomically) */&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;atomic_dec(&amp;amp;v);     /* v = v - 1 (atomically) */&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;printf(&quot;This will print 7: %d\n&quot;, atomic_read(&amp;amp;v));&lt;/tt&gt;&lt;/pre&gt; &lt;p&gt;    Some points to remember.&lt;br /&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;you cannot pass an atomic_t to anything but one of the atomic operators.&lt;/li&gt;&lt;li&gt;you cannot pass anything to an atomic operator except an atomic_t.&lt;/li&gt;&lt;/ul&gt; &lt;/div&gt; &lt;div class=&quot;simplesect&quot; lang=&quot;en&quot;&gt; &lt;div class=&quot;titlepage&quot;&gt;&lt;u&gt;&lt;b&gt;Spinlocks&lt;br /&gt;&lt;/b&gt;&lt;/u&gt;    When more complex locking design is needed, we don&#39;t rely on atomic operations. Spinlocks are commonly used in the kernel, defined in include/asm/spinlock.h and include/linux/spinlock.h. The spinlock is a very simple single-holder lock. If a process attempts to acquire a spinlock and it is unavailable, the process will keep trying (spinning) until it can acquire the lock. This simplicity creates a small and fast lock. The basic use of the spinlock is:&lt;br /&gt;&lt;/div&gt; &lt;tt&gt;&lt;br /&gt;spinlock_t mr_lock = SPIN_LOCK_UNLOCKED;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;unsigned long flags;&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;spin_lock_irqsave(&amp;amp;mr_lock, flags);&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;/* critical section ... */&lt;/tt&gt;&lt;br /&gt;&lt;tt&gt;spin_unlock_irqrestore(&amp;amp;mr_lock, flags);&lt;br /&gt;&lt;br /&gt;&lt;/tt&gt;spin_lock_irqsave() will disable interrupts locally and provide the spinlock on SMP. This covers both interrupt and SMP concurrency issues&lt;br /&gt;spin_unlock_irqrestore(), interrupts are restored to the state when the lock was acquired.&lt;br /&gt;&lt;p&gt;    With a UP kernel, the above code compiles to the same as:&lt;/p&gt; &lt;tt&gt;unsigned long flags;&lt;br /&gt;save_flags(flags);&lt;br /&gt;cli();&lt;br /&gt;/* critical section ... */&lt;br /&gt;restore_flags(flags);&lt;br /&gt;&lt;br /&gt;&lt;/tt&gt;spin_lock_irq() disables and re-enables interrupts unconditionally, in the same manner as cli() and sti(). Use this only when you know that interrupts were not already disabled before the acquisition of the lock.&lt;br /&gt;&lt;tt&gt;&lt;br /&gt;spinlock_t mr_lock = SPIN_LOCK_UNLOCKED;&lt;br /&gt;spin_lock_irq(&amp;amp;mr_lock);&lt;br /&gt;/* critical section ... */&lt;br /&gt;spin_unlock_irq(&amp;amp;mr_lock);&lt;/tt&gt; &lt;p&gt;spin_lock() and spin_unlock() methods that acquire and release the specified lock without any interaction with interrupts.&lt;br /&gt;spin_lock_bh() that implements the standard spinlock as well as disables softirqs. This is needed when you have code outside a softirq that is also used inside a softirq. The corresponding unlock function is naturally spin_unlock_bh().&lt;/p&gt; &lt;p&gt;You must be careful not to re-acquire a spinlock you already hold, or you will deadlock.&lt;/p&gt; &lt;p&gt;Spinlocks should be used to lock data in situations where the lock is not held for a long time--recall that a waiting process will spin, doing nothing, waiting for the lock. (See the ``Rules&#39;&#39; Sidebar for guidelines on what is considered a long time.) Thankfully, spinlocks can be used anywhere. You cannot, however, do anything that will sleep while holding a spinlock. For example, never call any function that touches user memory, kmalloc() with the GFP_KERNEL flag, any semaphore functions or any of the schedule functions while holding a spinlock. You have been warned.&lt;/p&gt; &lt;u&gt;&lt;b&gt;Semaphores&lt;br /&gt;&lt;/b&gt;&lt;/u&gt;    If you need a lock that is safe to hold for longer periods of time, safe to sleep with or capable of allowing concurrency to do more than one process at a time, Linux provides the semaphore. Semaphores in Linux are sleeping locks. Because they cause a task to sleep on contention, instead of spin, they are used in situations where the lock-held time may be long. Conversely, since they have the overhead of putting a task to sleep and subsequently waking it up, they should not be used where the lock-held time is short.&lt;br /&gt;    Semaphores are represented by a structure, struct semaphore, which is defined in include/asm/semaphore.h. The structure contains a pointer to a wait queue and a usage count. The wait queue is a list of processes blocking on the semaphore. The usage count is the number of concurrently allowed holders. If it is negative, the semaphore is unavailable and the absolute value of the usage count is the number of processes blocked on the wait queue. The usage count is initialized at runtime via sema_init(), typically to 1 (in which case the semaphore is called a mutex).&lt;br /&gt;    Semaphores are manipulated via two methods: down (historically P) and up (historically V). The former attempts to acquire the semaphore and blocks if it fails. The later releases the semaphore, waking up any tasks blocked along the way.&lt;br /&gt;    Semaphore use is simple in Linux. To attempt to acquire a semaphore, call the down_interruptible() function. This function decrements the usage count of the semaphore. If the new value is less than zero, the calling process is added to the wait queue and blocked. If the new value is zero or greater, the process obtains the semaphore and the call returns 0. If a signal is received while blocking, the call returns -EINTR and the semaphore is not acquired.&lt;br /&gt;    The up() function, used to release a semaphore, increments the usage count. If the new value is greater than or equal to zero, one or more tasks on the wait queue will be woken up:&lt;br /&gt;&lt;/div&gt; &lt;div class=&quot;simplesect&quot; lang=&quot;en&quot;&gt; &lt;tt&gt;&lt;br /&gt;struct semaphore mr_sem;&lt;br /&gt;sema_init(&amp;amp;mr_sem, 1); /* usage count is 1 */&lt;br /&gt;if (down_interruptible(&amp;amp;mr_sem))&lt;br /&gt;/* semaphore not acquired; received a signal ... */&lt;br /&gt;/* critical region (semaphore acquired) ... */&lt;br /&gt;up(&amp;amp;mr_sem);&lt;/tt&gt; &lt;p&gt;down() function, which differs in that it puts the calling task into an uninterruptible sleep. A signal received by a process blocked in uninterruptible sleep is ignored&lt;br /&gt;down_trylock() function, which attempts to acquire the given semaphore. If the call fails, down_trylock() will return nonzero instead of blocking.&lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;b&gt;Reader/Writer Locks&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;    Since it is typically safe for multiple threads to read data concurrently, so long as nothing modifies the data, reader/writer locks allow multiple concurrent readers but only a single writer (with no concurrent readers). If your data access naturally divides into clear reading and writing patterns, especially with a greater amount of reading than writing, the reader/writer locks are often preferred. The reader/writer spinlock is called an rwlock and is used similarly to the standard spinlock, with the exception of separate reader/writer locking:&lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;simplesect&quot; lang=&quot;en&quot;&gt; &lt;tt&gt;rwlock_t mr_rwlock = RW_LOCK_UNLOCKED;&lt;br /&gt;read_lock(&amp;amp;mr_rwlock);&lt;br /&gt;/* critical section (read only) ... */&lt;br /&gt;read_unlock(&amp;amp;mr_rwlock);&lt;br /&gt;write_lock(&amp;amp;mr_rwlock);&lt;br /&gt;/* critical section (read and write) ... */&lt;br /&gt;write_unlock(&amp;amp;mr_rwlock);&lt;/tt&gt; &lt;p&gt;Likewise, the reader/writer semaphore is called an rw_semaphore and use is identical to the standard semaphore, plus the explicit reader/writer locking:&lt;/p&gt; &lt;tt&gt;struct rw_semaphore mr_rwsem;&lt;br /&gt;init_rwsem(&amp;amp;mr_rwsem);&lt;br /&gt;down_read(&amp;amp;mr_rwsem);&lt;br /&gt;/* critical region (read only) ... */&lt;br /&gt;up_read(&amp;amp;mr_rwsem);&lt;br /&gt;down_write(&amp;amp;mr_rwsem);&lt;br /&gt;/* critical region (read and write) ... */&lt;br /&gt;up_write(&amp;amp;mr_rwsem);&lt;br /&gt;&lt;br /&gt;&lt;/tt&gt;Use of reader/writer locks, where appropriate, is an appreciable optimization.&lt;br /&gt;Note: reader locks cannot be automatically upgraded to the writer variant. Therefore, attempting to acquire exclusive access while holding reader access will deadlock.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Big-Reader Locks&lt;br /&gt;&lt;/b&gt;&lt;/u&gt;    Big-reader locks (brlocks), defined in include/linux/brlock.h, are a specialized form of reader/writer locks. It is a spinning lock that is very fast to acquire for reading but incredibly slow to acquire for writing. Therefore, they are ideal in situations where there are many readers and few writers. While the behavior of brlocks is different from that of rwlocks, their usage is identical with the lone exception that brlocks are predefined in brlock_indices (see brlock.h):&lt;br /&gt;&lt;/div&gt; &lt;div class=&quot;simplesect&quot; lang=&quot;en&quot;&gt; &lt;tt&gt;&lt;br /&gt;br_read_lock(BR_MR_LOCK);&lt;br /&gt;/* critical region (read only) ... */&lt;br /&gt;br_read_unlock(BR_MR_LOCK);&lt;br /&gt;&lt;br /&gt;&lt;/tt&gt;&lt;/div&gt; &lt;div class=&quot;simplesect&quot; lang=&quot;en&quot;&gt; &lt;div class=&quot;titlepage&quot;&gt;&lt;u&gt;&lt;b&gt;The Big Kernel Lock&lt;br /&gt;&lt;/b&gt;&lt;/u&gt;    Linux contains a global kernel lock, kernel_flag, that was originally introduced in kernel 2.0 as the only SMP lock. During 2.2 and 2.4, much work went into removing the global lock from the kernel and replacing it with finer-grained localized locks. Today, the global lock&#39;s use is minimal. It still exists, however, and developers need to be aware of it.&lt;br /&gt;    The global kernel lock is called the big kernel lock or BKL. It is a spinning lock that is recursive; therefore two consecutive requests for it will not deadlock the process (as they would for a spinlock). Further, a process can sleep and even enter the scheduler while holding the BKL. When a process holding the BKL enters the scheduler, the lock is dropped so other processes can obtain it. This is also known as release-on-block/sleep These attributes of the BKL helped ease the introduction of SMP during the 2.0 kernel series. Today, however, they should provide plenty of reason &lt;span class=&quot;emphasis&quot;&gt;&lt;em&gt;not&lt;/em&gt;&lt;/span&gt; to use the lock.&lt;br /&gt;    Use of the big kernel lock is simple. Call lock_kernel() to acquire the lock and unlock_kernel() to release it. The routine kernel_locked() will return nonzero if the lock is held, zero if not. For example:&lt;br /&gt;&lt;/div&gt; &lt;tt&gt;&lt;br /&gt;lock_kernel();&lt;br /&gt;/* critical region ... */&lt;br /&gt;unlock_kernel();&lt;br /&gt;&lt;/tt&gt; &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://theextraspace.blogspot.com/feeds/3076926248001968328/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/18437616/3076926248001968328' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/3076926248001968328'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/3076926248001968328'/><link rel='alternate' type='text/html' href='http://theextraspace.blogspot.com/2008/09/kernel-locking-techniques.html' title='Kernel Locking Techniques'/><author><name>libin_v</name><uri>http://www.blogger.com/profile/06681436264062842278</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-18437616.post-4889012883981399583</id><published>2008-09-04T05:15:00.001-07:00</published><updated>2008-09-04T05:15:37.021-07:00</updated><title type='text'>Recovering Grub</title><content type='html'>&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;I happened to reinstall Win XP on my DebianLinux+WinXP machine and my MBR was overwritten by re-installation.&lt;br /&gt;&lt;br /&gt;I loaded Ubuntu Live CD:&lt;br /&gt;&lt;/span&gt;&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;mounted the root parition&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;chroot to the mount-point&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;grub-install /dev/hda&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;That is it... grub was up and running.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-family:Courier New;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://theextraspace.blogspot.com/feeds/4889012883981399583/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/18437616/4889012883981399583' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/4889012883981399583'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/4889012883981399583'/><link rel='alternate' type='text/html' href='http://theextraspace.blogspot.com/2008/09/recovering-grub.html' title='Recovering Grub'/><author><name>libin_v</name><uri>http://www.blogger.com/profile/06681436264062842278</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-18437616.post-5504405265746438016</id><published>2008-05-22T01:41:00.001-07:00</published><updated>2008-05-22T02:58:20.743-07:00</updated><title type='text'>Licenses: Derived Works</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;After reading the &lt;a href=&#39;http://www.amath.washington.edu/%7Elf/tutorials/autoconf/toolsmanual.html#SEC26&#39;&gt;GPL &amp;amp;amp; Libraries&lt;/a&gt;, for the first understood more about the definition derived works.&lt;br/&gt;&lt;br/&gt;It is not only adding more functionality to a particular open-source code, but also if it is used in combination with another application in the form of libraries ( static and dynamic ).&lt;br/&gt;&lt;br/&gt;Then almost all program linking with libc will have to GPL&#39;ed. To avoid this we have LGPL. All system libraries are LGPL, where derived works are not necessarily LGPL&#39;ed.&lt;br/&gt;&lt;br/&gt;Further Reading:&lt;br/&gt;http://www.onlamp.com/pub/a/onlamp/2004/11/18/licenses.html&lt;br/&gt;http://www.linuxjournal.com/article/6366&lt;br/&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://theextraspace.blogspot.com/feeds/5504405265746438016/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/18437616/5504405265746438016' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/5504405265746438016'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/5504405265746438016'/><link rel='alternate' type='text/html' href='http://theextraspace.blogspot.com/2008/05/licenses-derived-works.html' title='Licenses: Derived Works'/><author><name>libin_v</name><uri>http://www.blogger.com/profile/06681436264062842278</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-18437616.post-179716554201721692</id><published>2008-04-28T01:15:00.000-07:00</published><updated>2008-04-28T01:16:47.013-07:00</updated><title type='text'>Indent</title><content type='html'>&lt;span style=&quot;font-family:Courier;&quot;&gt;&lt;br /&gt;Content&lt;br /&gt;=======&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1 Purpose:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2 Psychological Factors:&lt;br /&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;2.1 Pattern Recognition&lt;br /&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;2.2 Switching between context/controls&lt;br /&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;2.3 Eye movement&lt;br /&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;2.4 Looking ahead&lt;br /&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;2.5 Looking back&lt;br /&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;2.6 Be consistent&lt;br /&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;2.7 There&#39;s no one true style&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3. Techniques&lt;br /&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;3.1 Spacing the Code&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3.1.1 Horizontal Spacing&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3.1.2 Vertical Spacing&lt;br /&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;3.2 Grouping with Brace&lt;br /&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;3.3 Positioning the Code Blocks&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4. Examples:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5. Profile File&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6 References:&lt;br /&gt;&lt;br /&gt;1 Purpose:&lt;br /&gt;==========&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The prime purpose to convey the structure of the program to human readers in better and clear form.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;This is to help in better productivity, quality, maintainability and understandability&lt;br /&gt;&lt;br /&gt;2 Psychological Factors:&lt;br /&gt;========================&lt;br /&gt;&lt;br /&gt;2.1 Pattern Recognition&lt;br /&gt;-----------------------&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;We survive in this world not by recognizing complete situations, nor by analyzing each situation from scratch, but by fitting the world into established recognizable patterns. For example in programming, the following represents traversing a list:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;while ( pTemp != NULL )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&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;// Some Statements&lt;br /&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;pTemp = pTemp-&gt;next;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Once patterns are in place it is very easy to **Filter** or **Search** for a pattern.&lt;br /&gt;&lt;br /&gt;2.2 Switching between context/controls&lt;br /&gt;--------------------------------------&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;When you are talking about something, and get interrupted (and parentheses in a sentence like this is just such an example) then what you were thinking about before the interruption goes onto a &#39;mind stack&#39;. Successive interruptions cause the previous context to be pushed onto the stack, and popped off again only when the interruption is completed.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Similarly in the programming world, the code is split into contexts and controls. Usually the contexts are split using the braces and indentation.&lt;br /&gt;&lt;br /&gt;2.3 Eye movement&lt;br /&gt;----------------&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;When you are reading, your eyes move from left to right and top to bottom&lt;br /&gt;(unless, of course, you are Arabic or Chinese!). However, when you are reading fast, or scanning for a particular item (such as looking for a particular variable in a code procedure), the eyes skip, and prefer to move in a downwards direction only.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Lesser the characters on the line, the more faster we read.&lt;br /&gt;&lt;br /&gt;2.4 Looking ahead&lt;br /&gt;-----------------&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;When we drive we look well ahead, so we can be ready for any hazard. Similarly, as we are reading, we tend to peek ahead to absorb the context ahead of the current reading point. If it is laid out nicely, and everything looks familiar, then we relax and read comfortably at our own rate. If, however, the text ahead looks dense or unfamiliar, we tense up and start to think negatively. We are more likely to misunderstand and make mistakes if things look difficult and we are expecting to err.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Thus, with the use of a consistent programming style, the reader is comforted simply by the &#39;look&#39; of the code and can relax and concentrate on the current fragment.&lt;br /&gt;&lt;br /&gt;2.5 Looking back&lt;br /&gt;----------------&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;When we reading something, particularly for the first time, and especially if we are trying to understand or learn it, we don&#39;t just read it once. We continually skip back and re-read chunks, particularly the difficult bits. There are flags in the written language to allow us to find the start of chunks, even when looking backwards. The capital at the start of a sentence helps. Splitting the text into paragraphs, with the first word indented, help too.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The programming equivalent is to make the start of the statement group, block or function easier to find, by using white space, braces or comment blocks.&lt;br /&gt;&lt;br /&gt;2.6 Be consistent&lt;br /&gt;-----------------&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Changing the way things are done is a certain way to cause confusion in the reader, and could lead to serious error. When a style is chosen, it must be used consistently.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The consistency principle applies to all elements of style, including naming, commenting, layout and usage. It should also be applied to the selection of standards. If, for example, one brace style is selected, then the same style should be used for both code blocks and declarations (including struct&#39;s, union&#39;s and enum&#39;s).&lt;br /&gt;&lt;br /&gt;2.7 There&#39;s no one true style&lt;br /&gt;-----------------------------&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;There is no such thing as a &#39;correct&#39; style. There are almost as many styles as there are programmers. Some are more sensible than others, but there is no one style that can be clearly agreed upon as being the best style to use.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;But in the end, one style must be chosen. You have to say, &quot;This is the style that we will use. We have argued over which one to use, and the consensus is that this is it&quot;. Doubters and dissenters may have to be persuaded or coerced, for although your style is not perfect, it has been chosen to be standard.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;A maintenance note: If you happen to be changing a program that does not use your style, then the professional approach is to use the style that the program uses, rather than to use your normal style. Maintaining poor style is difficult enough - maintaining several styles at once is hell!&lt;br /&gt;&lt;br /&gt;3. Techniques&lt;br /&gt;=============&lt;br /&gt;&lt;br /&gt;3.1 Spacing the Code&lt;br /&gt;--------------------&lt;br /&gt;3.1.1 Horizontal Spacing&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Spacing the code increases readability by identifying the tokens in the statement. However, using more space cost you the horizontal line. A simple rule could be used:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. No space with object reference. Eg: pObj-&gt;member, Obj.member&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. No spaces between unary operators and their operands. Eg: *ptr, ++i, -num&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c. All other binary operators have an equal number of spaces either side.&lt;br /&gt;&lt;br /&gt;Indent Options:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Put a space between sizeof and its argument. --blank-before-sizeof&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Put a space after a cast operator. --space-after-cast&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c. Insert a space between the name of the procedure being called and the&lt;br /&gt;`(&#39;. --space-after-procedure-calls&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d. Put a space after every &#39;(&#39; and before every &#39;)&#39;.&lt;br /&gt;--space-after-parentheses&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e. Put a space after each for. --space-after-for&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;f. Put a space after each if. --space-after-if&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;g. Put a space after each while. --space-after-while&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;h. On one-line for and while statments, force a blank before the semicolon.&lt;br /&gt;--space-special-semicolon&lt;br /&gt;    &lt;br /&gt;3.1.2 Vertical Spacing&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;One means of providing a context is grouping similar statements together and differentiating between groups by a new lines:&lt;br /&gt;&lt;br /&gt;Indent Options:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Split the declarations and code. Force blank lines after the declarations. --blank-lines-after-declarations&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Force blank lines after procedure bodies. --blank-lines-after-procedures&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c. Force blank lines before block comments. Usually block comments are use for a sequence of statements performing a particular task.&lt;br /&gt;--blank-lines-before-block-comments&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d. When compared to&lt;br /&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;int nLenSentence, nI;&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;and&lt;br /&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;int&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nLenSentence,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;nI;&lt;br /&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;In the former, it is easier to search for &quot;nI&quot;. Force newline after comma in declaration. --blank-lines-after-commas  &lt;br /&gt;&lt;br /&gt;3.2 Grouping with Brace&lt;br /&gt;-----------------------&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Besides Vertical Spacing, another means of grouping is using Code Body Block, after branching controls.&lt;br /&gt;&lt;br /&gt;Indent Options:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Put braces on line after if, etc. --braces-after-if-line&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Put braces on the line after struct declaration lines.&lt;br /&gt;--braces-after-struct-decl-line&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c. Group the while in do-while with the close brace. --dont-cuddle-do-while&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d. don&#39;t group the brace with else. --dont-cuddle-else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e. For block comments, it easier to identy comments when the begin with a star. Put the ‘*’ character at the left of comments. --start-left-side-of-comments &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3.3 Positioning the Code Blocks&lt;br /&gt;-------------------------------&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Indentation is one major tools to define structural and control code blocks. Positioning of the braces also helps in maintaining the start and end of the code blocks.&lt;br /&gt;&lt;br /&gt;Indent Options:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Zeroth law, use tabs instead of spaces. None is interested to key in 4 spaces when compared to a tab. --use-tabs&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Usually a tab is considered to be 8 spaces, this will waste a lot of line space, hence specify the tab size to 4. --tab-size4&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c. Each level/hierarchy should be indented by 4 again. Set indentation level to 4 spaces. --indent-level4&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d. Put comments to the right of code in column 41. --comment-indentation41&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e. By default the case body brace is put 2 characters after the case. Indent braces after a case label 0 spaces. --case-brace-indentation0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;f. Put comments to the right of the declarations in column 41.&lt;br /&gt;--declaration-comment-column41 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;g. It is important to know that comment has ended, which can be identified by using the comment delimiter on a new line. Put comment delimiters on blank lines. --comment-delimiters-on-blank-lines&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;h. Set maximum size of a single line to 80 characters. --line-length80&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i. The above sets the line size for a non-comment line. Set maximum size of a single comment line to 80 characters. --comment-line-length80&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;j. Best place to break a long line would be binary operator. Prefer to break long lines before boolean operators. --break-before-boolean-operator&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;k. When a huge line is broken (which does not contain a parenthesis), then align the next line by an offset of 4 spaces. --continuation-indentation4&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;l. When a huge line is broken (which does contain a parenthesis), then align with open parenthesis. --continue-at-parentheses&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m. If you use the `-bl&#39; option, you must specify the `-bli&#39; option. This option specifies the number of spaces by which braces are indented. `-bli2&#39;, the default, gives the result below:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (x &gt; 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x--;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  }&lt;br /&gt;&lt;br /&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;`-bli0&#39; results in the following:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (x &gt; 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x--;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&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;Indent braces 0 spaces, --brace-indent0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;n. Case label indent of 4 spaces. --case-indentation4&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;o. Similarly, the brace for case should also be 0 indented. Indent braces after a case label 0 spaces. --case-brace-indentation0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;p. Similarly, the brace for struct should also be 0 indented. Indent braces of a struct, union or enum 0 spaces. --struct-brace-indentation0&lt;br /&gt;&lt;br /&gt;3.4 Changing some Default Settings of indent&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. By default GNU Style is used for functions --dont-break-procedure-type&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. To format all the comments use --format-all-comments and&lt;br /&gt;--format-first-column-comments&lt;br /&gt;&lt;br /&gt;4. Examples:&lt;br /&gt;============&lt;br /&gt;$ indent --blank-before-sizeof&lt;br /&gt;INPUT:&lt;br /&gt;sizeof(int);&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;sizeof (int);&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --space-after-cast&lt;br /&gt;INPUT:&lt;br /&gt;(int)&#39;a&#39;;&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;(int) &#39;a&#39;;&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --space-after-procedure-calls&lt;br /&gt;INPUT:&lt;br /&gt;foo(10);&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;foo (10);&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --space-after-parentheses&lt;br /&gt;INPUT:&lt;br /&gt;(a+b)*c*((x-y)*(x-y));&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;( a + b ) * c * ( ( x - y ) * ( x - y ) );&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --space-after-for&lt;br /&gt;INPUT:&lt;br /&gt;for(;;);&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;for (;;);&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --space-after-if&lt;br /&gt;INPUT:&lt;br /&gt;if(1);&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;if (1);&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --space-after-while&lt;br /&gt;INPUT:&lt;br /&gt;while(0);        &lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;while (0);&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --space-special-semicolon&lt;br /&gt;INPUT:&lt;br /&gt;for(initial_state;loopig_condition;increment);&lt;br /&gt;while(looping_condition);&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;for (initial_state; loopig_condition; increment) ;&lt;br /&gt;while (looping_condition) ;&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --blank-lines-after-declarations&lt;br /&gt;INPUT:&lt;br /&gt;int a = 10;&lt;br /&gt;int b = 20;&lt;br /&gt;int c;&lt;br /&gt;c = a + b;&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;int a = 10;&lt;br /&gt;int b = 20;&lt;br /&gt;int c;&lt;br /&gt;&lt;br /&gt;c = a + b;&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --blank-lines-after-procedures&lt;br /&gt;INPUT:&lt;br /&gt;void foo ( )&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/* Do Something */&lt;br /&gt;}&lt;br /&gt;void bar ( )&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/* Do yet another thing */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;void&lt;br /&gt;foo ()&lt;br /&gt;{&lt;br /&gt;  /* Do Something */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;bar ()&lt;br /&gt;{&lt;br /&gt;  /* Do yet another thing */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --blank-lines-before-block-comments&lt;br /&gt;INPUT:&lt;br /&gt;end_of_sequence_statements_performing_task_A;&lt;br /&gt;/*&lt;br /&gt; * Task B&lt;br /&gt; *&lt;br /&gt; * Some Alogorithms is mentioned&lt;br /&gt; * Step 1: Blah&lt;br /&gt; * Step 2: Blah Blah&lt;br /&gt; * Step 3: More Blahs&lt;br /&gt; */&lt;br /&gt;step_1;&lt;br /&gt;step_2;&lt;br /&gt;step_3;  &lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;end_of_sequence_statements_performing_task_A;&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt; * Task B&lt;br /&gt; *&lt;br /&gt; * Some Alogorithms is mentioned&lt;br /&gt; * Step 1: Blah&lt;br /&gt; * Step 2: Blah Blah&lt;br /&gt; * Step 3: More Blahs&lt;br /&gt; */&lt;br /&gt;step_1;&lt;br /&gt;step_2;&lt;br /&gt;step_3;&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --blank-lines-after-commas&lt;br /&gt;INPUT:&lt;br /&gt;int nLenSentence = 0, nI;&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;int nLenSentence = 0,&lt;br /&gt;  nI;&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --braces-after-if-line&lt;br /&gt;INPUT:&lt;br /&gt;if ( condition ) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;some_statement;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;if (condition)&lt;br /&gt;  {&lt;br /&gt;    some_statement;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --braces-after-struct-decl-line&lt;br /&gt;INPUT:&lt;br /&gt;struct someStruct {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int int_member;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;char char_member;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;struct someStruct&lt;br /&gt;{&lt;br /&gt;  int int_member;&lt;br /&gt;  char char_member;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --dont-cuddle-do-while&lt;br /&gt;INPUT:&lt;br /&gt;do&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;body_of_loop;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;increment;&lt;br /&gt;} while ( looping_condition );&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;do&lt;br /&gt;  {&lt;br /&gt;    body_of_loop;&lt;br /&gt;    increment;&lt;br /&gt;  }&lt;br /&gt;while (looping_condition);&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --dont-cuddle-else&lt;br /&gt;INPUT:&lt;br /&gt;if ( cond )&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;do_something;&lt;br /&gt;} else&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;do_nothing;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;if (cond)&lt;br /&gt;  {&lt;br /&gt;    do_something;&lt;br /&gt;  }&lt;br /&gt;else&lt;br /&gt;  {&lt;br /&gt;    do_nothing;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent  --comment-indentation41&lt;br /&gt;INPUT:&lt;br /&gt;sum=operaand1+operand2;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/* Adds two operands */&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;sum = operaand1 + operand2;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/* Adds two operands */&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --case-brace-indentation0&lt;br /&gt;INPUT:&lt;br /&gt;switch ( value )&lt;br /&gt;{&lt;br /&gt;        case const1:&lt;br /&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;{ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;do_something;&lt;br /&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;}&lt;br /&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;break;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;switch (value)&lt;br /&gt;  {&lt;br /&gt;  case const1:&lt;br /&gt;  {&lt;br /&gt;    do_something;&lt;br /&gt;  }&lt;br /&gt;    break;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --declaration-comment-column41&lt;br /&gt;INPUT:&lt;br /&gt;int nLenWord = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;/* No of characters in word */&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;int nLenWord = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;/* No of characters in word */&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --line-length80&lt;br /&gt;INPUT:&lt;br /&gt;if ( ( ( date.year % 4 ) == 0 &amp;&amp; ( date.year % 100 ) != 0 ) &amp;&amp; date.month == 2 &amp;&amp; date.day == 29 )&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;do_some_valid_operation;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;if (((date.year % 4) == 0 &amp;&amp; (date.year % 100) != 0) &amp;&amp; date.month == 2&lt;br /&gt;    &amp;&amp; date.day == 29)&lt;br /&gt;  {&lt;br /&gt;    do_some_valid_operation;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --line-length80  --break-before-boolean-operator --continuation-indentation4&lt;br /&gt;INPUT:&lt;br /&gt;bValidDay =  ( ( date.year % 4 ) == 0 &amp;&amp; ( date.year % 100 ) != 0 ) &amp;&amp; date.month == 2 &amp;&amp; date.day == 29 ;&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;bValidDay = ((date.year % 4) == 0 &amp;&amp; (date.year % 100) != 0) &amp;&amp; date.month == 2&lt;br /&gt;    &amp;&amp; date.day == 29;&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --line-length80  --break-before-boolean-operator --continuation-indentation4  --continue-at-parentheses&lt;br /&gt;INPUT:&lt;br /&gt;bValidDay = ( ( ( ( date.year % 4 ) == 0 ) &amp;&amp; ( ( date.year % 100 ) != 0 ) ) &amp;&amp; ( date.month == 2 ) &amp;&amp; ( date.day == 29 ) );&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;bValidDay = ((((date.year % 4) == 0) &amp;&amp; ((date.year % 100) != 0))&lt;br /&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;&amp; (date.month == 2) &amp;&amp; (date.day == 29));&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --braces-after-if-line --brace-indent0&lt;br /&gt;INPUT:&lt;br /&gt;if ( cond ) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;do_something;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;if (cond)&lt;br /&gt;{&lt;br /&gt;  do_something;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;$ indent --braces-after-struct-decl-line --struct-brace-indentation0I&lt;br /&gt;INPUT:&lt;br /&gt;struct someStruct {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int a;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;char b;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;OUTPUT:&lt;br /&gt;struct someStruct&lt;br /&gt;{&lt;br /&gt;  int a;&lt;br /&gt;  char b;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;******************************&lt;br /&gt;&lt;br /&gt;5. Profile File&lt;br /&gt;===============&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If you find that you often use indent with the same options, you may put those options into a file named ‘.indent.pro’. indent will look for a profile file in three places. First it will check the environment variable INDENT_PROFILE. If that exists its value is expected to name the file that is to be used. If the environment variable does not exist, indent looks for ‘.indent.pro’ in the current directory and use that if found. Finally indent will search your home directory for ‘.indent.pro’ and use that file if it is found. This behaviour is different from that of other versions of indent, which load both files if they both exist.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The format of ‘.indent.pro’ is simply a list of options, just as they would appear on the command line, separated by white space (tabs, spaces, and newlines). Options in ‘.indent.pro’ may be surrounded by C or C++ comments, in which case they are ignored.&lt;br /&gt;&lt;br /&gt;********** COPY THE BELOW IN .indent.pro file&lt;br /&gt;--blank-before-sizeof&lt;br /&gt;--space-after-cast&lt;br /&gt;--space-after-procedure-calls&lt;br /&gt;--space-after-parentheses&lt;br /&gt;--space-after-for&lt;br /&gt;--space-after-if&lt;br /&gt;--space-after-while&lt;br /&gt;--space-special-semicolon&lt;br /&gt;&lt;br /&gt;--blank-lines-after-declarations&lt;br /&gt;--blank-lines-after-procedures&lt;br /&gt;--blank-lines-before-block-comments&lt;br /&gt;--blank-lines-after-commas&lt;br /&gt;  &lt;br /&gt;--braces-after-if-line&lt;br /&gt;--braces-after-struct-decl-line&lt;br /&gt;--dont-cuddle-do-while&lt;br /&gt;--dont-cuddle-else&lt;br /&gt;--start-left-side-of-comments &lt;br /&gt;&lt;br /&gt;--use-tabs&lt;br /&gt;--tab-size4&lt;br /&gt;--indent-level4&lt;br /&gt;--comment-indentation41&lt;br /&gt;--case-brace-indentation0&lt;br /&gt;--declaration-comment-column41 &lt;br /&gt;--comment-delimiters-on-blank-lines&lt;br /&gt;--line-length80&lt;br /&gt;--comment-line-length80&lt;br /&gt;--break-before-boolean-operator&lt;br /&gt;--continuation-indentation4&lt;br /&gt;--continue-at-parentheses&lt;br /&gt;--brace-indent0&lt;br /&gt;--case-indentation4&lt;br /&gt;--case-brace-indentation0&lt;br /&gt;--struct-brace-indentation0&lt;br /&gt;&lt;br /&gt;--dont-break-procedure-type&lt;br /&gt;--format-all-comments&lt;br /&gt;--format-first-column-comments&lt;br /&gt;************* COPY TILL THE ABOVE LINE TO .indent.pro&lt;br /&gt;&lt;br /&gt;6 References:&lt;br /&gt;=============&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. C Style: Standards and Guidelines&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;http://syque.com/cstyle/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Indent Style (Wikipedia)&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;http://en.wikipedia.org/wiki/Indent_style&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c. Indent Man Pages&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;http://www.linuxmanpages.com/man1/indent.1.php&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;This document is licensed under the Creative&lt;br /&gt;Commons Attribution 3.0 Unported License (&lt;br /&gt;http://creativecommons.org/licenses/by/3.0/  )&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://theextraspace.blogspot.com/feeds/179716554201721692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/18437616/179716554201721692' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/179716554201721692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/179716554201721692'/><link rel='alternate' type='text/html' href='http://theextraspace.blogspot.com/2008/04/indent.html' title='Indent'/><author><name>libin_v</name><uri>http://www.blogger.com/profile/06681436264062842278</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-18437616.post-4067398199233379021</id><published>2008-04-28T00:37:00.000-07:00</published><updated>2008-04-28T01:07:11.309-07:00</updated><title type='text'>Starting Brew from Scratch from Visual Studio 2005 Express Edition</title><content type='html'>&lt;span style=&quot;font-family:Courier;&quot;&gt;Contents:&lt;br /&gt;=========&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1. Install Brew SDK&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2. Generate MIF&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3. Create a skeleton project&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4. Important Notes&lt;br /&gt;&lt;br /&gt;1. Install Brew SDK&lt;br /&gt;===================&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Download an Install the Brew SDK, preferably 2.1.0. For Documentation reference 3.x SDK could be used.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. To keep all the project file, mfx files machine independent, create an Environment Variable BREWSDK210EN pointing to the BREW SDK Directory. Please use DOS File formats in Environment variable. ( For 3.1.2 SDK use BREWSDK312EN, for a 2.0.1 Japanese SDK use BREWSDK201JP)&lt;br /&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;eg: Assuming the BREW SDK is installed in &quot;F:\Program Files\BREW SDK v2.1.0&quot; to get the DOS format use DIR /X /AD command.&lt;br /&gt;************************************&lt;br /&gt;F:\&amp;gt;dir /x /ad&lt;br /&gt; Volume in drive C has no label.&lt;br /&gt; Volume Serial Number is 8CC3-3122&lt;br /&gt;04/14/2008  04:11 PM    &amp;lt;DIR&amp;gt;          PROGRA~1     Program Files&lt;br /&gt;04/17/2008  10:57 AM    &amp;lt;DIR&amp;gt;                       WINDOWS&lt;br /&gt;************************************&lt;br /&gt;The DOS file format of Program Files is PROGRA~1&lt;br /&gt;&lt;br /&gt;************************************&lt;br /&gt;F:\Program Files&amp;gt;dir /x /ad&lt;br /&gt; Volume in drive C has no label.&lt;br /&gt;04/17/2007  08:22 PM    &amp;lt;DIR&amp;gt;          BREW31~1.2   BREW 3.1.2&lt;br /&gt;04/19/2007  05:57 PM    &amp;lt;DIR&amp;gt;          BREW31~1.3   BREW 3.1.3&lt;br /&gt;04/19/2007  06:28 PM    &amp;lt;DIR&amp;gt;          BREW31~1.4   BREW 3.1.4&lt;br /&gt;10/29/2007  04:43 PM    &amp;lt;DIR&amp;gt;          BREW31~1.5   BREW 3.1.5&lt;br /&gt;07/24/2007  04:13 PM    &amp;lt;DIR&amp;gt;          BREWBR~1.0   BREW Browser v2.0.0&lt;br /&gt;04/17/2007  08:43 PM    &amp;lt;DIR&amp;gt;          BREWSD~1.1   BREW SDK Tools 1.0.1&lt;br /&gt;08/09/2007  03:25 PM    &amp;lt;DIR&amp;gt;          BREWSD~3.1   BREW SDK Tools 1.1.1&lt;br /&gt;10/04/2007  01:04 AM    &amp;lt;DIR&amp;gt;          BREWSD~1.1SP BREW SDK Tools 1.1.1 SP01&lt;br /&gt;01/21/2008  01:22 PM    &amp;lt;DIR&amp;gt;          BREWSD~2.1   BREW SDK v2.0.1&lt;br /&gt;04/27/2007  02:48 PM    &amp;lt;DIR&amp;gt;          BREWSD~1.0   BREW SDK v2.1.0&lt;br /&gt;04/19/2007  05:40 PM    &amp;lt;DIR&amp;gt;          BREWSD~1.3   BREW SDK v2.1.3&lt;br /&gt;07/26/2007  12:33 AM    &amp;lt;DIR&amp;gt;          BREWUI~1     BREW UI Widgets&lt;br /&gt;*******************************&lt;br /&gt;The DOS file format for BREW SDK v2.1.0 is BREWSD~1.0 (**Note: This is system dependent**)&lt;br /&gt;&lt;br /&gt;So the path to the BREW SDK is F:\PROGRA~1\BREWSD~1.0\&lt;br /&gt;&lt;br /&gt;To add Environment Variable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1. Right-Click &quot;My Computer&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2. Properties-&amp;gt;Advanced-&amp;gt;Environment Variable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3. Click &quot;New&quot; under the &quot;System Variable&quot; Section&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4. Add Variable Name as BREWSDK210EN&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5. Add Variable Value as F:\PROGRA~1\BREWSD~1.0\&lt;br /&gt;&lt;br /&gt;2. Generate MIF&lt;br /&gt;===============&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Open MIF Editor, listed under BREW SDK Tools&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. In the BREW MIF Editor window, click the Applets tab.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c. Create a new applet, by clicking the New Button in the List of Applets defined in this Module. The &quot;Specify BREW Class ID&quot; Windows pops.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d. Select the Locally Radio Button.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e. Add a unique Class ID (say &quot;0x12345678&quot;, ( you should create new class id&#39;s every time you create a new project ).&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;f. Also put the put the Class Name (say &quot;FIRSTHELLOWORLD&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;g. Click Ok, you will be prompted to generate file. Save the BID file in the Project Directory. ( FIRSTHELLOWORLD.bid )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;h. For 2.1.0, add the Images from the &quot;images&quot; Directory&lt;br /&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;* Large&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;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BrewImage-1.bmp&lt;br /&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;* Medium&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;BrewIcon-1.bmp&lt;br /&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;* Small&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;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Games16x16-1.bmp&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i. Now Save the file in the project directory. ( firsthelloworld.mfx )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;j. To make the MFX machine independent use relative path.&lt;br /&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;* I have created a copy of firsthelloworld.mfx created in Step 2.i as&lt;br /&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;firsthelloworld.mfx.start&lt;br /&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;* Now edit the firsthelloworld.mfx in Notepad (any Text&lt;br /&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;Editor), find the below&lt;br /&gt;**************&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Object Id=&quot;21&quot; Name=&quot;IDI_OBJECT_21&quot;&amp;gt;&lt;br /&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;lt;File&amp;gt;F:\temp\firsthelloworld\images\BrewIcon-1.bmp&amp;lt;/File&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/Object&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Object Id=&quot;22&quot; Name=&quot;IDI_OBJECT_22&quot;&amp;gt;&lt;br /&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;lt;File&amp;gt;F:\temp\CVS_Work\firsthelloworld\images\BrewImage-1.bmp&amp;lt;/File&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/Object&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Object Id=&quot;23&quot; Name=&quot;IDI_OBJECT_23&quot;&amp;gt;&lt;br /&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;lt;File&amp;gt;F:\temp\CVS_Work\firsthelloworld\images\Games16x16-1.bmp&amp;lt;/File&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/Object&amp;gt;&lt;br /&gt;*************&lt;br /&gt;When MFX is compiled in another system, the project directory could be anything but E:\Work\CVS_Work\firsthelloworld, so use relative path &quot;.&quot;. Dot (.) stands for Current Directory.&lt;br /&gt;**************&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Object Id=&quot;21&quot; Name=&quot;IDI_OBJECT_21&quot;&amp;gt;&lt;br /&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;lt;File&amp;gt;.\images\BrewIcon-1.bmp&amp;lt;/File&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/Object&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Object Id=&quot;22&quot; Name=&quot;IDI_OBJECT_22&quot;&amp;gt;&lt;br /&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;lt;File&amp;gt;.\images\BrewImage-1.bmp&amp;lt;/File&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/Object&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Object Id=&quot;23&quot; Name=&quot;IDI_OBJECT_23&quot;&amp;gt;&lt;br /&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;lt;File&amp;gt;.\images\Games16x16-1.bmp&amp;lt;/File&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/Object&amp;gt;&lt;br /&gt;*************&lt;br /&gt;&lt;br /&gt;Now open this edited MFX file and Compile. ( Output firsthelloworld.mif ).&lt;br /&gt;&lt;br /&gt;One inconveneice with MIF Editor is any time you edit the MFX file, it will replace the Relative Path with Actual Path, so everytime you &quot;save&quot; the file, edit with with a notepad after saving.&lt;br /&gt;&lt;br /&gt;3. Creating a Skeleton Project&lt;br /&gt;==============================&lt;br /&gt;3.1 New Project&lt;br /&gt;---------------&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Open Visual Studio 2005 Express Edition&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Create a New Project&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c. Choose Project Type as Win32&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d. Choose Template as Windows Console Application&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e. Name: firsthelloworld&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;f. Location: As your preference&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;g. Unselect &quot;Create directory for solution&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;h. OK -&amp;gt; Next&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i. Select &quot;Empty Project&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;j. Unselect &quot;Precompiled header&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;k. Finished&lt;br /&gt;&lt;br /&gt;Now the Solution Explorer Pane Contains:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;firsthelloworld&lt;br /&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;* Header Files&lt;br /&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;* Resource Files&lt;br /&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;* Source Files&lt;br /&gt;&lt;br /&gt;3.2 Adding Files&lt;br /&gt;----------------&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Right-Click on firsthelloworld project, Add -&amp;gt; Existing Items&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Add AeeAppGen.c and AeeModGen.c in the src folder of BREWSDK directory.&lt;br /&gt;&lt;br /&gt;3.3 Setting Up a Brew Application&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Right-Click on firsthelloworld project, Properties&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Make sure the Configuration Name is Active(Debug)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c. On the Left Pane, Configuration Properties -&amp;gt; General&lt;br /&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;* Set Configuration Type = Dynamic Library (.dll)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d. Configuration Properties -&amp;gt; Linker -&amp;gt; General&lt;br /&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;* Set OutputFile = $(OutDir)\$(ProjectName).dll&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e. Configuration Properties -&amp;gt; C/C++ -&amp;gt; Preprocessor&lt;br /&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;* Preprocessor = WIN32;_DEBUG;_WINDOWS;_USRDLL;AEE_SIMULATOR&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;f. Configuration Properties -&amp;gt; C/C++ -&amp;gt; General&lt;br /&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;Additional Include Directories -&amp;gt;&quot;E:\Program Files\BREW SDK v2.1.0\inc&quot;&lt;br /&gt;(Note: Please quotes around the directory name, the the directory name contains space ).&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;g. Now Apply, and Build the project.&lt;br /&gt;&lt;br /&gt;You should get the following Errors:&lt;br /&gt;**********************************&lt;br /&gt;------ Build started: Project: firsthelloworld, Configuration: Debug Win32 ------&lt;br /&gt;Compiling...&lt;br /&gt;AEEModGen.c&lt;br /&gt;AEEAppGen.c&lt;br /&gt;Generating Code...&lt;br /&gt;Compiling manifest to resources...&lt;br /&gt;Linking...&lt;br /&gt;   Creating library f:\temp\firsthelloworld\Debug\firsthelloworld.lib and object f:\temp\firsthelloworld\Debug\firsthelloworld.exp&lt;br /&gt;AEEModGen.obj : error LNK2019: unresolved external symbol _AEEClsCreateInstance referenced in function _AEEMod_CreateInstance&lt;br /&gt;f:\temp\firsthelloworld\Debug\firsthelloworld.dll : fatal error LNK1120: 1 unresolved externals&lt;br /&gt;Build log was saved at &quot;file://f:\temp\firsthelloworld\Debug\BuildLog.htm&quot;&lt;br /&gt;firsthelloworld - 2 error(s), 0 warning(s)&lt;br /&gt;========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========&lt;br /&gt;*********************************&lt;br /&gt;&lt;br /&gt;3.4 Building the DLL&lt;br /&gt;--------------------&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Now copy helloworld.c from the BREWSDK Examples to the project directory&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Add the File to the Project.&lt;br /&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;* Right Click on firsthelloworld&lt;br /&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;* Add -&amp;gt; Existing Items -&amp;gt; Select the helloworld.c&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c. Change #include &quot;helloworld.bid&quot; to #include &quot;firsthelloworld.bid&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d. Compile the project. (This should build successfully)&lt;br /&gt;There should be a dll file in Debug Directory&lt;br /&gt;&lt;br /&gt;With this you won&#39;t be able to run the dll.&lt;br /&gt;&lt;br /&gt;3.5 Running the Application&lt;br /&gt;---------------------------&lt;br /&gt;Let us start from scratch. Delete the BREW_Emu.dat in the bin directory of the BREW SDK. This file contains the basic settings.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Create a Directory known a BrewAppRepository or something similar&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Create an Environment variable named BREWAPP pointing to the BrewAppRepository. (Refer above document on how to create Envirnment Variables).&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c. Make a directory inside BrewAppRepository as firsthelloworld.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d. Copy the firsthelloworld.dll from the Debug Directory into the newly created folder.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e. Copy the firsthelloworld.mif into BrewAppRepository&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;f. Now Start-&amp;gt;Program Files-&amp;gt;BREW SDK xxx-&amp;gt;Brew Simulator/Emulator&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;g. A Settings Dialog is displayed&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;h. Choose the Device as the Initial Device from the Devices Directory of the BREW SDK&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i. Choose BrewAppRepository as the Applet Directory.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;j. Click OK&lt;br /&gt;You should see the able to see the FIRSTHELLOWORLD Application icon. On clicking it, &quot;Hello World&quot; will be displayed.&lt;br /&gt;&lt;br /&gt;Now, this requires you manual copy the dll every time you build the dll. And you need to run the emulator from Start-&amp;gt;Program files. There many ways to avoid this problem.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1. Post Build Script&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2. Setting Output Directory&lt;br /&gt;With the above solution, you need to set as to how you want to run the dll.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Go to Project properties ( Right Click on firsthelloworld -&amp;gt; Properties )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Configuration Properties -&amp;gt; Debugging&lt;br /&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;Command = &amp;lt;Select the BREW_Emulator.exe in the bin directory on the Brew SDK&amp;gt; ( In 3.x and greater it is known as BREW_Simulator.exe )&lt;br /&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;This is a User Based Setting, that means on every time you copy the project into a different User Space or System, you need to do this setting.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;* Now Press F5 or Debug -&amp;gt; Start Debugging&lt;br /&gt;&lt;br /&gt;3.5.1 Post Build Script&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Simple Shell Scripts which will copy the dll to the Brew Applet directory.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Go to Project properties ( Right Click on firsthelloworld -&amp;gt; Properties )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Configuration Properties -&amp;gt; Build Events -&amp;gt; Post-Build Events&lt;br /&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;Command Line = copy Debug\firsthelloworld.dll $(BREWAPP)\firsthelloworld\&lt;br /&gt;(Note: I am using Environment Variable)&lt;br /&gt;********************** After every build&lt;br /&gt;Performing Post-Build Event...&lt;br /&gt;        1 file(s) copied.&lt;br /&gt;**********************&lt;br /&gt;&lt;br /&gt;3.5.2 Setting Output Directory&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Go to Project properties&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Configuration Properties -&amp;gt; Linker&lt;br /&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;Output Directory = $(BREWAPP)\$(ProjectName)\$(ProjectName).dll&lt;br /&gt;&lt;br /&gt;3.6 Adding Debug Information&lt;br /&gt;----------------------------&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;I have made a copy of the Project File before I started adding Debug Information. ( firsthelloworld.vcproj.withoutDebug )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Go to Project Properties&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Configuration Properties -&amp;gt; C/C++ -&amp;gt; General&lt;br /&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;* Debug Information Format = Program Database for Edit &amp; Continue&lt;br /&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;* Warning Level = Level 4&lt;br /&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;* Detect 64-bit Portability Issues = No&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c. Configuration Properties -&amp;gt; C/C++ -&amp;gt; Browse Information&lt;br /&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;* Enable Browse Information = Include All Browse Information&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d. Configuration Properties -&amp;gt; Linker -&amp;gt; Debugging&lt;br /&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;* Generate Debug Info = YES&lt;br /&gt;&lt;br /&gt;3.7 Making it System Independent&lt;br /&gt;--------------------------------&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;I have made a copy of the Project File before I make it system Independent &lt;br /&gt;( firsthelloworld.vcproj.systemDependent )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Close VS 2005 Express&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Edit the firsthelloworld.vcproj wit a Text Edit ( Notepad, Vi )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c. Replace all instance of the BREW SDK Directory (say E:\Program Files\BREW SDK v2.1.0) with $(BREWSDK210EN).&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d. Save and exit&lt;br /&gt;&lt;br /&gt;4. Important Notes&lt;br /&gt;==================&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a. Always restart the VS 2005 Express after adding a new Environment.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b. Always close all instance of VS 2005 Express, when you edit the vcproj file using Text Editor&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;This document is licensed under the Creative Commons Attribution 3.0 Unported License (  http://creativecommons.org/licenses/by/3.0/  )&lt;span style=&quot;font-style:italic;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://theextraspace.blogspot.com/feeds/4067398199233379021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/18437616/4067398199233379021' title='53 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/4067398199233379021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/4067398199233379021'/><link rel='alternate' type='text/html' href='http://theextraspace.blogspot.com/2008/04/starting-brew-from-scratch-from-visual.html' title='Starting Brew from Scratch from Visual Studio 2005 Express Edition'/><author><name>libin_v</name><uri>http://www.blogger.com/profile/06681436264062842278</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>53</thr:total></entry><entry><id>tag:blogger.com,1999:blog-18437616.post-5705669244992052439</id><published>2007-06-01T12:48:00.001-07:00</published><updated>2007-06-01T12:48:25.683-07:00</updated><title type='text'>Saving Electricity - Inspired by Blackle</title><content type='html'>For those who are inspired by Blackle and want to invert ( change ) the color of the entire system to black - what are you waiting for!!!&lt;br&gt; &lt;br&gt; 1. Goto Control Panel.&lt;br&gt; 2. Select Display -&amp;gt; Click the Apperance Tab.&lt;br&gt; 3. Choose High Contrast #1 or #2 ( Greeniee Foreground ) in the Color Scheme.&lt;br&gt; 4. Apply and wait for the changes to happen.&lt;br&gt; &lt;br&gt; Once this is done, you can access Google instead of Blackle.&lt;br&gt; &lt;br&gt; Sometimes the browser may not use the system default color scheme, for that to happen:&lt;br&gt; 1. Open Browser ( Firefox )&lt;br&gt; 2. Tools menu -&amp;gt; Options&lt;br&gt; 3. Content Tab -&amp;gt; Colors&lt;br&gt; 4. Mark the Use System Color Option&lt;br&gt; 5. Click Ok.&lt;br&gt; &lt;br&gt; &lt;div align=&quot;center&quot;&gt;&lt;b&gt;Trickles of Water in the high mountains, together form a mighty river - which joins the great Ocean.&lt;/b&gt;&lt;br&gt; &lt;/div&gt; </content><link rel='replies' type='application/atom+xml' href='http://theextraspace.blogspot.com/feeds/5705669244992052439/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/18437616/5705669244992052439' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/5705669244992052439'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/5705669244992052439'/><link rel='alternate' type='text/html' href='http://theextraspace.blogspot.com/2007/06/saving-electricity-inspired-by-blackle.html' title='Saving Electricity - Inspired by Blackle'/><author><name>libin_v</name><uri>http://www.blogger.com/profile/06681436264062842278</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-18437616.post-5957782481647590601</id><published>2007-05-19T12:43:00.001-07:00</published><updated>2007-05-19T12:43:23.411-07:00</updated><title type='text'>Arrage Icons by CVS Status</title><content type='html'>I want Tortoise CVS to arrange icons based on CVS Status. I was not able &lt;br&gt;to do so. I check up the feature list need find them there. I also check &lt;br&gt;the features wanted listed, no luck even there. I thought I should add &lt;br&gt;code to tortoise for this feature. When I was studying some pages for &lt;br&gt;adding a column on the file explorer. It was here that I found that the &lt;br&gt;feature already exists.&lt;p&gt;All you got to do is&lt;br&gt;1.Click View-&amp;gt;Details&lt;br&gt;2.Right Click on the column header, choose more.&lt;br&gt;3.Select amoung the CVS Status, CVS Revision, CVS Sticky Tags or CVS &lt;br&gt;File type&lt;br&gt;4.Click View-&amp;gt;Arrange Icons by-&amp;gt;CVS Status&lt;br&gt;5............There you go, it is ordered by CVS Status ( Modified, &lt;br&gt;Unmodifed, Unknown, Added, Conflict, Removed )</content><link rel='replies' type='application/atom+xml' href='http://theextraspace.blogspot.com/feeds/5957782481647590601/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/18437616/5957782481647590601' title='39 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/5957782481647590601'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/5957782481647590601'/><link rel='alternate' type='text/html' href='http://theextraspace.blogspot.com/2007/05/arrage-icons-by-cvs-status.html' title='Arrage Icons by CVS Status'/><author><name>libin_v</name><uri>http://www.blogger.com/profile/06681436264062842278</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>39</thr:total></entry><entry><id>tag:blogger.com,1999:blog-18437616.post-114184032050272347</id><published>2006-03-08T09:52:00.000-08:00</published><updated>2006-03-08T09:52:00.550-08:00</updated><title type='text'>void __builtin_return_address (unsigned int level);</title><content type='html'>&lt;font color=&quot;#cc0000&quot;&gt;void __builtin_return_address (unsigned int &lt;em&gt;level&lt;/em&gt;);&lt;/font&gt;&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; Returns the return address of the current function, or of one of its callers. Where &lt;em&gt;level&lt;/em&gt; argument is a constant literal indicating the number of frames to scan up the call stack. The &lt;em&gt;level&lt;/em&gt; must range from 0 to 63. A value of 0 yields the return address of the current function, a value of 1 yields the return address of the caller of the current function and so on. &lt;div class=&quot;notelisttitle&quot; id=&quot;wq1283&quot;&gt;Notes:&lt;/div&gt; &lt;ol type=&quot;1&quot;&gt;   &lt;li&gt;When the top of the stack is reached, the function will return 0.&lt;/li&gt;   &lt;li&gt;The &lt;em&gt;level&lt;/em&gt; must range from 0 to 63, otherwise a warning message will be issued and the compilation will halt.&lt;/li&gt;   &lt;li&gt;When functions are inlined, the return address corresponds to that of the function that is returned to. &lt;/li&gt;   &lt;li&gt;Compiler optimization may affect expected return value due to introducing extra stack frames or fewer stack frames than expected due to optimizations such as inlining.&lt;/li&gt; &lt;/ol&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; __builtin_return_address(0) yields the address to which the current function will return. __builtin_return_address(1) yields the address to which the caller will return, and so on up the stack.&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; Return probes operates by replacing the return address in the stack (or in a known register, such as the lr register for ppc - what else can you do with a system with 100&#39;s of registers :) ). This may cause __builtin_return_address(0), when invoked from return-probed function, to return the address of the return-probes trampoline. There has been concern that this will break something.&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; __builtin_return_address is used entirely for tracing, profiling, and error reporting.&lt;br&gt;</content><link rel='replies' type='application/atom+xml' href='http://theextraspace.blogspot.com/feeds/114184032050272347/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/18437616/114184032050272347' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/114184032050272347'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/114184032050272347'/><link rel='alternate' type='text/html' href='http://theextraspace.blogspot.com/2006/03/void-builtinreturnaddress-unsigned-int.html' title='void __builtin_return_address (unsigned int level);'/><author><name>libin_v</name><uri>http://www.blogger.com/profile/06681436264062842278</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-18437616.post-114176395151264716</id><published>2006-03-07T12:39:00.000-08:00</published><updated>2006-03-07T12:52:24.550-08:00</updated><title type='text'>Keeping Deleted Code for Future Reference (with comments)</title><content type='html'>&lt;p class=&quot;mobile-post&quot;&gt;        Many a times we have come across a situation where we want to&lt;br /&gt;keep a piece of code that does not execute. If often do it with &quot;/*&quot; and&lt;br /&gt;&quot;*/&quot;. But these won&#39;t work if there are similar comments within the&lt;br /&gt;piece of code we want to comment. It achieve this use &quot;#if 0&quot; and&lt;br /&gt;&quot;&lt;br /&gt;&lt;br /&gt;eg:&lt;br /&gt;&lt;br /&gt;#if 0&lt;br /&gt;&lt;ul&gt;/* Used for debugging */&lt;br /&gt;while (a &lt; n)&lt;/ul&gt;&lt;br /&gt;&lt;ul&gt;&lt;ul&gt;printf (&quot;%d&quot;, a);&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;#endif&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://theextraspace.blogspot.com/feeds/114176395151264716/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/18437616/114176395151264716' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/114176395151264716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/114176395151264716'/><link rel='alternate' type='text/html' href='http://theextraspace.blogspot.com/2006/03/keeping-deleted-code-for-f_114176395151264716.html' title='Keeping Deleted Code for Future Reference (with comments)'/><author><name>libin_v</name><uri>http://www.blogger.com/profile/06681436264062842278</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-18437616.post-114163952954085036</id><published>2006-03-06T01:46:00.000-08:00</published><updated>2006-03-06T02:06:11.606-08:00</updated><title type='text'>Eraser - In Brief</title><content type='html'>&lt;b&gt;Multi-threaded programming &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* error-prone  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* easy to make synch mistakes := data race  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* hard to locate synch mistakes in debug&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;In few Word: Eraser is ? &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* dynamically detects data races in lock-based multi-threaded programs  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* uses binary rewriting techniques  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* monitor every shared memory reference &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* verify &quot;consistent&quot; locking behavior/discipline  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Introduction &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* multi-threaded programs are the common programming techniques  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Dynamic race detection based on &quot;happens-before&quot; relation  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* checks conflicting mem accesses from different threads  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Based on locking discipline: programming policy, ensures absence of data races E.g. require every variable shared b/n threads to be protected by a mutual exclusion lock  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Definitions &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Lock : synch object; used for mutex; either available or owned by a thread  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= ops on lock L: lock(L); unlock(L)  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= is essentially a binary semaphore ,but ONLY lock&#39;s owner can release that lock  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Data Race : when two (or more) concurrent threads access a shared var  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= at least one access is a write AND  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= the threads use no explicit mech to prevent the accesses from being simultaneous  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= If a prog has a potential data race, then the impact of conflicting accesses to the shared var *will depend on the interleaving* (of the thread executions)  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Related Work ? Monitors &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* group of shared vars + procedures that are allowed to access those vars  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* single &quot;anonymous&quot; lock (by which we mean implicit)  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* whenever one of those procedures is entered, that lock is acquired &amp; whenever one of those procedures is exited, the lock is released  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* the shared vars in the monitor are invisible outside of the monitor  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* provide a static, compile-time guarantee that shared vars are   &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* serialized and thus free from data races  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Don&#39;t protect against data races in progs with dynamically allocated shared vars  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Happens-Before Relation &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* The HB order is a partial order on all events of all threads in a concurrent execution.  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* W/in any single thread: events ordered in order in which they occur.  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* B/n threads, events ordered according to the properties of the synch objects they access;  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= if thread T1 accesses synch object L1 and the next access to L1 is by T2 then the T1&#39;s access of L1 &quot;happens before&quot; T2&#39;s  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= if two (or more) threads access a shared var and the accesses are NOT ordered by the happens-before relation, then in another exec of the prog, the two accesses could have happened simultaneously == a data race could have occurred  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.98in; margin-bottom: 0in;&quot;&gt;# If there were no happens-before relation b/n T1&#39;s unlock(L) and T2&#39;s lock(L) then T1 could have read v = 3; T2 could have read v = 3; then T1 would write v = 4; so would T2 (which is not what SHOULD have happened had those two variable assignments been serialized)  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt;  &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Drawbacks to tools based on HB &lt;/b&gt; &lt;/p&gt;&lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;* inefficient; require per-thread info a/b concurrent accesses to all shared mem locs  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;* effectiveness of tools based on HB is highly dependent upon the interleaving produced by the scheduler  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Interleaving produced by the Scheduler &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Thread 1  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;y++ //y1  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;A  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Thread 2  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;B  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;y++ //y2  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* So possible orderings (y_1 comes before A; y_2 comes after B):  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= y_1, A, B, y_2  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= y_1, B, A, y_2  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= y_1, B, y_2, A  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= B, y_1, A, y_2  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= B, y_1, y_2, A &lt;=== potential data race  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= B, y_2, y_1, A &lt;=== potential data race  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;The Lockset algo &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* enforces simple locking discipline:  &quot;every shared var must be protected by some lock?  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= the lock is held by the thread accessing the var *when* that thread accesses the shared var  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Eraser monitors all reads and writes as the program executes; infers protection relation (b/n particular locks &amp; specific vars) from execution history (since it does not know which lock protects which shared var)  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* V =&gt; shared var  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* C(V) =&gt; candidate locks for V  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* as would expect, when new var V is initialized, its candidate set, C(V), includes all possible locks  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* when V is accessed, it updates C(V) with the intersection of C(V) and the set of locks held by the current thread =&gt; &quot;lockset refinement?  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* if C(V) becomes empty, then this indicates that there is no lock that consistently protects V. (error) &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;The Lockset algo V.1 &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Let locks held(t) be the set of locks held by thread t.  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* For each v, initialize C(v) to the set of all locks.  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* On each access to v by thread t,  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= set C(v) := C(v) ? locks held(t);  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= if C(v) := { }, then issue a warning.  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Improving the Locking Discipline &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Three cases violate the discipline but don&#39;t have data races  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= Initialization: shared vars are frequently initialized w/o holding a lock   &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= Read-shared data: some shared vars are written during init only and are read-only thereafter; is OK to have multiple readers simultaneously reading  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= Read-write locks: read-write locks allow multiple readers to  access a shared var but only ONE writer to do so  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Accommodating Initialization &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* by delaying refinement of a variable&#39;s candidate after that var has been initialized  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* how to know when initialization is complete?  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= Eraser says a shared var has been initialized at the instant that var is first accessed by a second thread (Virgin)  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= As long as a var has been touched by a single thread only, all reads &amp; writes of that var are considered part of initialization (Exclusive). C(V) is not refined here  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Accommodating Multiple-Readers &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* A read access from another state changes the state of the variable to shared  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* C(V) is refined, but errors are not reported even if C(V) is null  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Accommodating Read-Write  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* A write by another thread on a shared var, takes the var from Exclusive or shared state to shared-modified  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* C(V) is refined and error is reported if C(V) is null  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Require that for every variable V, some lock M protects V   &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= M is held in write-mode for every write of V  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= M is held in *some* mode (read or write) for every read of V  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;The Lockset algo V.2 &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* keep track of all locks held by thread T; locks_held(T)  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* keep track of locks held in write mode by T; write_locks_held(T)  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Upon entering the Shared-Modified, C(V) = set of all locks  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= If we are READING V, C(V) = C(V) intersection locks_held(T)  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= If we are writing V, C(V) = C(V) intersection write_locks_held(T)  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= if C(V) == {}, report error  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Implementation &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Eraser takes an unmodified program binary as input and adds instrumentation to produce a new binary that is functionally equivalent but that includes calls to the Eraser runtime to implement the Lockset algo  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* To maintain C(V), Eraser instruments each load &amp; store in the program  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* To maintain locks_held(T) for each thread T, Eraser instruments each call to acquire or release a lock as well as the stubs used to manage thread initi &amp; finalization.  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* To initialize C(V) for dynamically allocated data, Eraser instruments each call to the storage allocator &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Eraser treats each 32-bit word in the heap or global data as a possible shared var  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Eraser does NOT instrument loads &amp; stores whose address mode is indirect off the stack pointer -- since these are presumed to be stack refs which are presumed to be local to the thread data, not global data (which will be in a global location or in the heap).  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Eraser maintains candidate sets for stack locations that are accessed via registers *besides* the stack pointer  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Representing Candidate Lock Sets &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* naive implem: store a list of candidate locks for each mem loc  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* exploit:  distinct sets of locks observed in practice is small  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= represent each set of locks by an int (lockset index)  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= lockset index indexes into a table whose entries represent the set of locks as sorted vectors of lock addresses  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= each entry represents some set of locks stored as a vector where that vector is sorted by the addresses of the locks comprising the set  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= use hashing to eliminate dupes in the table &amp; to find the key for a given set of locks  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= the entries in the table are never deallocated nor modified; lockset index valid for program&#39;s lifetime  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= Eraser caches result of several set intersections so fast case for set intersection is just a table lookup  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= each lock set is -- again -- stored as a sorted vector so the worst case, intersection can be performed by comparing two sorted vectors  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* For every 32-bit word in the data segment or in the heap, there is a shadow word that contains   &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= the 30-bit lockset index for that word  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= a 2-bit state condition (Virgin, Exclusive, Shared, Shared-Modified).  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= In the Exclusive state the 30 bits are used to store the ID of the thread with exclusive access.  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* All the std. mem alloc routines are instrumented to allocate and initialize a shadow word for each word allocated by the prog.  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* When a thread accesses a mem loc, Eraser finds the shadow word for that mem loc by adding some fixed displacement to the memory  location&#39;s  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Annotations &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* How to suppress false positives without eliminating true positives?  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* If false alarms suppressed with accurate &amp; specific &quot;annotations,? then when a prog is modified and modified prog is tested, only &quot;fresh and relevant&quot; warnings will be produced  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Kinds of False Alarms &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* mem reuse: mem is reused w/o resetting shadow var  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= many progs implement free lists or private allocators so now way for Eraser to know that some piece of memory has been &quot;privately recycled&quot; (and thus is protected by a *new* set of locks) must be accommodated  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= EraserReuse(address,size)  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= instructs eraser to reset the shadow mem corresponding to the mem range to the Virgin state  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Private locks:  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= locks taken w/o communicating this seizure to Eraser  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= caused by private implems of multiple-reader, single-writer locks (not part of pthreads i/f that Eraser implements)  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= EraserReadLock(lock)  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= EraserReadUnlock(lock)  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= EraserWriteLock(lock)  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= EraserWriteUnlock(lock)  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= communicate private lock implementations  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Benign races:  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= true data races; didn&#39;t affect program&#39;s correctness  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= some intentional, others no  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= EraserIgnoreOn() &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= EraserIgnoreOff()  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= surround code which the race detector should not worry about w.r.t. finding races  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;br /&gt;&lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Additional Thoughts/Works &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Protection by multiple locks  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Deadlock  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Protection by multiple locks &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Some programs protect a shared variable by multiple locks instead of single  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Working :  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= any writer must hold all locks for a shared var  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= any reader must hold at least one lock for a shared var  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= aimed at avoiding dead lock  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* modified Lockset in following manner: &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= On each read of V by T,  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= if C(V) == {}, issue warning  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= On each write of V by T,  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= set C(V) == C(V) intersect locks_held(T)  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= if C(V) == {}, issue warning  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* prevented false alarms, could also cause false negatives  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= if T1 reads V while holding M1 and T2 writes V while holding M2  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= violation of locking discipline will only be reported if the write preceeds the read  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* requires complex DSs: sets of sets of locks  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom: 0in;&quot;&gt;&lt;b&gt;Deadlocks &lt;/b&gt; &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* Discipline to avoid deadlock:  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= choose partial ordering among all locks  &lt;/p&gt; &lt;p style=&quot;margin-left: 0.49in; margin-bottom: 0in;&quot;&gt;= and program each thread so that whenver it holds more than one lock, it acquires them in increasing order (prevents Circularity requirement of deadlock).  &lt;/p&gt; &lt;p style=&quot;margin-bottom: 0in;&quot;&gt;* deadlock checking could be useful addition to Eraser  &lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://theextraspace.blogspot.com/feeds/114163952954085036/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/18437616/114163952954085036' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/114163952954085036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/18437616/posts/default/114163952954085036'/><link rel='alternate' type='text/html' href='http://theextraspace.blogspot.com/2006/03/eraser-in-brief.html' title='Eraser - In Brief'/><author><name>libin_v</name><uri>http://www.blogger.com/profile/06681436264062842278</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>