<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;A0UDR3s_eSp7ImA9WhRbGUk.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479</id><updated>2012-02-11T14:04:36.541+05:30</updated><category term="C#" /><category term="HPUX" /><category term="Tomcat" /><category term="Visual Studio" /><category term="Data Structures" /><category term="General" /><category term="Cygwin" /><category term="STL" /><category term="Javascript" /><category term="C C++" /><category term="Linux" /><category term="SQL Server" /><category term="Shell Scripting" /><category term="Windows" /><category term="Multithreading" /><category term="Java" /><category term="Inspiration" /><category term="Algorithms" /><category term="AIX" /><title>My Notes - C, C++, Java...</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://dev-faqs.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>74</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/PerryPetersonsBlog" /><feedburner:info uri="perrypetersonsblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;D0MGQncyfCp7ImA9WhRbGEw.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-6345430473895743971</id><published>2012-02-10T00:26:00.007+05:30</published><updated>2012-02-10T00:53:43.994+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-10T00:53:43.994+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Cygwin" /><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><title>Reverse a stack in place</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/6345430473895743971/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=6345430473895743971" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/6345430473895743971?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/6345430473895743971?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/yoJqGvzuhtc/reverse-given-stack-in-place.html" title="Reverse a stack in place" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/W4rz6JD9f2BlREAbQ26SWgUUi6Q/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/W4rz6JD9f2BlREAbQ26SWgUUi6Q/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/W4rz6JD9f2BlREAbQ26SWgUUi6Q/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/W4rz6JD9f2BlREAbQ26SWgUUi6Q/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Write a C/C++ Program to reverse a stack in place? 

You can only use the following ADT functions on the stack:
1. empty()
2. push()
3. pop()
4. top()
Solution:
1. Whenever in place conversion is required, use recursion which will make use of function stack to store the variables
2. Pop out all the elements from the given stack recursively and store them in a variable.
3. As the stack unwinding &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/yoJqGvzuhtc" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2012/02/reverse-given-stack-in-place.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk4AQH0-eyp7ImA9WhRQEko.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-4710570555726269015</id><published>2011-12-06T21:45:00.004+05:30</published><updated>2011-12-07T21:52:21.353+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-07T21:52:21.353+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="Data Structures" /><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms" /><title>Traversing a Binary Tree</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/4710570555726269015/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=4710570555726269015" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/4710570555726269015?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/4710570555726269015?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/LPvB3enUDAs/traversing-in-binary-tree.html" title="Traversing a Binary Tree" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/sJfFNlHg0HQxT5IjhxdbZN7Y5A0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sJfFNlHg0HQxT5IjhxdbZN7Y5A0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/sJfFNlHg0HQxT5IjhxdbZN7Y5A0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sJfFNlHg0HQxT5IjhxdbZN7Y5A0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;There are basically two ways of traversing a binary tree
1. Depth First Traversals
2. Breadth First Traversal

Depth First Traversal
A binary tree can be traversed in three ways using the depth first approach namely

1. Inorder Traversal
template &amp;lt;typename T&amp;gt;
  void BTTraveller&amp;lt;T&amp;gt;::inOrder(BSTNode&amp;lt;T&amp;gt; *node, std::deque&amp;lt;T&amp;gt; &amp;amp;out)
  {
    if(node)
    {
      inOrder(node-&amp;gt;left, out);
      &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/LPvB3enUDAs" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/12/traversing-in-binary-tree.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C04DR3Y6eyp7ImA9WhRQEUQ.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-1576012113437343067</id><published>2011-12-05T00:19:00.004+05:30</published><updated>2011-12-06T22:49:36.813+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-06T22:49:36.813+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="Data Structures" /><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms" /><title>A Binary Search Tree Example</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/1576012113437343067/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=1576012113437343067" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/1576012113437343067?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/1576012113437343067?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/6oqw_7gPrXE/binary-search-tree-example-in-c.html" title="A Binary Search Tree Example" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ky9-HGF5M9h3yPSno2Tb70ZM8ZQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ky9-HGF5M9h3yPSno2Tb70ZM8ZQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ky9-HGF5M9h3yPSno2Tb70ZM8ZQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ky9-HGF5M9h3yPSno2Tb70ZM8ZQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;A Binary Tree is a tree where each node may have 0, 1 or 2 children and a Binary Search Tree is a binary tree with a special property that the value of node under discussion is less than all the nodes in its right subtree and greater than all the nodes in its left subtree.
The programs below describes the three basic operations in a binary search tree viz. search, insert and remove

1. Searching &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/6oqw_7gPrXE" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/12/binary-search-tree-example-in-c.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEcARHszfip7ImA9WhRTF0k.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-1947459936245724284</id><published>2011-05-04T08:40:00.011+05:30</published><updated>2011-11-08T14:17:25.586+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-08T14:17:25.586+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><category scheme="http://www.blogger.com/atom/ns#" term="General" /><title>Static Library - An Introduction</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/1947459936245724284/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=1947459936245724284" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/1947459936245724284?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/1947459936245724284?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/bvHZ3WCRSX4/static-library-introduction.html" title="Static Library - An Introduction" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/h-nTZRDOBjn4IjXO1Eczn5vvZXY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/h-nTZRDOBjn4IjXO1Eczn5vvZXY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/h-nTZRDOBjn4IjXO1Eczn5vvZXY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/h-nTZRDOBjn4IjXO1Eczn5vvZXY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Static library is a group of object files bundled together in an archive by the archiver program. The static libraries have a .a extension.
Advantages
1. The executable is not dependent on any library as the library code is included in the binary
2. In some cases performance improvementCommand for creating a static library
ar rcs -o libmylibrary.a file1.o file2.o file3.o

Steps for generating the&lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/bvHZ3WCRSX4" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/05/static-library-introduction.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C04FRXw_fSp7ImA9WhZXF0Q.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-4579552168980514287</id><published>2011-05-03T09:33:00.006+05:30</published><updated>2011-05-07T23:41:54.245+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-07T23:41:54.245+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><category scheme="http://www.blogger.com/atom/ns#" term="General" /><title>Shared Library - An Introduction</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/4579552168980514287/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=4579552168980514287" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/4579552168980514287?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/4579552168980514287?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/4KADr7GBKgA/shared-library-tutorial.html" title="Shared Library - An Introduction" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/BCY3wWK48sr9tkiifYsmk2n6ELc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BCY3wWK48sr9tkiifYsmk2n6ELc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/BCY3wWK48sr9tkiifYsmk2n6ELc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/BCY3wWK48sr9tkiifYsmk2n6ELc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;A shared library is a library required by an executable to run properly. Such executables are called incomplete executables as they call routines present in the shared library code. The executables generated from the shared library are smaller in size than the ones generated from a static library

When an executable built with shared library is run, the dynamic loader identifies the list of &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/4KADr7GBKgA" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/05/shared-library-tutorial.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUcNQXc-fip7ImA9WhZRFkw.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-2815076503552508792</id><published>2011-03-20T21:21:00.002+05:30</published><updated>2011-04-12T18:28:10.956+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-04-12T18:28:10.956+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Cygwin" /><category scheme="http://www.blogger.com/atom/ns#" term="Multithreading" /><title>POSIX Threads - A simple Example</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/2815076503552508792/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=2815076503552508792" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/2815076503552508792?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/2815076503552508792?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/_EGdYD3N9UM/posix-threads-simple-example.html" title="POSIX Threads - A simple Example" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-XLfkvKGeP0U/TYYcde1iN6I/AAAAAAAADkk/pgQKfbXsKG4/s72-c/pthread_simple_example.JPG" height="72" width="72" /><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/0IIugE_eauSPQFacYv7PDJK8YPo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/0IIugE_eauSPQFacYv7PDJK8YPo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/0IIugE_eauSPQFacYv7PDJK8YPo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/0IIugE_eauSPQFacYv7PDJK8YPo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;In our earlier post, we have written multithreaded program using win32 apis. This post deals with writing the multithreaded programs using POSIX thread apis. The important POSIX thread apis are namely pthread_create, pthread_exit and pthread_join

Create a threadint pthread_create
(
    pthread_t *thread,
    const pthread_attr_t *attr,
    void *( *start_routine)(void *), 
    void *arg
);
&lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/_EGdYD3N9UM" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/03/posix-threads-simple-example.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8BRXo5eip7ImA9WhZTFUs.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-2946452043106393234</id><published>2011-03-20T01:13:00.001+05:30</published><updated>2011-03-20T01:14:14.422+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-20T01:14:14.422+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="General" /><title>Command prompt and setting environment variable properties</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/2946452043106393234/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=2946452043106393234" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/2946452043106393234?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/2946452043106393234?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/6rNaJRXBMps/command-prompt-and-setting-environment.html" title="Command prompt and setting environment variable properties" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-fj5v1lHf9e0/TYUG1nlxksI/AAAAAAAADkY/YuMxVhpUIDI/s72-c/cmd.jpg" height="72" width="72" /><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/381Vx0cuoXJGevmv_cBgTqaRD3A/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/381Vx0cuoXJGevmv_cBgTqaRD3A/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/381Vx0cuoXJGevmv_cBgTqaRD3A/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/381Vx0cuoXJGevmv_cBgTqaRD3A/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Working on multiple projects which require different compiler versions can be a daunting task especially if you are using windows command prompt cmd.exe to build the projects. You need to export the compiler specific environment variables and set the PATH variable appropriately each time you launch the command window to build each project. Here is a small tip that can help save some time

Tip
&lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/6rNaJRXBMps" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/03/command-prompt-and-setting-environment.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkEDQHc9fip7ImA9WhZTFE4.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-1855119313777675164</id><published>2011-03-15T14:26:00.011+05:30</published><updated>2011-03-18T13:21:11.966+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-18T13:21:11.966+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Shell Scripting" /><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><title>Customize Cygwin/Linux command prompt</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/1855119313777675164/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=1855119313777675164" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/1855119313777675164?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/1855119313777675164?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/fTQqaohEXRc/customize-cygwinlinux-command-prompt.html" title="Customize Cygwin/Linux command prompt" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-fy0nZr-495o/TX-wkYOJWCI/AAAAAAAADj0/2JqS1ryvLzU/s72-c/PS1_Example.jpg" height="72" width="72" /><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/GK-xgrPUErZ_c6j6VIW-YF0e-WU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/GK-xgrPUErZ_c6j6VIW-YF0e-WU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/GK-xgrPUErZ_c6j6VIW-YF0e-WU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/GK-xgrPUErZ_c6j6VIW-YF0e-WU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;From the bash manual, the following environment variables control the display of prompt in a Cygwin or Linux terminal namely PS1, PS2, PS3, PS4. 
Note: For referring the bash manual type info bash
Key Points
1. PS1 : The value of this parameter is expanded and used as the primary prompt string. It's default value is '\s-\v\$ '
2. PS2 : The value of this parameter is expanded as with PS1 and used &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/fTQqaohEXRc" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/03/customize-cygwinlinux-command-prompt.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0YBRXgyeCp7ImA9WhZTEU8.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-954313010652293438</id><published>2011-03-14T21:57:00.007+05:30</published><updated>2011-03-14T22:15:54.690+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-14T22:15:54.690+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="General" /><title>Anatomy of a process stack</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/954313010652293438/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=954313010652293438" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/954313010652293438?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/954313010652293438?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/eJ8F8NmpNg8/anatomy-of-process-stack.html" title="Anatomy of a process stack" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-rYQbtcCa_lo/TX5D6-1SxqI/AAAAAAAADjE/HB8EdPoHN9A/s72-c/stackframes.JPG" height="72" width="72" /><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/rAxMmZnc6zZOt3EakvrPx4sPmkQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/rAxMmZnc6zZOt3EakvrPx4sPmkQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/rAxMmZnc6zZOt3EakvrPx4sPmkQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/rAxMmZnc6zZOt3EakvrPx4sPmkQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;A process is a program in execution. A process may have one or more threads executing different sections of the program. Every thread in the process maintains it's own separate stack, registers and program counter. 
Key Points
A stack is a collection of stack frames where each stack frame refers to a function call
Stack Frame
When a function call is made, a block of memory is set aside which &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/eJ8F8NmpNg8" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/03/anatomy-of-process-stack.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUMCQns7eSp7ImA9Wx9aFE4.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-6988159810897278160</id><published>2011-03-06T15:58:00.003+05:30</published><updated>2011-03-07T00:21:03.501+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-07T00:21:03.501+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="General" /><title>A simple Makefile example</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/6988159810897278160/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=6988159810897278160" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/6988159810897278160?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/6988159810897278160?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/vygWzhASh6w/simple-makefile.html" title="A simple Makefile example" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-CRvqrtgmvU8/TXPXhs3DEQI/AAAAAAAADig/hpK-vRD0ZGo/s72-c/gnumakefile.JPG" height="72" width="72" /><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/mJeZvMLbkQ2V-YPyDS4tbbKbiKM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mJeZvMLbkQ2V-YPyDS4tbbKbiKM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/mJeZvMLbkQ2V-YPyDS4tbbKbiKM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mJeZvMLbkQ2V-YPyDS4tbbKbiKM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Continuing our series on makefile tutorial, below is a simple makefile which compiles the Hello World program Main.cpp into an object file Main.o and generates the binary executable Main.exe
#-----------------------------------------------------------------------
#                   A Simple Makefile example
#-----------------------------------------------------------------------
PROJECT := Main
&lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/vygWzhASh6w" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/03/simple-makefile.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0cFSH85eip7ImA9WhZQGUU.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-2525441869352897879</id><published>2011-03-04T14:51:00.016+05:30</published><updated>2011-04-28T15:33:39.122+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-04-28T15:33:39.122+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="General" /><title>Makefile tutorial for beginners</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/2525441869352897879/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=2525441869352897879" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/2525441869352897879?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/2525441869352897879?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/LyPAJWKboSM/simple-makefile-tutorial.html" title="Makefile tutorial for beginners" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/YYbbCtNjC9dfmN4IBVVOdIbBLQQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/YYbbCtNjC9dfmN4IBVVOdIbBLQQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/YYbbCtNjC9dfmN4IBVVOdIbBLQQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/YYbbCtNjC9dfmN4IBVVOdIbBLQQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;The purpose of the make utility is to determine automatically which pieces of your large program needs to be re-compiled, and issue the commands to recompile them. The make program uses the makefile instructions and the last modified time of the files to decide which of the files needs to be updated. 
A makefile tells make what to do. The make utility executes commands in the makefile to update &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/LyPAJWKboSM" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/03/simple-makefile-tutorial.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A08ASXk5fip7ImA9Wx9aEEo.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-3085773210009096204</id><published>2011-03-02T15:46:00.007+05:30</published><updated>2011-03-02T21:00:48.726+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-02T21:00:48.726+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="Multithreading" /><title>Producer and Consumer Problem revisited with Events</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/3085773210009096204/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=3085773210009096204" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/3085773210009096204?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/3085773210009096204?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/uGYosG9G4YY/revisiting-producer-and-consumer.html" title="Producer and Consumer Problem revisited with Events" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-kfVvqreLfjY/TW4ozX4cAUI/AAAAAAAADiI/g21Uj53xwbA/s72-c/Producer_Consumer_Events_New.JPG" height="72" width="72" /><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/aJcnlXSYnng393888IpReUNk6CM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aJcnlXSYnng393888IpReUNk6CM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/aJcnlXSYnng393888IpReUNk6CM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aJcnlXSYnng393888IpReUNk6CM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;The producer and consumer problem we visited earlier used CRITICAL_SECTION for synchronization and the threads were spinning and checking over the queue size to add or remove the elements. In this post, we are going to use Windows Event objects for synchronizing the Producer and Consumer threads.
Key Points
1. Events are kernel objects which contain an usage count, flag indicating the type of &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/uGYosG9G4YY" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/03/revisiting-producer-and-consumer.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck8ERX44cSp7ImA9Wx9aEE0.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-7449292881325553648</id><published>2011-02-26T00:02:00.009+05:30</published><updated>2011-03-01T23:03:24.039+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-01T23:03:24.039+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Sort elements in a Collection using Comparator Interface</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/7449292881325553648/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=7449292881325553648" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/7449292881325553648?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/7449292881325553648?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/anoemmWC99Q/sort-elements-in-collection-using.html" title="Sort elements in a Collection using Comparator Interface" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-LX9zyGRt3fM/TWf1i-NqOjI/AAAAAAAADho/2nQCd7h3RpY/s72-c/ComparatorInterface.JPG" height="72" width="72" /><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/XFRb08SMo8nqsPq1W7emQ8ytCUQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XFRb08SMo8nqsPq1W7emQ8ytCUQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/XFRb08SMo8nqsPq1W7emQ8ytCUQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XFRb08SMo8nqsPq1W7emQ8ytCUQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Continuing our series of sorting elements in a Collection, this post makes use of the Comparator interface to sort the objects. 
Key Idea
The sort(List list, Comparator c)method sorts the specified (modifiable) list in the order specified by the comparator
The Employee Java Bean below makes use of the EmployeeNameComparator class to sort the Employee elements in the list. Also, note the use of &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/anoemmWC99Q" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/02/sort-elements-in-collection-using.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkEMRng_fSp7ImA9Wx9aEE0.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-2838795238429469681</id><published>2011-02-25T21:39:00.011+05:30</published><updated>2011-03-01T23:01:27.645+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-01T23:01:27.645+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Sort elements in a collection using Comparable Interface</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/2838795238429469681/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=2838795238429469681" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/2838795238429469681?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/2838795238429469681?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/RteaCCuqM64/sort-elements-in-collection.html" title="Sort elements in a collection using Comparable Interface" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-yNIwJhe_uJY/TWfT8nOuS0I/AAAAAAAADhc/un57bnzdAk4/s72-c/ComparableInterface.JPG" height="72" width="72" /><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/2oNpYVornAt4_93oDH5XUx-Wthc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2oNpYVornAt4_93oDH5XUx-Wthc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/2oNpYVornAt4_93oDH5XUx-Wthc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2oNpYVornAt4_93oDH5XUx-Wthc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;The Collections class in java provides the following methods for sorting the specified (modifiable) list. This post deals with the first method from the list.
void sort(List list)
void sort(List list, Comparator c)

Key Points

The sort(List list)method sorts the elements in ascending order according to the natural ordering of it's elements. The ordering is defined by implementing Comparable &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/RteaCCuqM64" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/02/sort-elements-in-collection.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEUCQHg4fyp7ImA9Wx9bFkw.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-6583585279175090953</id><published>2011-02-24T15:41:00.013+05:30</published><updated>2011-02-25T12:14:21.637+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-25T12:14:21.637+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server" /><title>Orphan Users in SQL Server 2005</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/6583585279175090953/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=6583585279175090953" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/6583585279175090953?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/6583585279175090953?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/NOB62NCQmug/orphaned-users-in-sql-server-2005.html" title="Orphan Users in SQL Server 2005" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/AGJnt4eLwcl2S69e_CimpFztnTs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/AGJnt4eLwcl2S69e_CimpFztnTs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/AGJnt4eLwcl2S69e_CimpFztnTs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/AGJnt4eLwcl2S69e_CimpFztnTs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;All Sql Server logins are stored in a system base table in master database. Whenever a new user is created, a corresponding entry is added in the system base table. There is a associated login entry for every user in system base table which also stores an associated SID (security identifier).

Key Idea

1. An orphan user is one which does not have an associated login entry in the System Base &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/NOB62NCQmug" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/02/orphaned-users-in-sql-server-2005.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEMDR3k6cCp7ImA9Wx9UGEo.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-2712509410315575657</id><published>2011-02-16T22:41:00.004+05:30</published><updated>2011-02-16T22:44:36.718+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-16T22:44:36.718+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="General" /><category scheme="http://www.blogger.com/atom/ns#" term="Multithreading" /><title>Mutex vs Semaphores</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/2712509410315575657/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=2712509410315575657" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/2712509410315575657?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/2712509410315575657?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/8L5XfY09GwQ/mutex-vs-semaphore.html" title="Mutex vs Semaphores" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/xe7cvT8PhZkl_lCiiUw1tg4ExNg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xe7cvT8PhZkl_lCiiUw1tg4ExNg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/xe7cvT8PhZkl_lCiiUw1tg4ExNg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xe7cvT8PhZkl_lCiiUw1tg4ExNg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Key Points

1. Only the thread which acquires the mutex can release the mutex successfully.
2. A binary semaphore (semaphore with a count of 1) is similar to mutex but allows other threads to release it.
A thread which owns a mutex can acquire the same mutex recursively without blocking it's execution. This prevents the thread from deadlocking itself while waiting for the mutex it already owns. &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/8L5XfY09GwQ" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/02/mutex-vs-semaphore.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUYBQ3wyfSp7ImA9Wx9UGEg.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-6766022080868527588</id><published>2011-02-16T00:35:00.010+05:30</published><updated>2011-02-16T17:22:32.295+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-16T17:22:32.295+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="Multithreading" /><title>Thread Synchronization using Windows Mutex</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/6766022080868527588/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=6766022080868527588" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/6766022080868527588?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/6766022080868527588?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/7ceutwFnRe4/thread-synchronization-using-windows.html" title="Thread Synchronization using Windows Mutex" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-Wk5T9dWC9xo/TVrLDk64L4I/AAAAAAAADg0/f4crAuKVOtE/s72-c/Results_With_Improper_TimeOut.JPG" height="72" width="72" /><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/sD7wCO9_iIvsMhS6DK41GZwSIag/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sD7wCO9_iIvsMhS6DK41GZwSIag/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/sD7wCO9_iIvsMhS6DK41GZwSIag/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sD7wCO9_iIvsMhS6DK41GZwSIag/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;In my earlier post Thread Synchronization in Windows using Critical Section, I have used Windows Critical Section as Locks for synchronizing the threads. This post talks about using Windows Mutex as synchronization objects and demonstrates it's use with a simple example. Windows functions related with Mutexes are CreateMutex, ReleaseMutex and OpenMutex

HANDLE CreateMutex(
  LPSECURITY_ATTRIBUTES&lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/7ceutwFnRe4" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/02/thread-synchronization-using-windows.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE8AQHo9fip7ImA9Wx9UFk8.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-8000436526744961410</id><published>2011-02-14T01:18:00.006+05:30</published><updated>2011-02-14T01:24:01.466+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-14T01:24:01.466+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="Multithreading" /><title>Producer and Consumer Problem using Windows Threads</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/8000436526744961410/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=8000436526744961410" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/8000436526744961410?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/8000436526744961410?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/1Q-B6cW9FAg/producer-and-consumer-problem-using.html" title="Producer and Consumer Problem using Windows Threads" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-WdSkugcMmSw/TVgsedBZE2I/AAAAAAAADgc/agzS0SACITA/s72-c/ProducerConsumer.JPG" height="72" width="72" /><thr:total>1</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/G-e02-omk-LgoSqpeWmCyxjIhc4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/G-e02-omk-LgoSqpeWmCyxjIhc4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/G-e02-omk-LgoSqpeWmCyxjIhc4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/G-e02-omk-LgoSqpeWmCyxjIhc4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Above is class diagram for a simple producer/consumer problem
#include &amp;lt;iostream&amp;gt;
#include "MQ.h"
#include "Thread.h"
#include "Runnable.h"
#include "ProductionTask.h"
#include "ConsumptionTask.h"

//File: Main.cpp

using namespace examples;

int main()
{
    try
    {
        MQ q(10);
        ProductionTask producerTask(q);
        ConsumptionTask consumerTask(q);
        Thread t[2] = { &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/1Q-B6cW9FAg" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/02/producer-and-consumer-problem-using.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0MGR30yfCp7ImA9Wx9UF0s.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-7437880056247259198</id><published>2011-02-11T22:02:00.010+05:30</published><updated>2011-02-15T15:53:46.394+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-15T15:53:46.394+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="Multithreading" /><title>Encapsulating Windows Threads in C++ Objects</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/7437880056247259198/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=7437880056247259198" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/7437880056247259198?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/7437880056247259198?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/-_7AkT_wbso/encapsulating-windows-threads-in-c.html" title="Encapsulating Windows Threads in C++ Objects" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-PoEMN26CMbE/TVWGlDEi2rI/AAAAAAAADf4/52fosL_l15k/s72-c/InterleavedOutput.JPG" height="72" width="72" /><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/KlavMSsWum4237XR5iohsSEAd4k/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KlavMSsWum4237XR5iohsSEAd4k/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/KlavMSsWum4237XR5iohsSEAd4k/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/KlavMSsWum4237XR5iohsSEAd4k/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Threads in Windows can be created using the following three routines
HANDLE CreateThread(
LPSECURITY_ATTRIBUTES lpsa,
DWORD cbStack,
LPTHREAD_START_ROUTINE lpStartAddr,
LPVOID lpvThreadParam,
DWORD fdwCreate,
LPDWORD lpIDThread
);uintptr_t _beginthread( 
void( *start_address )( void * ),
unsigned stack_size,
void *arglist 
);uintptr_t _beginthreadex( 
void *security,
unsigned stack_size,
unsigned&lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/-_7AkT_wbso" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/02/encapsulating-windows-threads-in-c.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0EEQnw-fSp7ImA9Wx9UEkU.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-6317945373369513737</id><published>2011-02-10T01:00:00.008+05:30</published><updated>2011-02-10T01:30:03.255+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-10T01:30:03.255+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="Multithreading" /><title>Coding simplified with Guard Classes</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/6317945373369513737/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=6317945373369513737" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/6317945373369513737?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/6317945373369513737?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/KltvRNw27b8/simplified-coding-with-guard-classes.html" title="Coding simplified with Guard Classes" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/G7WFN9A8nS-KqHjBCJ7A6e6snQQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/G7WFN9A8nS-KqHjBCJ7A6e6snQQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/G7WFN9A8nS-KqHjBCJ7A6e6snQQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/G7WFN9A8nS-KqHjBCJ7A6e6snQQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;With the introduction of exceptions, writing code has become increasingly complex. Any resource acquired has to be released when no longer in use. If not handled properly will lead to handle leaks, memory leaks and in some cases deadlocks which are very difficult to debug. 
Guard classes takes advantage of the fact that the destructor is always called for an object on the stack regardless of how &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/KltvRNw27b8" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/02/simplified-coding-with-guard-classes.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkQFRncycSp7ImA9Wx9UEkU.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-1519104479010526095</id><published>2011-02-09T23:11:00.010+05:30</published><updated>2011-02-10T01:08:37.999+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-10T01:08:37.999+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="Multithreading" /><title>Debug the Code : Thread synchronization</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/1519104479010526095/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=1519104479010526095" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/1519104479010526095?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/1519104479010526095?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/AjFYMw_Yzw8/program-is-supposed-to-print-multiples.html" title="Debug the Code : Thread synchronization" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_ebteqMFaxAo/TVLGIDzJAOI/AAAAAAAADfg/5y7mAFtQcdo/s72-c/DebugTheCode_ThreadSynchronization.JPG" height="72" width="72" /><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Y0Zb9e52tAKU5bd-6A2KhAGKy5U/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Y0Zb9e52tAKU5bd-6A2KhAGKy5U/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Y0Zb9e52tAKU5bd-6A2KhAGKy5U/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Y0Zb9e52tAKU5bd-6A2KhAGKy5U/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;The program is supposed to print multiples of 10 in a new line in increasing order. Although, the program appears to be correct, it is not. It is giving me duplicate values in the output. Locate the problem?
#include &amp;lt;windows.h&amp;gt;
#include &amp;lt;process.h&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;assert.h&amp;gt;
#include "Lock.h"

using namespace examples;

static bool alive = true;
static int current = 0;

unsigned __&lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/AjFYMw_Yzw8" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/02/program-is-supposed-to-print-multiples.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUIDSHYyeCp7ImA9Wx9UEUQ.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-6165520985446215909</id><published>2011-02-09T00:45:00.008+05:30</published><updated>2011-02-09T01:02:59.890+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-09T01:02:59.890+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="Multithreading" /><title>Thread Synchronization in Windows using Critical Section</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/6165520985446215909/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=6165520985446215909" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/6165520985446215909?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/6165520985446215909?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/VcsNRa2odUk/thread-synchronization-in-windows-using.html" title="Thread Synchronization in Windows using Critical Section" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_ebteqMFaxAo/TVGUw_T8ZwI/AAAAAAAADfU/GqUUtZSH7J4/s72-c/CriticalSectionExample.JPG" height="72" width="72" /><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/kOn9WIu-DBQvfPlxBxUuDk1rzQc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kOn9WIu-DBQvfPlxBxUuDk1rzQc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/kOn9WIu-DBQvfPlxBxUuDk1rzQc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kOn9WIu-DBQvfPlxBxUuDk1rzQc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;In multi threaded environments, where more than one thread operates on the shared data (global variables, collections) the results can be unpredictable due to race conditions. Critical Section is a mechanism that ensures that only one thread executes a particular piece of the code. A thread, once it enters a critical section should not be interrupted. Critical Sections have the advantage of not &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/VcsNRa2odUk" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/02/thread-synchronization-in-windows-using.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEAGRXszfSp7ImA9Wx9UEUQ.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-5777508301880618377</id><published>2011-02-02T23:50:00.008+05:30</published><updated>2011-02-09T00:48:44.585+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-09T00:48:44.585+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows" /><category scheme="http://www.blogger.com/atom/ns#" term="Multithreading" /><title>Multithreading in Windows - A simple example</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/5777508301880618377/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=5777508301880618377" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/5777508301880618377?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/5777508301880618377?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/QNIn-fde1nA/multithreading-in-windows-simple.html" title="Multithreading in Windows - A simple example" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_ebteqMFaxAo/TUmfcEsRkWI/AAAAAAAADe0/NZqWRqNlZAs/s72-c/simple_mt_example_windows.JPG" height="72" width="72" /><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Zf8bV8wkouPHFIO2KCRjS9oZD0A/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Zf8bV8wkouPHFIO2KCRjS9oZD0A/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Zf8bV8wkouPHFIO2KCRjS9oZD0A/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Zf8bV8wkouPHFIO2KCRjS9oZD0A/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;A thread is an independent unit of execution within a process. Threads under windows can be created/terminated using the following Win API functions:

1. CreateThread()/ExitThread() system calls. 
2. _beginthread()/_endthread() OR _beginthreadex()/_endthreadex() CRT functions.

Key Points

1. Using CreateThread() in a program that uses the CRT functions (for example, links with LIBCMT.LIB) may &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/QNIn-fde1nA" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/02/multithreading-in-windows-simple.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk8BSHg7cCp7ImA9Wx9VF04.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-3769348082234875113</id><published>2011-01-31T02:27:00.014+05:30</published><updated>2011-02-03T17:37:39.608+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-03T17:37:39.608+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><title>Overloading operator()</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/3769348082234875113/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=3769348082234875113" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/3769348082234875113?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/3769348082234875113?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/rTQn_h3JqFA/c-operator-overloading.html" title="Overloading operator()" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_ebteqMFaxAo/TUXQREjMddI/AAAAAAAADek/BHDHbcr-SE0/s72-c/Matrix_Operator.JPG" height="72" width="72" /><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/fwZ7_9LKeMVvzLov-0BHBVfpcgk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/fwZ7_9LKeMVvzLov-0BHBVfpcgk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/fwZ7_9LKeMVvzLov-0BHBVfpcgk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/fwZ7_9LKeMVvzLov-0BHBVfpcgk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Browsing through some of the open source code implementation in C++, came across the function void operator()() 
Q. Why would one use operator() in the first place? 
A. Simplicity of usage. Of course, less intuitive if you are seeing it's use for the very first time. 

The program below implements a matrix and uses operator() as a replacement of subscript operator[] to retrieve and set values at &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/rTQn_h3JqFA" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/01/c-operator-overloading.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk4ERH06eyp7ImA9Wx9WGEg.&quot;"><id>tag:blogger.com,1999:blog-6852315043205803479.post-2481022830282290539</id><published>2011-01-23T21:52:00.007+05:30</published><updated>2011-01-24T13:11:45.313+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-24T13:11:45.313+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C C++" /><title>C Program - struct usage example</title><link rel="replies" type="application/atom+xml" href="http://dev-faqs.blogspot.com/feeds/2481022830282290539/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=6852315043205803479&amp;postID=2481022830282290539" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/2481022830282290539?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6852315043205803479/posts/default/2481022830282290539?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/PerryPetersonsBlog/~3/bvcCKOTbGj0/c-program-struct-usage-example-in-c.html" title="C Program - struct usage example" /><author><name>pankaj</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_ebteqMFaxAo/TTxTB4SLAUI/AAAAAAAADeY/Ps1M-ytS0Ng/s72-c/c-struct-example-emp.JPG" height="72" width="72" /><thr:total>0</thr:total><content type="html">
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/VhQmYJGKwsDN5u7-kF5cnFsBnsg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VhQmYJGKwsDN5u7-kF5cnFsBnsg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/VhQmYJGKwsDN5u7-kF5cnFsBnsg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VhQmYJGKwsDN5u7-kF5cnFsBnsg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;This is a follow up post on my last blog update Pointers in C - an eye opener. The program touches on the following - 
1. Using struct as Employee record
2. Using pointer to Employee* as an employee list
3. Using void pointer and casting it to an appropriate type to avoid duplicate code
4. Allocating memory and freeing memory
struct Person
{
    char *name;
    size_t age;
};
typedef struct &lt;img src="http://feeds.feedburner.com/~r/PerryPetersonsBlog/~4/bvcCKOTbGj0" height="1" width="1"/&gt;</content><feedburner:origLink>http://dev-faqs.blogspot.com/2011/01/c-program-struct-usage-example-in-c.html</feedburner:origLink></entry></feed>

