<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7583883832675464864</id><updated>2012-02-16T07:15:42.996-08:00</updated><title type='text'>Its Nag's blog. check it out....</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://youfindeverything.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://youfindeverything.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Its_nags_blog</name><uri>http://www.blogger.com/profile/17596584488702584996</uri><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>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7583883832675464864.post-558738760979972945</id><published>2009-09-27T05:06:00.000-07:00</published><updated>2009-09-27T05:15:20.764-07:00</updated><title type='text'>TALKING TO HARDWARE in C language.</title><content type='html'>inportb&lt;br /&gt;Syntax&lt;br /&gt;#include &lt;pc.h&gt;&lt;br /&gt;unsigned char inportb(unsigned short _port);&lt;br /&gt;Description&lt;br /&gt;Read a single 8-bit I/O port.&lt;br /&gt;This function is provided as an inline assembler macro, and will be optimized down to a single opcode when you optimize your program.&lt;br /&gt;Return Value&lt;br /&gt;The value returned through the port.&lt;br /&gt;Portability&lt;br /&gt;ANSI/ISO C  No&lt;br /&gt;POSIX  No &lt;br /&gt;*****************************************&lt;br /&gt;Inportl&lt;br /&gt;Syntax&lt;br /&gt;#include &lt;pc.h&gt;&lt;br /&gt;unsigned long inportl(unsigned short _port);&lt;br /&gt;Description&lt;br /&gt;This function reads a single 32-bit I/O port.&lt;br /&gt;This function is provided as an inline assembler macro, and will be optimized down to a single opcode when you optimize your program.&lt;br /&gt;Return Value&lt;br /&gt;The value returned from the port.&lt;br /&gt;Portability&lt;br /&gt;ANSI/ISO C  No&lt;br /&gt;POSIX  No &lt;br /&gt;************************************************************&lt;br /&gt; inportsb&lt;br /&gt;Syntax&lt;br /&gt;#include &lt;pc.h&gt;&lt;br /&gt;void inportsb(unsigned short _port, unsigned char *_buf, unsigned _len);&lt;br /&gt;Description&lt;br /&gt;Reads the 8-bit _port _len times, and stores the bytes in buf.&lt;br /&gt;Portability&lt;br /&gt;ANSI/ISO C  No&lt;br /&gt;POSIX  No&lt;br /&gt;*************************************************************&lt;br /&gt; inportsl&lt;br /&gt;Syntax&lt;br /&gt;#include &lt;pc.h&gt;&lt;br /&gt;void inportsl(unsigned short _port, unsigned long *_buf, unsigned _len);&lt;br /&gt;Description&lt;br /&gt;Reads the 32-bit _port _len times, and stores the bytes in buf.&lt;br /&gt;Portability&lt;br /&gt;ANSI/ISO C  No&lt;br /&gt;POSIX  No &lt;br /&gt;*************************************************************&lt;br /&gt; inportsw&lt;br /&gt;Syntax&lt;br /&gt;#include &lt;pc.h&gt;&lt;br /&gt;void inportsw(unsigned short _port,&lt;br /&gt;              unsigned short *_buf, unsigned _len);&lt;br /&gt;Description&lt;br /&gt;&lt;br /&gt;Reads the 16-bit _port _len times, and stores the bytes in buf.&lt;br /&gt;Portability&lt;br /&gt;ANSI/ISO C  No&lt;br /&gt;POSIX  No &lt;br /&gt;**********************************************&lt;br /&gt;inportw&lt;br /&gt;Syntax&lt;br /&gt;#include &lt;pc.h&gt;&lt;br /&gt;unsigned short inportw(unsigned short _port);&lt;br /&gt;Description&lt;br /&gt;Read a single 16-bit I/O port.&lt;br /&gt;This function is provided as an inline assembler macro, and will be optimized down to a single opcode when you optimize your program.&lt;br /&gt;Return Value&lt;br /&gt;The value returned through the port.&lt;br /&gt;Portability&lt;br /&gt;ANSI/ISO C  No&lt;br /&gt;POSIX  No &lt;br /&gt;**************************************************&lt;br /&gt;inpw&lt;br /&gt;Syntax&lt;br /&gt;&lt;br /&gt;#include &lt;pc.h&gt;&lt;br /&gt;unsigned short inpw(unsigned short _port);&lt;br /&gt;Description&lt;br /&gt;Calls inportw. Provided only for compatibility.&lt;br /&gt;Portability&lt;br /&gt;ANSI/ISO C  No&lt;br /&gt;POSIX  No&lt;br /&gt;&lt;br /&gt;*******************************************&lt;br /&gt;Similarily with outport() also&lt;br /&gt;All the above function are same for sendting data .. except change the in prefix to out&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7583883832675464864-558738760979972945?l=youfindeverything.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://youfindeverything.blogspot.com/feeds/558738760979972945/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://youfindeverything.blogspot.com/2009/09/talking-to-hardware-in-c-language.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/558738760979972945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/558738760979972945'/><link rel='alternate' type='text/html' href='http://youfindeverything.blogspot.com/2009/09/talking-to-hardware-in-c-language.html' title='TALKING TO HARDWARE in C language.'/><author><name>Its_nags_blog</name><uri>http://www.blogger.com/profile/17596584488702584996</uri><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></entry><entry><id>tag:blogger.com,1999:blog-7583883832675464864.post-5276276087480499748</id><published>2009-09-27T04:57:00.000-07:00</published><updated>2009-09-27T05:03:45.079-07:00</updated><title type='text'>Socket Program in C</title><content type='html'>&lt;p&gt;&lt;span style="color:#ff0000;"&gt;&lt;/span&gt;&lt;em&gt;&lt;span style="font-size:180%;color:#ff0000;"&gt;&lt;marquee&gt;hey guys ! socket programing in C language..&lt;/marquee&gt;&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;span style="color:#ff0000;"&gt;you can chat with your friend .using this program,, try it ..&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;br /&gt;. TCP&lt;br /&gt;* TCP server : simple TCP server that prints received messages.&lt;br /&gt;source : tcpServer.c&lt;br /&gt;usage : ./tcpServer&lt;br /&gt;* TCP client : simple TCP client that sends data to server.&lt;br /&gt;source : tcpClient.c&lt;br /&gt;usage : ./tcpClient server data1 ... dataN&lt;br /&gt;&lt;br /&gt;/*********************** tcpserver.c ***********************/&lt;br /&gt;#include &lt;sys/types.h&gt;&lt;br /&gt;#include &lt;sys/socket.h&gt;&lt;br /&gt;#include &lt;netinet/in.h&gt;&lt;br /&gt;#include &lt;arpa/inet.h&gt;&lt;br /&gt;#include &lt;netdb.h&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#include &lt;unistd.h&gt; /* close */&lt;br /&gt;&lt;br /&gt;#define SUCCESS 0&lt;br /&gt;#define ERROR 1&lt;br /&gt;#define END_LINE 0x0&lt;br /&gt;#define SERVER_PORT 1500&lt;br /&gt;#define MAX_MSG 100&lt;br /&gt;/* function readline */&lt;br /&gt;int read_line();&lt;br /&gt;int main (int argc, char *argv[]) {&lt;br /&gt;int sd, newSd, cliLen;&lt;br /&gt;struct sockaddr_in cliAddr, servAddr;&lt;br /&gt;char line[MAX_MSG];&lt;br /&gt;&lt;br /&gt;/* create socket */&lt;br /&gt;sd = socket(AF_INET, SOCK_STREAM, 0);&lt;br /&gt;if(sd&lt;0) {&lt;br /&gt;perror("cannot open socket ");&lt;br /&gt;return ERROR;&lt;br /&gt;}&lt;br /&gt;/* bind server port */&lt;br /&gt;servAddr.sin_family = AF_INET;&lt;br /&gt;servAddr.sin_addr.s_addr = htonl(INADDR_ANY);&lt;br /&gt;servAddr.sin_port = htons(SERVER_PORT);&lt;br /&gt;if(bind(sd, (struct sockaddr *) &amp;amp;servAddr, sizeof(servAddr))&lt;0) {&lt;br /&gt;perror("cannot bind port ");&lt;br /&gt;return ERROR;&lt;br /&gt;}&lt;br /&gt;listen(sd,5);&lt;br /&gt;while(1) {&lt;br /&gt;printf("%s: waiting for data on port TCP %u\n",argv[0],SERVER_PORT);&lt;br /&gt;cliLen = sizeof(cliAddr);&lt;br /&gt;newSd = accept(sd, (struct sockaddr *) &amp;amp;cliAddr, &amp;amp;cliLen);&lt;br /&gt;if(newSd&lt;0) {&lt;br /&gt;perror("cannot accept connection ");&lt;br /&gt;return ERROR;&lt;br /&gt;}&lt;br /&gt;/* init line */&lt;br /&gt;memset(line,0x0,MAX_MSG);&lt;br /&gt;/* receive segments */&lt;br /&gt;while(read_line(newSd,line)!=ERROR) {&lt;br /&gt;printf("%s: received from %s:TCP%d : %s\n", argv[0],&lt;br /&gt;inet_ntoa(cliAddr.sin_addr),&lt;br /&gt;ntohs(cliAddr.sin_port), line);&lt;br /&gt;/* init line */&lt;br /&gt;memset(line,0x0,MAX_MSG);&lt;br /&gt;} /* while(read_line) */&lt;br /&gt;} /* while (1) */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING */&lt;br /&gt;/* this function is experimental.. I don't know yet if it works */&lt;br /&gt;/* correctly or not. Use Steven's readline() function to have */&lt;br /&gt;/* something robust. */&lt;br /&gt;/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING */&lt;br /&gt;/* rcv_line is my function readline(). Data is read from the socket&lt;br /&gt;when */&lt;br /&gt;/* needed, but not byte after bytes. All the received data is read.&lt;br /&gt;*/&lt;br /&gt;/* This means only one call to recv(), instead of one call for&lt;br /&gt;*/&lt;br /&gt;/* each received byte.&lt;br /&gt;*/&lt;br /&gt;/* You can set END_CHAR to whatever means endofline for you. (0x0A is&lt;br /&gt;\n)*/&lt;br /&gt;/* read_lin returns the number of bytes returned in line_to_return&lt;br /&gt;*/&lt;br /&gt;int read_line(int newSd, char *line_to_return) {&lt;br /&gt;static int rcv_ptr=0;&lt;br /&gt;static char rcv_msg[MAX_MSG];&lt;br /&gt;static int n;&lt;br /&gt;int offset;&lt;br /&gt;offset=0;&lt;br /&gt;while(1) {&lt;br /&gt;if(rcv_ptr==0) {&lt;br /&gt;/* read data from socket */&lt;br /&gt;memset(rcv_msg,0x0,MAX_MSG); /* init buffer */&lt;br /&gt;n = recv(newSd, rcv_msg, MAX_MSG, 0); /* wait for data */&lt;br /&gt;if (n&lt;0) {&lt;br /&gt;perror(" cannot receive data ");&lt;br /&gt;return ERROR;&lt;br /&gt;} else if (n==0) {&lt;br /&gt;printf(" connection closed by client\n");&lt;br /&gt;close(newSd);&lt;br /&gt;return ERROR;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/* if new data read on socket */&lt;br /&gt;/* OR */&lt;br /&gt;/* if another line is still in buffer */&lt;br /&gt;/* copy line into 'line_to_return' */&lt;br /&gt;while(*(rcv_msg+rcv_ptr)!=END_LINE &amp;amp;&amp;amp; rcv_ptr&lt;n) {&lt;br /&gt;memcpy(line_to_return+offset,rcv_msg+rcv_ptr,1);&lt;br /&gt;offset++;&lt;br /&gt;rcv_ptr++;&lt;br /&gt;}&lt;br /&gt;/* end of line + end of buffer =&gt; return line */&lt;br /&gt;if(rcv_ptr==n-1) {&lt;br /&gt;/* set last byte to END_LINE */&lt;br /&gt;*(line_to_return+offset)=END_LINE;&lt;br /&gt;rcv_ptr=0;&lt;br /&gt;return ++offset;&lt;br /&gt;}&lt;br /&gt;/* end of line but still some data in buffer =&gt; return line */&lt;br /&gt;if(rcv_ptr &lt;n-1) {&lt;br /&gt;/* set last byte to END_LINE */&lt;br /&gt;*(line_to_return+offset)=END_LINE;&lt;br /&gt;rcv_ptr++;&lt;br /&gt;return ++offset;&lt;br /&gt;}&lt;br /&gt;/* end of buffer but line is not ended =&gt; */&lt;br /&gt;/* wait for more data to arrive on socket */&lt;br /&gt;if(rcv_ptr == n) {&lt;br /&gt;rcv_ptr = 0;&lt;br /&gt;}&lt;br /&gt;} /* while */&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/*********************** tcpclient.c ***********************/&lt;br /&gt;&lt;br /&gt;/* tcpClient.c */&lt;br /&gt;#include &lt;sys/types.h&gt;&lt;br /&gt;#include &lt;sys/socket.h&gt;&lt;br /&gt;#include &lt;netinet/in.h&gt;&lt;br /&gt;#include &lt;arpa/inet.h&gt;&lt;br /&gt;#include &lt;netdb.h&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#include &lt;unistd.h&gt; /* close */&lt;br /&gt;#define SERVER_PORT 1500&lt;br /&gt;#define MAX_MSG 100&lt;br /&gt;int main (int argc, char *argv[]) {&lt;br /&gt;int sd, rc, i;&lt;br /&gt;struct sockaddr_in localAddr, servAddr;&lt;br /&gt;struct hostent *h;&lt;br /&gt;if(argc &lt; 3) {&lt;br /&gt;printf("usage: %s &lt;server&gt; &lt;data1&gt; &lt;data2&gt; ... &lt;datan&gt;\n",argv[0]);&lt;br /&gt;exit(1);&lt;br /&gt;}&lt;br /&gt;h = gethostbyname(argv[1]);&lt;br /&gt;if(h==NULL) {&lt;br /&gt;printf("%s: unknown host '%s'\n",argv[0],argv[1]);&lt;br /&gt;exit(1);&lt;br /&gt;}&lt;br /&gt;servAddr.sin_family = h-&gt;h_addrtype;&lt;br /&gt;memcpy((char *) &amp;amp;servAddr.sin_addr.s_addr, h-&gt;h_addr_list[0],&lt;br /&gt;h-&gt;h_length);&lt;br /&gt;servAddr.sin_port = htons(SERVER_PORT);&lt;br /&gt;/* create socket */&lt;br /&gt;sd = socket(AF_INET, SOCK_STREAM, 0);&lt;br /&gt;if(sd&lt;0) {&lt;br /&gt;perror("cannot open socket ");&lt;br /&gt;exit(1);&lt;br /&gt;}&lt;br /&gt;/* bind any port number */&lt;br /&gt;localAddr.sin_family = AF_INET;&lt;br /&gt;localAddr.sin_addr.s_addr = htonl(INADDR_ANY);&lt;br /&gt;localAddr.sin_port = htons(0);&lt;br /&gt;rc = bind(sd, (struct sockaddr *) &amp;amp;localAddr, sizeof(localAddr));&lt;br /&gt;if(rc&lt;0) {&lt;br /&gt;printf("%s: cannot bind port TCP %u\n",argv[0],SERVER_PORT);&lt;br /&gt;perror("error ");&lt;br /&gt;exit(1);&lt;br /&gt;}&lt;br /&gt;/* connect to server */&lt;br /&gt;rc = connect(sd, (struct sockaddr *) &amp;amp;servAddr, sizeof(servAddr));&lt;br /&gt;if(rc&lt;0) {&lt;br /&gt;perror("cannot connect ");&lt;br /&gt;exit(1);&lt;br /&gt;}&lt;br /&gt;for(i=2;i greater than argc;i++) {&lt;br /&gt;rc = send(sd, argv[i], strlen(argv[i]) + 1, 0);&lt;br /&gt;if(rc&lt;0) {&lt;br /&gt;perror("cannot send data ");&lt;br /&gt;close(sd);&lt;br /&gt;exit(1);&lt;br /&gt;}&lt;br /&gt;printf("%s: data%u sent (%s)\n",argv[0],i-1,argv[i]);&lt;br /&gt;}&lt;br /&gt;return&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7583883832675464864-5276276087480499748?l=youfindeverything.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://youfindeverything.blogspot.com/feeds/5276276087480499748/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://youfindeverything.blogspot.com/2009/09/socket-program-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/5276276087480499748'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/5276276087480499748'/><link rel='alternate' type='text/html' href='http://youfindeverything.blogspot.com/2009/09/socket-program-in-c.html' title='Socket Program in C'/><author><name>Its_nags_blog</name><uri>http://www.blogger.com/profile/17596584488702584996</uri><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></entry><entry><id>tag:blogger.com,1999:blog-7583883832675464864.post-1566473269589261613</id><published>2009-04-03T09:35:00.000-07:00</published><updated>2009-04-03T10:46:31.829-07:00</updated><title type='text'>Some STUFF which helps U (SORTING TECHNIQUES)</title><content type='html'>&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(0, 0, 153);font-family:times new roman;font-size:180%;"  &gt;&lt;i&gt;insertion sort&lt;/i&gt;&lt;/span&gt;:-&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;br /&gt;&lt;br /&gt;One of the simplest sorting algorithms is the &lt;i&gt;insertion sort&lt;/i&gt;. The code for the algorithm is as follows:&lt;/span&gt; &lt;p&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    &lt;b&gt;for(i = 1; i &lt;&gt;&lt;/b&gt;&lt;/span&gt;&lt;b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        Inserted = false; //boolean variable&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        j = i;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        while((j &gt;= 1) &amp;amp;&amp;amp; (Inserted == false){&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            if(List[j] &lt;&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;                swap(List[j], List[j-1]);&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            else&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;                Inserted=true;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            j--;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        }&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    }&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt; &lt;span style="color: rgb(0, 0, 153);"&gt;This algorithm works by first considering the first element of the list (element 0) to be correctly placed. It proceeds to the next element (element 1) and compares its value with. If the magnitude is smaller, it swaps it with element 0. Now, elements 0 and 1 are sorted, but only with respect to each other. Element 2 is now considered, and is moved to its correct position with respect to elements 0 and 1, i.e., it may stay where it currently is, or it may be placed between what are now elements 0 and 1, or it may be placed before element 0. To do this, elements 2 and 1 may be swapped, resulting in the placement of element 2 between what is currently element 0 and element 1, and then another swap between what are now elements 0 and 1 may be done to place the element before what is now element 0. This continues over and over again, considering the elements from element 3 through the last element of the list. Each element is placed in its proper position in the part of the list already consider to be sorted. Each element under consideration is swapped with its immediately preceeding neighbour as it moves towards the front of the list. The moment the swapping stops, the element's immediately preceding neighbor has lesser magnitude, and so the current element may be considered to be properly placed.&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(255, 102, 102);"&gt;&lt;b&gt;Complexity:&lt;/b&gt;&lt;/span&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;b&gt; In this method there are N-1 insert operations. The j-th insert operation inserts a new element into a sorted array of j elements and hence takes at most j comparisions. Thus the total number of comparisions are:&lt;/b&gt;&lt;/span&gt;&lt;b&gt; &lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;b&gt;    1 + 2 + 3 + ... + (N-1) = N*(N-1)/2 = O(N^2)&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;b&gt;INSERTION SORT II&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;h2&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:helvetica;"&gt;&lt;b&gt;iNSERTION SORT (&lt;i&gt;A&lt;/i&gt;)&lt;br /&gt;&lt;b&gt;for&lt;/b&gt; j &lt;-- 2 &lt;b&gt;to&lt;/b&gt; &lt;i&gt;length&lt;/i&gt;[A]&lt;br /&gt;     &lt;b&gt;do&lt;/b&gt; &lt;i&gt;key&lt;/i&gt;&lt;--&lt;i&gt;A&lt;/i&gt;[j]&lt;br /&gt;         //Insert &lt;i&gt;A&lt;/i&gt;[j] into the sorted sequence A[1 . . . .&lt;i&gt;j&lt;/i&gt;-1]&lt;br /&gt;         i &lt;-- j - 1                  &lt;b&gt;while&lt;/b&gt; i &gt; 0 and &lt;i&gt;A&lt;/i&gt;[i] &gt; &lt;i&gt;key&lt;/i&gt;&lt;br /&gt;                 &lt;b&gt;do&lt;/b&gt; &lt;i&gt;A&lt;/i&gt;[i + 1] &lt;-- &lt;i&gt;A&lt;/i&gt;[i]&lt;br /&gt;                      i &lt;-- i -1                 &lt;i&gt;A&lt;/i&gt;[i + 1] &lt;-- &lt;i&gt;key&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;marquee&gt;&lt;b&gt;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\&lt;br /&gt;&lt;br /&gt;&lt;/b&gt;&lt;/marquee&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;h1&gt;&lt;span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;COUNTING SORT&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;br /&gt;&lt;h2&gt; &lt;span style=";font-family:Helvetica;color:black;"  &gt; &lt;p align="justify"&gt;Counting sort is a linear time sorting algorithm used to sort items when they belong to a fixed and finite set. Integers which lie in a fixed interval, say k1 to k2, are examples of such items.&lt;/p&gt; &lt;p align="justify"&gt;The algorithm proceeds by defining an ordering relation between the items from which the set to be sorted is derived (for a set of integers, this relation is trivial).Let the set to be sorted be called A. Then, an auxiliary array with size equal to the number of items in the superset is defined, say B. For each element in A, say &lt;i&gt;e&lt;/i&gt;, the algorithm stores the number of items in A smaller than or equal to &lt;i&gt;e&lt;/i&gt; in B(&lt;i&gt;e&lt;/i&gt;). If the sorted set is to be stored in an array C, then for each &lt;i&gt;e&lt;/i&gt; in A, taken in reverse order, C[B[&lt;i&gt;e&lt;/i&gt;]] = &lt;i&gt;e&lt;/i&gt;. After each such step, the value of B(&lt;i&gt;e&lt;/i&gt;) is decremented.&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;The algorithm makes two passes over A and one pass over B. If size of the range k is smaller than size of input n, then time complexity=O(n). Also, note that it is a stable algorithm, meaning that ties are resolved by reporting those elements first which occur first.&lt;/p&gt; &lt;p align="justify"&gt;This visual demonstration takes 8 randomly generated single digit numbers as input and sorts them. The range of the inputs are from 0 to 9.&lt;/p&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h2&gt;&lt;p align="justify"&gt;&lt;span style="font-family:TimesRoman;"&gt;COUNTING SORT(&lt;i&gt;A,B,k&lt;/i&gt;)&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:TimesRoman;"&gt;1  for &lt;i&gt;i&lt;/i&gt; = 1 to &lt;i&gt;k&lt;/i&gt;&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:TimesRoman;"&gt;2      do &lt;i&gt;c[i]&lt;/i&gt; = 0 &lt;/span&gt;&lt;/p&gt;&lt;p align="justify"&gt;&lt;span style="font-family:TimesRoman;"&gt;3  for &lt;i&gt;j&lt;/i&gt; = 1 to &lt;i&gt;length[A]&lt;/i&gt;&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:TimesRoman;"&gt;4      do &lt;i&gt;C[A[j]] = C[A[j]]&lt;/i&gt; + 1 &lt;/span&gt;&lt;/p&gt;&lt;p align="justify"&gt;&lt;span style="font-family:TimesRoman;"&gt;5  &gt;&lt;i&gt;C[i]&lt;/i&gt; now contains the number of elements equal to &lt;i&gt;i&lt;/i&gt;&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:TimesRoman;"&gt;6  for &lt;i&gt;i&lt;/i&gt; = 2 to &lt;i&gt;k&lt;/i&gt;&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:TimesRoman;"&gt;7      do &lt;i&gt;C[i] = C[i] + C[i-1]&lt;/i&gt;&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:TimesRoman;"&gt;8  &gt;&lt;i&gt;C[i]&lt;/i&gt; now contains the number of elements less than or equal to &lt;i&gt;i&lt;/i&gt;&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:TimesRoman;"&gt;9  for &lt;i&gt;j = length[A]&lt;/i&gt; downto 1&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:TimesRoman;"&gt;10      do &lt;i&gt;B[C[A[j]]] = A[j]&lt;/i&gt;&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="font-family:TimesRoman;"&gt;11       &lt;i&gt;C[A[j]] = C[A[J]]&lt;/i&gt; - 1&lt;/span&gt;&lt;/p&gt;&lt;p align="justify"&gt;&lt;span style="font-family:TimesRoman;"&gt;//////////////////////////////////////////////////////////////////////////////////////////////////&lt;/span&gt;&lt;/p&gt;&lt;p align="justify"&gt;&lt;span style="font-family:TimesRoman;"&gt;HEAP SORT&lt;/span&gt;&lt;/p&gt;&lt;p align="justify"&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;The &lt;i&gt;heapsort&lt;/i&gt; algorithm uses the data structure called the heap. A heap is defined as a complete binary tree in which each node has a value greater than both its children (if any). Each node in the heap corresponds to an element of the array, with the root node corresponding to the element with index 0 in the array. Considering a node corresponding to index i, then its left child has index (2*i + 1) and its right child has index (2*i + 2). If any or both of these elements do not exist in the array, then the corresponding child node does not exist either. Note that in a heap the largest element is located at the root node. The code for the algorithm is:&lt;/span&gt; &lt;/p&gt;&lt;/h2&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    &lt;b&gt;Heapify(A, i){&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        l &lt;- left(i)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        r &lt;- right(i)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        if l &lt;= heapsize[A] and A[l] &gt; A[i]&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            then largest &lt;- l&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            else largest &lt;- i&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        if r &lt;= heapsize[A] and A[r] &gt; A[largest]&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            then largest &lt;- r&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        if largest != i&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            then swap A[i] &lt;-&gt; A[largest]&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;                Heapify(A, largest)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    }&lt;/span&gt;&lt;/b&gt; &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    Buildheap(A){&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        heapsize[A] &lt;- length[A]&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        for i &lt;- |length[A]/2| downto 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            do Heapify(A, i)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    }&lt;/span&gt;&lt;/b&gt; &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    Heapsort(A){&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        Buildheap(A)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        for i &lt;- length[A] downto 2&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            do swap A[1] &lt;-&gt; A[i]&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            heapsize[A] &lt;- heapsize[A] - 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            Heapify(A, 1)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    }&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Heap Sort operates by first converting the initial array into a heap. The HeapSort algorithm uses a process called Heapify to accomplish its job. The Heapify algorithm, as shown above, receives a binary tree as input and converts it to a heap. The root is then compared with its two immediate children, and the larger child is swapped with it. This may result in one of the left or right subtrees losing their heap property. Consequently, the Heapify algorithm is recursively applied to the appropriate subtree rooted at the the node whose value was just swapped with the root and the process continues until either a leaf node is reached, or it is determined that the heap property is satisfied in the subtree.&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    The entire HeapSort method consists of two major steps:&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    STEP 1: Construct the initial heap using adjust (N/2) times on all non-leaf nodes.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    STEP 2: Sort by swapping and adjusting the heap (N-1) times.&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    In step 2, since the largest element of the heap is always at the root, after the initial heap is constructed, the root value is swapped with the lowest, rightmost element. This node corresponds to the last element of the array and so after the swapping the righmost element of the array has the largest value, which is what we want it to have. Consequently, the rightmost element is correctly place, and so the corresponding node becomes a light gray in the tree display depicting the heap. Also, the elements (nodes) chosen for swapping at this point of the algorithm are shown as yellow nodes.&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    Thereafter, since the value of the lowest, rightmost node has moved up to the root, the heap property of the rest of the heap (minus the gray nodes) has been disturbed. Consequently, now the Heapify process is applied to the rest of the heap (treating the light gray nodes as though they were no longer a part of the heap). Once the rest of the heap is again converted to a proper heap, the swapping process as described in the previous paragraph, followed by the Heapify process is applied again. This continues until the root node of the heap turns light gray - i.e., the root has its correct value. Then, the array is sorted.&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;hr /&gt;&lt;br /&gt;&lt;img style="width: 406px; height: 52px;" src="http://www.cse.iitk.ac.in/users/dsrkg/cs210/applets/pics/complexbanner.jpg" nosave="" /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    At each step of the Heapify algorithm, a node is compared to its children and one of them is chosen as the next root. One level of the tree is dropped at each step of this process. Since the heap is a complete binary tree, there are atmost log(N) levels. Thus, the worst case time complexity of Heapify is O(log(N)). In the Heapsort algorithm, Heapify is used (N/2) times to construct the initial heap and (N-1) times to sort. Thus the Heapsort algorithm has a worst case time complexity of O(N*log(N)).&lt;/span&gt; &lt;p&gt; &lt;/p&gt;&lt;h2&gt;&lt;span style=";font-family:Helvetica;color:black;"  &gt;&lt;p align="justify"&gt;******************************************************************************&lt;/p&gt;&lt;/span&gt;&lt;/h2&gt;&lt;h1&gt;&lt;span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;POSTMAN SORT&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;br /&gt;&lt;h2&gt;&lt;p align="justify"&gt;&lt;span style="color: rgb(0, 0, 0);font-family:helvetica;" &gt;Postman Sort is probably the newest linear order sorting algorithm for fixed domain sets in use today. It's developers claim that it is also the fastest such algorithm.&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="color: rgb(0, 0, 0);font-family:helvetica;" &gt;The algorithm works by sorting the numbers from their most significant digit to their least significant digit. Significant gain in speed is achieved by sorting the numbers on more than one digit at a time (the actual number is decided based on the size of the computer's memory). The process is also considerably speeded up by using some knowledge of the range in which the numbers lie, for example the fact that digits of octal numbers lie in the range 0 to 7.&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style="color: rgb(0, 0, 0);font-family:helvetica;" &gt;For this visual demonstration we have sorted randomly input 9 digit binary numbers, using 3 digits at a time (The use of binary numbers enhances the clarity of the visual representation considerably).&lt;/span&gt;&lt;/p&gt;&lt;p align="justify"&gt;&lt;span style="color: rgb(0, 0, 0);font-family:helvetica;" &gt;""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""&lt;/span&gt;&lt;/p&gt;&lt;/h2&gt;&lt;h1&gt;&lt;span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;RADIX SORT&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;br /&gt;&lt;h2&gt;&lt;p align="justify"&gt;&lt;span style=";font-family:Helvetica;color:black;"  &gt;Radix sort is one of the linear sorting algorithms for integers. It functions by sorting the input numbers on each digit, for each of the digits in the numbers. However, the process adopted by this sort method is somewhat counterintuitive, in the sense that the numbers are sorted on the least-significant digit first, followed by the second-least significant digit and so on till the most significant digit.&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style=";font-family:Helvetica;color:black;"  &gt;To appreciate Radix Sort, consider the following analogy: Suppose that we wish to sort a deck of 52 playing cards (the different suits can be given suitable values, for example 1 for Diamonds, 2 for Clubs, 3 for Hearts and 4 for Spades). The 'natural' thing to do would be to first sort the cards according to suits, then sort each of the four seperate piles, and finally combine the four in order. This approach, however, has an inherent disadvantage. When each of the piles is being sorted, the other piles have to be kept aside and kept track of. If, instead, we follow the 'counterintuitive' aproach of first sorting the cards by value, this problem is eliminated. After the first step, the four seperate piles are combined in order and then sorted by suit. If a stable sorting algorithm (i.e. one which resolves a tie by keeping the number obtained first in the input as the first in the output) it can be easily seen that correct final results are obtained.&lt;/span&gt;&lt;/p&gt; &lt;p align="justify"&gt;&lt;span style=";font-family:Helvetica;color:black;"  &gt;As has been mentioned, the sorting of numbers proceeds by sorting the least significant to most significant digit. For sorting each of these digit groups, a stable sorting algorithm is needed. Also, the elements in this group to be sorted are in the fixed range of 0 to 9. Both of these characteristics point towards the use of Counting Sort as the sorting algorithm of choice for sorting on each digit (If you haven't read the description on Counting Sort already, please do so now).&lt;/span&gt;&lt;/p&gt;  &lt;p align="justify"&gt;&lt;span style=";font-family:Helvetica;color:black;"  &gt;The time complexity of the algorithm is as follows: Suppose that the n input numbers have maximum k digits. Then the Counting Sort procedure is called a total of k times. Counting Sort is a linear, or O(n) algorithm. So the entire Radix Sort procedure takes O(kn) time. If the numbers are of finite size, the algorithm runs in O(n) asymptotic time. &lt;/span&gt;&lt;/p&gt;&lt;p align="justify"&gt;&lt;span style=";font-family:Helvetica;color:black;"  &gt;A graphical representation of the entire procedure has been provided in the attached applet. This program takes 8 randomly generated 3 digit integers as input and sorts them using Radix Sort.&lt;/span&gt;&lt;/p&gt;&lt;/h2&gt;&lt;h2&gt;&lt;span&gt;&lt;span style="font-family:TimesRoman;"&gt;&lt;p align="justify"&gt;RADIX-SORT(&lt;i&gt;A,d&lt;/i&gt;)&lt;/p&gt; &lt;p align="justify"&gt;1 &lt;b&gt;for&lt;/b&gt; &lt;i&gt;i&lt;/i&gt; - 1 to &lt;i&gt;d&lt;/i&gt;&lt;/p&gt; &lt;p align="justify"&gt;2    &lt;b&gt;do&lt;/b&gt; use a stable sort to sort Array &lt;i&gt;A&lt;/i&gt; on digit &lt;i&gt;i&lt;/i&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;h1&gt;&lt;span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;br /&gt;&lt;center&gt;&lt;img style="width: 267px; height: 70px;" src="http://www.cse.iitk.ac.in/users/dsrkg/cs210/applets/pics/mergebanner.jpg" nosave="" /&gt;&lt;br /&gt;&lt;img style="width: 251px; height: 52px;" src="http://www.cse.iitk.ac.in/users/dsrkg/cs210/applets/pics/algobanner.jpg" nosave="" /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;The &lt;i&gt;mergesort&lt;/i&gt; algorithm closely follows the divide-and-conquer paradigm. Generally, Merge Sort is considered to be one of the best internal sorting methods. If the data is too large to be accommodated all at once in the memory then one has to use external sorting methods. In external sorting methods small blocks of data are loaded into the memory, sorted using an internal sorting method and written out to a tape or disk. Sorted parts are then merged using variations of the merging algorithm discussed below:&lt;/span&gt; &lt;/div&gt;&lt;p style="text-align: left;"&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    Mergesort(A,p,r){&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        if p &lt;&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            then q &lt;- |(p+ r)/2|&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            Mergesort(A,p,q)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            Mergesort(A,q+1,r)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            Merge(A,p,q,r)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    }&lt;/span&gt;&lt;/b&gt; &lt;/p&gt;&lt;div style="text-align: left;"&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;b&gt;    &lt;/b&gt;To sort the entire sequence A, Mergesort(A,1,length[A]) is called where length[A]=N.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/center&gt;&lt;div style="text-align: left;"&gt;&lt;img style="width: 255px; height: 52px;" src="http://www.cse.iitk.ac.in/users/dsrkg/cs210/applets/pics/explainbanner.jpg" nosave="" /&gt;&lt;br /&gt;  &lt;span style="color: rgb(0, 0, 153);"&gt;Mergesort works by splitting the list into two halves and then sorting each half recursively. Mergesort may be considered to be a tree based algorithm and over here it is executed in a depth first manner. For the above list the algorithm starts by handling the merging of elements as follows (the trend in which the sublists are being considered):&lt;/span&gt; &lt;p&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    1. First, elements 1 and 2 are handled.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    2. Then, elements from 0 through 2 are handled (note the black items indicating the border elements).&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    3. Then, elements 3 and 4 are handled. After this, elements 5 and 6.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    4. Then, elements 3 through 6 are handled.&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    Subsequently, elements 0 through 6 are handled and so on until elements 0 to 14 are handled.&lt;/span&gt; &lt;/p&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    The Merge algorithm takes two sorted lists and merges them to give a sorted list. It assumes the existence of a temporary merge space whose current contents are shown on the upper canvas of the above applet. Mereg takes the the smaller of the first elements of the two lists and places it into the merge space. When either input list is exhausted, the remainder of the other list is copied to the merge space. The sorted sublist is then copied back from the merge space into the appropriate indices.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="width: 348px; height: 52px;" src="http://www.cse.iitk.ac.in/users/dsrkg/cs210/applets/pics/complexbanner.jpg" nosave="" /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    Merge Sort algorithm uses the process of merging two sorted lists recursively to accomplish the sorting of an unsorted list. Firstly, two sorted lists of length M and N respectively can be merged in O(M+N) time. If the lists have the same size N then the time will be O(2*N) or O(N).&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    First, each individual element of the list is considered as a 1-element sorted list. The merge algorithm is then used N/2 times to merge pairs of elements into sorted lists of length 2. This will produce N/2 sorted lists each of length 2. It takes N/2 comparisons to accomplish this. Pairs of 2-element lists are then merged to produce N/4 sorted lists each of length 4. In this case there are N/4 merge operations each taking at most 4 comparisons. This process continues until we have two sorted lists of size N/2 and we merge them in O(N) time. There are log(N) levels of merging. Hence, Merge Sort has a worst-case complexity of O(N*log(N)).&lt;br /&gt;&lt;br /&gt;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!&lt;br /&gt;&lt;/span&gt;&lt;h1&gt;&lt;span&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;HEAPSORT ii&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;&lt;br /&gt;&lt;h2&gt;&lt;span style="color: rgb(0, 0, 0);font-family:helvetica;" &gt;The running time of heapsort is O(N*lgN) i.e. it achieves the lower bound for computational based sorting.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(170, 85, 85);font-family:helvetica;" &gt;HEAP&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:helvetica;color:black;"  &gt; The heap data structure is an array object which can be easily visualized as a complete binary tree.There is a one to one correspondence between elements of the array and nodes of the tree.The tree is completely filled on all levels except possibly the lowest,which is filled from the left upto a point.All nodes of heap also satisfy the relation that the key value at each node is at least as large as the value at its children.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(68, 153, 119);"&gt;Step I:&lt;/span&gt; The user inputs the size of the heap(within a specified limit).The program generates a corresponding binary tree with nodes having randomly generated key Values.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(68, 153, 119);"&gt;Step II:&lt;/span&gt; Build Heap Operation:Let n be the number of nodes in the tree and i be the key of a tree.For this,the program uses operation Heapify.when Heapify is called both the left and right subtree of the i are Heaps.The function of Heapify is to let i settle down to a position(by swapping itself with the larger of its children,whenever the heap property is not satisfied)till the heap property is satisfied in the tree which was rooted at (i).This operation calls&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(68, 153, 119);"&gt;Step III:&lt;/span&gt; Remove maximum element:The program removes the largest element of the heap(the root) by swapping it with the last element.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(68, 153, 119);"&gt;Step IV:&lt;/span&gt; The program executes Heapify(new root) so that the resulting tree satisfies the heap property.&lt;br /&gt;&lt;span style="color: rgb(68, 153, 119);"&gt;Step V:&lt;/span&gt; Goto step III till heap is empty &lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;center&gt;&lt;img style="width: 157px; height: 74px;" src="http://www.cse.iitk.ac.in/users/dsrkg/cs210/applets/pics/quickbanner.jpg" nosave="" /&gt;&lt;/center&gt;  &lt;hr /&gt;&lt;br /&gt;&lt;img style="width: 317px; height: 52px;" src="http://www.cse.iitk.ac.in/users/dsrkg/cs210/applets/pics/algobanner.jpg" nosave="" /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;span style="font-size:130%;"&gt;    &lt;/span&gt;&lt;i&gt;Quicksort&lt;/i&gt; is based on the divide and conquer approach and inspite of its slow worst case running time, it is often the best practical choice for sorting because it is remarkably efficient on the average. The following code describes the algorithm:&lt;/span&gt; &lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    QuickSort(A, p, r){&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        if p &lt;&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            then q &lt;- Partition(A, p, r)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;                QuickSort(A, p, q)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;                QuickSort(A, q+1, r)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    }&lt;/span&gt;&lt;/b&gt; &lt;/p&gt;&lt;p&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;&lt;b&gt;    &lt;/b&gt;To sort an entire array A, the initial call is &lt;b&gt;QuickSort(A, 1, length[A]).&lt;/b&gt;&lt;/span&gt; &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    Partition(A, p, r){&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        x &lt;- A[p]&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        i &lt;- p - 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        j &lt;- r + 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;        while TRUE&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;            do repeat j &lt;- j - 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;                until A[j] &lt;= x&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;               repeat i &lt;- i + 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;                until A[i] &gt;= x&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;               if i &lt;&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;                   then exchange A[i] &lt;-&gt; A[j]&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;                   else return j&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    }&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;/p&gt;&lt;hr width="100%"&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;img style="width: 318px; height: 52px;" src="http://www.cse.iitk.ac.in/users/dsrkg/cs210/applets/pics/explainbanner.jpg" nosave="" /&gt;&lt;br /&gt;  &lt;span style="color: rgb(0, 0, 153);"&gt;The algorithm starts by first performing a scan of the entire list, as indicated by the two black items at the two ends of the list. It attempts then to partition the list. The manner in which this partitioning is done is: First, the pivot element is considered to be the first element of the (sub)list being scanned, i.e., element 0. The high-pointer is shown in green and the low-pointer in blue. Scanning of the (sub)list consists of decrementing the high-pointer and incrementing the low-pointer until A[low-pointer]&gt;= A[pivot] &gt;= A[high-pointer]. As the scan of the (sub)list proceeds, the magnitudes of the list elements are compared with the magnitude of the pivot. First the high-pointer is decremented till it meets an element that is less than or equal to the pivot. Then the low-pointer is incremented till it meets an element greater than equal to the pivot. If the low-pointer is less than the high-pointer, then the elements pointed to by these are swapped else the element pointed by the high-pointer becomes the pivot. Conceptually, the partitioning procedure performs a simple function: it puts elemnts smaller than the pivot into the bottom region of the array and elements larger than the pivot into the top region. Now, the same partitioning approach can be recursively applied to the smaller sublist and also to the larger sublist obtained as a result of the partitioning. Repeated applications of this approach to all sublists generated results in a sorted list.&lt;/span&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;img style="width: 347px; height: 52px;" src="http://www.cse.iitk.ac.in/users/dsrkg/cs210/applets/pics/complexbanner.jpg" nosave="" /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    Quicksort works by partitioning the list into two parts. The first partitioning of the N elements in list positions 0 to N-1, compares and swaps them to produce a pivotal index j such that the elements in positions 0 to j-1 are less than or equal to the pivot which is now in the jth position and those elements in positions j+1 to N-1 are greater. This is accomplished in O(N) time.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    The first partition produces two sublists such that sorting of each of them results in the sorting of the original list. The partitioning technique is applied recursively to each half until the halves reduce to single-element or empty lists.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    Assuming that the list breaks into two halves of equal size, then we have two lists of size N/2 to sort. Each of these has to be partitioned which takes (N/2) + (N/2) = N comparisions. Continuing the same assumption, there will be atmost log(N) splits. This results in the best case time estimate of O(N*log(N)) for quicksort.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;    In the worst case, the partitioning routine produces one region with (N-1) elements and one with only one element (this happens when the list to be sorted is already sorted). This gives a worst case time of O(N^2). However, quicksort takes O(N*log(N)) in the average case.2&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;center&gt; &lt;h1&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;MERGE SORT&lt;/span&gt;&lt;/h1&gt;&lt;/center&gt; &lt;center&gt;&lt;img src="http://www.cse.iitk.ac.in/users/dsrkg/cs210/applets/sortingII/figures/bluemarb.gif" /&gt;&lt;/center&gt;  &lt;h2&gt; &lt;span style="color: rgb(0, 0, 0);font-family:helvetica;" &gt;The &lt;i&gt;mergesort&lt;/i&gt; algorithm is based  on the classical divide-and-conquer paradigm. It operates as  follows:&lt;br /&gt;&lt;br /&gt;&lt;span style="color:green;"&gt;&lt;i&gt;DIVIDE&lt;/i&gt;:&lt;/span&gt; Partition the n-element sequence to be sorted into two subsequences of n/2 elements each.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:green;"&gt;&lt;i&gt;CONQUER&lt;/i&gt;:&lt;/span&gt; Sort the two subsequences recursively using the mergesort.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:green;"&gt;&lt;i&gt;COMBINE&lt;/i&gt;:&lt;/span&gt; Merge the two sorted sorted subsequences of size n/2 each to produce the sorted sequence consisting of n elements.&lt;br /&gt;&lt;br /&gt;Note that recursion &lt;span style="color:orange;"&gt;"bottoms out"&lt;/span&gt; when the sequence to be sorted is of unit length. Since every sequence of length 1 is in sorted order, no further recursive call is necessary. The key operation of the mergesort algorithm is the merging of the two sorted sequencesin the "combine step". To perform the merging, we use an auxilliary procedure Merge(A,p,q,r), where A is an array and p,q and r are indices numbering elements of the array such that dure assumes that the subarrays A[p..q] and A[q+1...r] are in sorted order.It merges them to form a single sorted subarray that replaces the current subarray A[p..r]. Thus finally,we obtain the sorted array A[1..n], which is the solution.  &lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;h2&gt;&lt;span&gt;&lt;span style="font-family:helvetica;"&gt;MERGE SORT (&lt;i&gt;A,p,r&lt;/i&gt;)&lt;br /&gt;1   &lt;b&gt;if&lt;/b&gt; p &lt;&gt;then &lt;i&gt;q&lt;/i&gt;&lt;-- [ (p + r) / 2 ] 3            MERGE SORT(&lt;i&gt;A,p,q&lt;/i&gt;)&lt;br /&gt;4            MERGER SORT(&lt;i&gt;A,q&lt;/i&gt; + 1,&lt;i&gt;r&lt;/i&gt;)&lt;br /&gt;5            MERGE(&lt;i&gt;A,p,q,r&lt;/i&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;h1&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;QUICK SORT&lt;/span&gt;&lt;/h1&gt; &lt;center&gt;&lt;img src="http://www.cse.iitk.ac.in/users/dsrkg/cs210/applets/sortingII/figures/bluemarb.gif" /&gt;&lt;/center&gt; &lt;h2&gt; &lt;span style="color: rgb(0, 0, 0);font-family:TimesRoman;" &gt;&lt;i&gt;Quick sort&lt;/i&gt;,is based on the divide-and-conquer paradigm.It is a sorting algorithm with worst case running time O(n^2) on an input array of n numbers.In spite of this slow worst case running time,&lt;i&gt;quicksort&lt;/i&gt; is often the best practical choice for sorting because it is remarkably efficient on the average : its expected running time is O(nlgn) and the constants hidden in the O-notation are quite small.Here is the three-step divide-and-conquer process for sorting a typical array &lt;i&gt;A&lt;/i&gt;[p . . . r]&lt;br /&gt;&lt;br /&gt;&lt;span style="color:green;"&gt;DIVIDE:&lt;/span&gt;The array &gt;&lt;i&gt;A&lt;/i&gt; is partitioned (rearranged) into two nonempty subarrays &lt;i&gt;A&lt;/i&gt;[p . . q] and &lt;i&gt;A&lt;/i&gt;[q+1 . . r].The index q is computed as a part of this partitioning procedure.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:green;"&gt;CONQUER:&lt;/span&gt;The two subarrays &lt;i&gt;A&lt;/i&gt;[p . . q] and &lt;i&gt;A&lt;/i&gt;[q+1 . . r] are sorted by recursive calls to quicksort.&lt;br /&gt;&lt;br /&gt;&lt;span style="color:green;"&gt;COMBINE:&lt;/span&gt;Since the subarrays are sorted in place, no work is needed to combine them : the entire array &lt;i&gt;A&lt;/i&gt; is now sorted. &lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;h2&gt;&lt;span&gt;&lt;span style="font-family:TimesRoman;"&gt;QUICK SORT (&lt;i&gt;A,p,r&lt;/i&gt;)&lt;br /&gt;1   &lt;b&gt;if&lt;/b&gt; p &lt;&gt;then &lt;i&gt;q&lt;/i&gt;&lt;-- PARTITION(&lt;i&gt;A,p,r&lt;/i&gt;)&lt;br /&gt;3            QUICK SORT(&lt;i&gt;A,p,q&lt;/i&gt;)&lt;br /&gt;4            QUICK SORT(&lt;i&gt;A,q&lt;/i&gt; + 1,&lt;i&gt;r&lt;/i&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2 style="text-align: left;"&gt;&lt;span style=";font-family:Helvetica;color:black;"  &gt; &lt;/span&gt;&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;&lt;b&gt; &lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt; &lt;/b&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7583883832675464864-1566473269589261613?l=youfindeverything.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://youfindeverything.blogspot.com/feeds/1566473269589261613/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://youfindeverything.blogspot.com/2009/04/some-stuff-which-helps-u-sorting.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/1566473269589261613'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/1566473269589261613'/><link rel='alternate' type='text/html' href='http://youfindeverything.blogspot.com/2009/04/some-stuff-which-helps-u-sorting.html' title='Some STUFF which helps U (SORTING TECHNIQUES)'/><author><name>Its_nags_blog</name><uri>http://www.blogger.com/profile/17596584488702584996</uri><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></entry><entry><id>tag:blogger.com,1999:blog-7583883832675464864.post-8132153924314284608</id><published>2009-03-19T11:19:00.000-07:00</published><updated>2009-03-19T11:22:42.089-07:00</updated><title type='text'>POST   Power On Self  Test .. Know your computer...</title><content type='html'>&lt;span style="font-weight: bold;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span style="color: rgb(255, 0, 0); font-style: italic;"&gt;What happens when your computer starts up and when it shuts down&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0); font-style: italic;"&gt;Starting Up&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;What happens when a computer starts? - POST - Power On Self Test&lt;br /&gt;Although there are differences in how each computer actually starts, they all share these basic steps. This example is particularly directed towards Dos and Windows (except where noted).&lt;br /&gt;• The computer performs a test on itself to make sure all components are available and ready. One important part of the first steps is that the registers (the place where data and instructors go in the CPU to be processed) are cleared of any old code. This is the start of the Power-On Self Test or POST test.&lt;br /&gt;• The CPU then gets a memory address from the ROM which where to find the ROM BIOS in order to continue the check.&lt;br /&gt;• The CPU now sends signals on its system bus, the main circuit on the mother board to which all components are attached.&lt;br /&gt;• The clock is checked by the CPU. All computer functions are regulated by this clock, which sends an impulse at a regular interval. It is very much similar to the beating of a bass drum to mark time in music.&lt;br /&gt;• POST tests the memory chips on the video adapter and loads information from the video adapter’s own BIOS into the system BIOS. Sometimes the BIOS codes from slower CMOS are also loaded into RAM. Newer PCs have additional equipment which also have their own BIOS on their own cards. These items, called plug and play also get loaded into the system BIOS.&lt;br /&gt;• The CPU now checks to see if a keyboard is attached, if it is working correctly and if any keys are pressed. Many operating systems permit the user to interrupt the POST test to change the computer’s initial or default behaviors (or environmental variables).&lt;br /&gt;• POST now checks the paths on the bus to the floppy and harddrives (and other devices) to see what storage and peripheral devices are available.&lt;br /&gt;• Once all the components contribute information to the system BIOS, and all other checks have been performed, if the test indicates a problem, such as a corrupted FAT table, the test will inform you and usually offer a change to fix the problem via a setup screen. If there are no problems, the operating system will display some form of greeting: on a Windows machine, you see a large Microsoft logo. On a Macintosh, you’ll read "Welcome to Macintosh." Command-line systems, such as Unix, may show nothing but a prompt.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic; color: rgb(255, 0, 0);font-size:180%;" &gt;To start the computer in safe mode&lt;/span&gt;&lt;br /&gt;You should print these instructions before continuing. They will not be available after you shut your computer down in step 2.&lt;br /&gt;1. Click Start, click Shut Down, and then, in the drop-down list, click Shut down.&lt;br /&gt;2. In the Shut Down Windows dialog box, click Restart, and then click OK.&lt;br /&gt;3. When you see the message Please select the operating system to start, press F8.&lt;br /&gt;4. Use the arrow keys to highlight the appropriate safe mode option, and then press ENTER.&lt;br /&gt;5. If you have a dual-boot or multiple-boot system, choose the installation that you need to access using the arrow keys, and then press ENTER.&lt;br /&gt;Notes&lt;br /&gt;In safe mode, you have access to only basic files and drivers (mouse, monitor, keyboard, mass storage, base video, default system services, and no network connections). You can choose the Safe Mode with Networking option, which loads all of the above files and drivers and the essential services and drivers to start networking, or you can choose the Safe Mode with Command Prompt option, which is exactly the same as safe mode except that a command prompt is started instead of the graphical user interface. You can also choose Last Known Good Configuration, which starts your computer using the registry information that was saved at the last shutdown.&lt;br /&gt;Safe mode helps you diagnose problems. If a symptom does not reappear when you start in safe mode, you can eliminate the default settings and minimum device drivers as possible causes. If a newly added device or a changed driver is causing problems, you can use safe mode to remove the device or reverse the change.&lt;br /&gt;There are circumstances where safe mode will not be able to help you, such as when Windows system files that are required to start the system are corrupted or damaged. In this case, the Recovery Console may help you.&lt;br /&gt;NUM LOCK must be off before the arrow keys on the numeric keypad will function.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 0, 0);font-size:180%;" &gt;Shutting Down&lt;/span&gt;&lt;br /&gt;What happens when you shut down&lt;br /&gt;Shut Down allows you to gracefully shut down Windows by first saving any open files or reminding you to do so, and then deleting any temporary files that have been in use and are no longer needed. The Shut Down option gives you the option to restart your computer, the equivalent of rebooting, either back into Windows or to DOS. You can protect yourself from losing unsaved information by always using Shut Down when leaving Windows and turning off your computer.&lt;br /&gt;To turn off the computer&lt;br /&gt;Click Start, click Shut Down, and then, in the drop-down list, click Shut down.&lt;br /&gt;This action shuts down Windows so that you can safely turn off the computer power. Many computers turn the power off automatically.&lt;br /&gt;To restart your computer&lt;br /&gt;Click Start, and then click Shut Down.&lt;br /&gt;In the What do you want the computer to do drop-down list, click Restart.&lt;br /&gt;As a last resort&lt;br /&gt;Hit Ctrl-Alt-Delete. The Task Manager should come up. Try closing down any open/stalled programs by hitting End Task (and End Task again if the window comes up), and then Shut Down again. If that doesn't work, hit Ctrl-Alt-Delete several times until the computer reboots. As a final resort, hold the power button on the computer in until the computer shuts off.&lt;br /&gt;&lt;br /&gt;&lt;blink style="color: rgb(51, 51, 255);"&gt;&lt;span style="font-size:180%;"&gt;Know Your Computer..&lt;/span&gt;&lt;/blink&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7583883832675464864-8132153924314284608?l=youfindeverything.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://youfindeverything.blogspot.com/feeds/8132153924314284608/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://youfindeverything.blogspot.com/2009/03/post-power-on-self-test-know-your.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/8132153924314284608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/8132153924314284608'/><link rel='alternate' type='text/html' href='http://youfindeverything.blogspot.com/2009/03/post-power-on-self-test-know-your.html' title='POST   Power On Self  Test .. Know your computer...'/><author><name>Its_nags_blog</name><uri>http://www.blogger.com/profile/17596584488702584996</uri><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></entry><entry><id>tag:blogger.com,1999:blog-7583883832675464864.post-2562546833288904967</id><published>2009-03-19T11:03:00.000-07:00</published><updated>2009-03-19T11:17:48.246-07:00</updated><title type='text'>Serial Communication Porgramming In C..</title><content type='html'>&lt;span style="font-family:Arial;"&gt;&lt;span lang="EN-AU"&gt;    &lt;span style="color: rgb(128, 0, 0);"&gt;&lt;i&gt; &lt;/i&gt;&lt;b&gt;&lt;span style="font-size:85%;"&gt;RS232 is the most            known serial port used in transmitting the data in communication and            interface. Even though serial port is harder to program than the            parallel port, this is the most effective method in which the data            transmission requires less wires that yields to the less cost. The            RS232 is the communication line which enables the data transmission by            only using three wire links. The three links provides ‘transmit’,            ‘receive’ and common ground.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="color: rgb(128, 0, 0);font-size:85%;" &gt;..&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;p&gt;   &lt;br /&gt;&lt;marquee&gt; To download the code ..........http://electrosofts.com/serial/&lt;/marquee&gt;&lt;/p&gt;&lt;p&gt;&lt;marquee&gt;&lt;/marquee&gt;&lt;/p&gt;&lt;p&gt;&lt;marquee&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;blink&gt;You find a link for sample code.. download it&lt;/blink&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/marquee&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7583883832675464864-2562546833288904967?l=youfindeverything.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://youfindeverything.blogspot.com/feeds/2562546833288904967/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://youfindeverything.blogspot.com/2009/03/serial-communication-porgramming-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/2562546833288904967'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/2562546833288904967'/><link rel='alternate' type='text/html' href='http://youfindeverything.blogspot.com/2009/03/serial-communication-porgramming-in-c.html' title='Serial Communication Porgramming In C..'/><author><name>Its_nags_blog</name><uri>http://www.blogger.com/profile/17596584488702584996</uri><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></entry><entry><id>tag:blogger.com,1999:blog-7583883832675464864.post-1093144678465571603</id><published>2009-03-19T10:52:00.000-07:00</published><updated>2009-03-19T10:58:28.690-07:00</updated><title type='text'>Computer Register..Play with it....</title><content type='html'>&lt;p&gt;In &lt;a href="http://en.wikipedia.org/wiki/Computer_architecture" title="Computer architecture"&gt;computer architecture&lt;/a&gt;, a &lt;b&gt;processor register&lt;/b&gt; is a small amount of &lt;a href="http://en.wikipedia.org/wiki/Computer_storage" title="Computer storage" class="mw-redirect"&gt;storage&lt;/a&gt; available on the &lt;a href="http://en.wikipedia.org/wiki/CPU" title="CPU" class="mw-redirect"&gt;CPU&lt;/a&gt; whose contents can be accessed more quickly than storage available elsewhere. Most, but not all, modern computer architectures operate on the principle of moving data from main memory into registers, operating on them, then moving the result back into main memory—a so-called &lt;a href="http://en.wikipedia.org/wiki/Load-store_architecture" title="Load-store architecture" class="mw-redirect"&gt;load-store architecture&lt;/a&gt;. A common property of &lt;a href="http://en.wikipedia.org/wiki/Computer_program" title="Computer program"&gt;computer programs&lt;/a&gt; is &lt;a href="http://en.wikipedia.org/wiki/Locality_of_reference" title="Locality of reference"&gt;locality of reference&lt;/a&gt;: the same values are often accessed repeatedly; and holding these frequently used values in registers improves program execution performance.&lt;/p&gt; &lt;p&gt;Processor registers are at the top of the &lt;a href="http://en.wikipedia.org/wiki/Memory_hierarchy" title="Memory hierarchy"&gt;memory hierarchy&lt;/a&gt;, and provide the fastest way for a &lt;a href="http://en.wikipedia.org/wiki/CPU" title="CPU" class="mw-redirect"&gt;CPU&lt;/a&gt; to access data. The term is often used to refer only to the group of registers that are directly encoded as part of an instruction, as defined by the &lt;a href="http://en.wikipedia.org/wiki/Instruction_set" title="Instruction set"&gt;instruction set&lt;/a&gt;. More properly, these are called the "architectural registers". For instance, the &lt;a href="http://en.wikipedia.org/wiki/X86" title="X86"&gt;x86&lt;/a&gt; instruction set defines a set of eight 32-bit registers, but a &lt;a href="http://en.wikipedia.org/wiki/Central_processing_unit" title="Central processing unit"&gt;CPU&lt;/a&gt; that implements the x86 instruction set will often contain many more registers than just these eight.&lt;/p&gt; &lt;p&gt;Allocating frequently used variables to registers can be critical to a program's performance. This action, namely &lt;a href="http://en.wikipedia.org/wiki/Register_allocation" title="Register allocation"&gt;register allocation&lt;/a&gt; is performed by a &lt;a href="http://en.wikipedia.org/wiki/Compiler" title="Compiler"&gt;compiler&lt;/a&gt; in the &lt;a href="http://en.wikipedia.org/wiki/Code_generation_%28compiler%29" title="Code generation (compiler)"&gt;code generation&lt;/a&gt; phase.&lt;/p&gt;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;Categories of registers&lt;br /&gt;&lt;br /&gt;Registers are normally measured by the number of bits they can hold, for example, an "8-bit register" or a "32-bit register". Registers are now usually implemented as a register file, but they have also been implemented using individual flip-flops, high speed core memory, thin film memory, and other ways in various machines.&lt;br /&gt;&lt;br /&gt;A processor often contains several kinds of registers, that can be classified according to their content or instructions that operate on them:&lt;br /&gt;&lt;br /&gt;  * User-accessible Registers - The most common division of user-accessible registers is into data registers and address registers.&lt;br /&gt;  * Data registers are used to hold numeric values such as integer and floating-point values. In some older and low end CPUs, a special data register, known as the accumulator, is used implicitly for many operations.&lt;br /&gt;  * Address registers hold addresses and are used by instructions that indirectly access memory.&lt;br /&gt;        o Some processors contain registers that may only be used to hold an address or only to hold numeric values (in some cases used as an index register whose value is added as an offset from some address); others allow registers hold either kind of quantity. A wide variety of possible addressing modes, used to specify the effective address of an operand, exist.&lt;br /&gt;&lt;br /&gt;&lt;blink&gt;To Know more .....follow the link &lt;a href="http://en.wikipedia.org/wiki/Processor_register"&gt;Processor and Regiters&lt;/a&gt;&lt;/blink&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7583883832675464864-1093144678465571603?l=youfindeverything.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://youfindeverything.blogspot.com/feeds/1093144678465571603/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://youfindeverything.blogspot.com/2009/03/computer-registerplay-with-it.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/1093144678465571603'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/1093144678465571603'/><link rel='alternate' type='text/html' href='http://youfindeverything.blogspot.com/2009/03/computer-registerplay-with-it.html' title='Computer Register..Play with it....'/><author><name>Its_nags_blog</name><uri>http://www.blogger.com/profile/17596584488702584996</uri><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></entry><entry><id>tag:blogger.com,1999:blog-7583883832675464864.post-8456107952837801329</id><published>2009-03-12T08:08:00.000-07:00</published><updated>2009-03-12T08:12:01.309-07:00</updated><title type='text'>Web programming at your finger tips ......</title><content type='html'>Its  a great site for learning web programming........&lt;br /&gt;visit the site .....&lt;a href="http://www.w3schools.com/"&gt;Become Web Programmer  within no time...&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7583883832675464864-8456107952837801329?l=youfindeverything.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://youfindeverything.blogspot.com/feeds/8456107952837801329/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://youfindeverything.blogspot.com/2009/03/web-programming-at-your-finger-tips.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/8456107952837801329'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/8456107952837801329'/><link rel='alternate' type='text/html' href='http://youfindeverything.blogspot.com/2009/03/web-programming-at-your-finger-tips.html' title='Web programming at your finger tips ......'/><author><name>Its_nags_blog</name><uri>http://www.blogger.com/profile/17596584488702584996</uri><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></entry><entry><id>tag:blogger.com,1999:blog-7583883832675464864.post-6921559842355571941</id><published>2009-03-02T10:18:00.000-08:00</published><updated>2009-03-02T10:24:01.762-08:00</updated><title type='text'>Whats Red  Tacton.........</title><content type='html'>&lt;span style="color: rgb(255, 102, 0);font-family:lucida grande;" class="Attention" &gt;RedTacton&lt;/span&gt;&lt;span style="color: rgb(255, 102, 0);font-family:lucida grande;" &gt; is a new Human Area                    Networking technology that uses the surface of the human body                    as a safe, high speed network transmission path..................................&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;to know more...........click&lt;br /&gt;http://www.redtacton.com/en/info/index.html&lt;br /&gt;&lt;br /&gt;&lt;marquee&gt;its_nags_blog@youfindeverything.com&lt;/marquee&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7583883832675464864-6921559842355571941?l=youfindeverything.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://youfindeverything.blogspot.com/feeds/6921559842355571941/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://youfindeverything.blogspot.com/2009/03/whats-red-tacton.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/6921559842355571941'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/6921559842355571941'/><link rel='alternate' type='text/html' href='http://youfindeverything.blogspot.com/2009/03/whats-red-tacton.html' title='Whats Red  Tacton.........'/><author><name>Its_nags_blog</name><uri>http://www.blogger.com/profile/17596584488702584996</uri><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></entry><entry><id>tag:blogger.com,1999:blog-7583883832675464864.post-2662517081708404679</id><published>2009-03-02T10:14:00.000-08:00</published><updated>2009-03-02T10:18:02.480-08:00</updated><title type='text'>CAPTCHA...</title><content type='html'>&lt;span style="font-style: italic; color: rgb(255, 102, 0);"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;Telling Humans and Computers Apart Automatically&lt;br /&gt;&lt;br /&gt;A CAPTCHA is a program that can generate and grade tests that humans can pass but current computer programs cannot. For example, humans can read distorted text &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;........................&lt;br /&gt;&lt;br /&gt;Use this link for more details...........&lt;br /&gt;http://recaptcha.net/captcha.html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7583883832675464864-2662517081708404679?l=youfindeverything.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://youfindeverything.blogspot.com/feeds/2662517081708404679/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://youfindeverything.blogspot.com/2009/03/captcha.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/2662517081708404679'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/2662517081708404679'/><link rel='alternate' type='text/html' href='http://youfindeverything.blogspot.com/2009/03/captcha.html' title='CAPTCHA...'/><author><name>Its_nags_blog</name><uri>http://www.blogger.com/profile/17596584488702584996</uri><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></entry><entry><id>tag:blogger.com,1999:blog-7583883832675464864.post-3207370328888023122</id><published>2009-03-01T03:18:00.000-08:00</published><updated>2009-03-01T03:40:27.339-08:00</updated><title type='text'></title><content type='html'>&lt;marquee&gt;&lt;span style="font-weight:bold;"&gt;The fundamentals of RTOS&lt;/span&gt;&lt;/marquee&gt;&lt;br /&gt;&lt;br /&gt;To most people, embedded systems are not recognizable as computers. Instead, they are hidden inside everyday objects that surround us and help us in our lives. Embedded systems typically do not interface with the outside world through familiar personal computer interface devices such as a mouse, keyboard and graphic user interface. Instead, they interface with the outside world through unusual interfaces such as sensors, actuators and specialized communication links.&lt;br /&gt;&lt;br /&gt;Real-time and embedded systems operate in constrained environments in which computer memory and processing power are limited. They often need to provide their services within strict time deadlines to their users and to the surrounding world. It is these memory, speed and timing constraints that dictate the use of real-time operating systems in embedded software.&lt;br /&gt;&lt;br /&gt;Basic kernel services&lt;br /&gt;&lt;br /&gt;In the discussion below, we will focus on the "kernel" – the part of an operating system that provides the most basic services to application software running on a processor.&lt;br /&gt;&lt;br /&gt;The "kernel" of a real-time operating system ("RTOS") provides an "abstraction layer" that hides from application software the hardware details of the processor (or set of processors) upon which the application software will run. This is shown in Figure1.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Figure 1: An RTOS Kernel provides an Abstraction Layer between Application Software and Embedded Hardware&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In providing this "abstraction layer" the RTOS kernel supplies five main categories of basic services to application software, as seen in Figure 2.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Figure 2: Basic Services Provided by a Real-Time Operating System Kernel&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The most basic category of kernel services, at the very center of Figure 2, is Task Management. This set of services allows application software developers to design their software as a number of separate "chunks" of software -- each handling a distinct topic, a distinct goal, and perhaps its own real-time deadline. Each separate "chunk" of software is called a "task." Services in this category include the ability to launch tasks and assign priorities to them. The main RTOS service in this category is the scheduling of tasks as the embedded system is in operation. The Task Scheduler controls the execution of application software tasks, and can make them run in a very timely and responsive fashion. [Later, we will see the details of how this is done.]&lt;br /&gt;&lt;br /&gt;The second category of kernel services, shown at the top of Figure 2, is Intertask Communication and Synchronization. These services make it possible for tasks to pass information from one to another, without danger of that information ever being damaged. They also make it possible for tasks to coordinate, so that they can productively cooperate with one another. Without the help of these RTOS services, tasks might well communicate corrupted information or otherwise interfere with each other.&lt;br /&gt;&lt;br /&gt;Since many embedded systems have stringent timing requirements, most RTOS kernels also provide some basic Timer services, such as task delays and time-outs. These are shown on the right side of Figure 2.&lt;br /&gt;&lt;br /&gt;Many (but not all) RTOS kernels provide Dynamic Memory Allocation services. This category of services allows tasks to "borrow" chunks of RAM memory for temporary use in application software. Often these chunks of memory are then passed from task to task, as a means of quickly communicating large amounts of data between tasks. Some very small RTOS kernels that are intended for tightly memory-limited environments, do not offer Dynamic Memory Allocation services.&lt;br /&gt;&lt;br /&gt;Many (but not all) RTOS kernels also provide a "Device I/O Supervisor" category of services. These services, if available, provide a uniform framework for organizing and accessing the many hardware device drivers that are typical of an embedded system. [For more information on this, please visit: the device drivers page at the Kalinsky Associates Website]&lt;br /&gt;&lt;br /&gt;In addition to kernel services, many RTOSs offer a number of optional add-on operating system components for such high-level services as file system organization, network communication, network management, database management, user-interface graphics, etc. Although many of these add-on components are much larger and much more complex than the RTOS kernel, they rely on the presence of the RTOS kernel and take advantage of its basic services. Each of these add-on components is included in an embedded system only if its services are needed for implementing the embedded application, in order to keep program memory consumption to a minimum.&lt;br /&gt;&lt;br /&gt;In this paper, we will focus on the basic RTOS kernel services for task management, intertask communication and synchronization, and dynamic memory allocation.&lt;br /&gt;&lt;br /&gt;RTOSs vs. general-purpose operating systems&lt;br /&gt;&lt;br /&gt;Many non-real-time operating systems also provide similar kernel services. The key difference between general-computing operating systems and real-time operating systems is the need for " deterministic " timing behavior in the real-time operating systems. Formally, "deterministic" timing means that operating system services consume only known and expected amounts of time. In theory, these service times could be expressed as mathematical formulas. These formulas must be strictly algebraic and not include any random timing components. Random elements in service times could cause random delays in application software and could then make the application randomly miss real-time deadlines – a scenario clearly unacceptable for a real-time embedded system.&lt;br /&gt;&lt;br /&gt;General-computing non-real-time operating systems are often quite non-deterministic. Their services can inject random delays into application software and thus cause slow responsiveness of an application at unexpected times. If you ask the developer of a non-real-time operating system for the algebraic formula describing the timing behavior of one of its services (such as sending a message from task to task), you will invariably not get an algebraic formula. Instead the developer of the non-real-time operating system (such as Windows, Unix or Linux) will just give you a puzzled look. Deterministic timing behavior was simply not a design goal for these general-computing operating systems.&lt;br /&gt;&lt;br /&gt;On the other hand, real-time operating systems often go a step beyond basic determinism. For most kernel services, these operating systems offer constant load-independent timing: In other words, the algebraic formula is as simple as: T(message_send) = constant , irrespective of the length of the message to be sent, or other factors such as the numbers of tasks and queues and messages being managed by the RTOS.&lt;br /&gt;&lt;br /&gt;Task scheduling&lt;br /&gt;&lt;br /&gt;Most RTOSs do their scheduling of tasks using a scheme called "priority-based preemptive scheduling." Each task in a software application must be assigned a priority, with higher priority values representing the need for quicker responsiveness. Very quick responsiveness is made possible by the "preemptive" nature of the task scheduling. "Preemptive" means that the scheduler is allowed to stop any task at any point in its execution, if it determines that another task needs to run immediately.&lt;br /&gt;&lt;br /&gt;The basic rule that governs priority-based preemptive scheduling is that at every moment in time, "The Highest Priority Task that is Ready to Run, will be the Task that Must be Running." In other words, if both a low-priority task and a higher-priority task are ready to run, the scheduler will allow the higher-priority task to run first. The low-priority task will only get to run after the higher-priority task has finished with its current work.&lt;br /&gt;&lt;br /&gt;What if a low-priority task has already begun to run, and then a higher-priority task becomes ready? This might occur because of an external world trigger such as a switch closing. A priority-based preemptive scheduler will behave as follows: It will allow the low-priority task to complete the current assembly-language instruction that it is executing. [But it won’t allow it to complete an entire line of high-level language code; nor will it allow it to continue running until the next clock tick.] It will then immediately stop the execution of the low-priority task, and allow the higher-priority task to run. After the higher-priority task has finished its current work, the low-priority task will be allowed to continue running. This is shown in Figure 3, where the higher-priority task is called "Mid-Priority Task."&lt;br /&gt;&lt;br /&gt;Of course, while the mid-priority task is running, an even higher-priority task might become ready. This is represented in Figure 3 by "Trigger_2" causing the "High-Priority Task" to become ready. In that case, the running task ("Mid-Priority Task") would be preempted to allow the high-priority task to run. When the high-priority task has finished its current work, the mid-priority task would be allowed to continue. And after both the high-priority task and the mid-priority task complete their work, the low-priority task would be allowed to continue running. This situation might be called "nested preemption."&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Figure 3: Timeline for Priority-based Preemptive Scheduling Examples&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Each time the priority-based preemptive scheduler is alerted by an external world trigger (such as a switch closing) or a software trigger (such as a message arrival), it must go through the following 5 steps:&lt;br /&gt;&lt;br /&gt;  * Determine whether the currently running task should continue to run. If not …&lt;br /&gt;  * Determine which task should run next.&lt;br /&gt;  * Save the environment of the task that was stopped (so it can continue later).&lt;br /&gt;  * Set up the running environment of the task that will run next.&lt;br /&gt;  * Allow this task to run.&lt;br /&gt;&lt;br /&gt;These 5 steps together are called "task switching."&lt;br /&gt;&lt;br /&gt;Fixed-time task switching&lt;br /&gt;&lt;br /&gt;The time it takes to do task switching is of interest when evaluating an operating system. A simple general-computing (non-preemptive) operating system might do task switching only at timer tick times, which might for example be ten milliseconds apart. Then if the need for a task switch arises anywhere within a 10-millisecond timeframe, the actual task switch would occur only at the end of the current 10-millisecond period. Such a delay would be unacceptable in most real-time embedded systems.&lt;br /&gt;&lt;br /&gt;In more sophisticated preemptive task schedulers, the scheduler may need to search through arrays of tasks to determine which task should be made to run next. If there are more tasks to search through, the search will take longer. Such searches are often done by general-computing operating systems, thus making them non-deterministic. Real-time operating systems, on the other hand, avoid such searches by using incrementally updated tables that allow the task scheduler to identify the task that should run next in a rapid fixed-time fashion.&lt;br /&gt;&lt;br /&gt;These two types of timing behavior for task switching can be seen in Figure 4.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Figure 4: Task Switching Timing&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In this figure, we see that for a general-computing (non-real-time) operating system, the task switching time generally rises as a software system includes more tasks that can be scheduled. However, the actual time for a task switch is not the time shown by the dashed red line. Instead, in any given task switch instance, it might be well above or well below the time shown by the dashed red line. The shaded regions surrounding the dashed red line simply show the likelihood of the actual task switch time being that far above or below the dashed red line.&lt;br /&gt;&lt;br /&gt;On the other hand, the horizontal solid green line shows the task switching time characteristic of a real-time operating system. It is constant, independent of any load factor such as the number of tasks in a software system.&lt;br /&gt;&lt;br /&gt;Please note that in some instances, such as the leftmost area of the graph, the task switching time might in special cases be quicker for a general-computing non-real-time operating system, than for a real-time operating system. This does not detract from the appropriateness of a real-time operating system for real-time embedded applications. For, in fact, the term "real-time" does not mean "as fast as possible" but rather "real-time" demands consistent, repeatable, known timing performance. Although a non-real-time operating system might do some faster task switching for small numbers of tasks, it might equally well introduce a long time delay the next time it does the same task switch. The strength of a real-time operating system is in its known, repeatable timing performance, which is also typically faster than that of a non-deterministic task scheduler in situations of large numbers of tasks in a software system. Most often, the real-time operating system will exhibit task-switching times much faster than its non-real-time competitor when the number of tasks grows above 5 or 10.&lt;br /&gt;&lt;br /&gt;Intertask communication and synchronization&lt;br /&gt;&lt;br /&gt;Most operating systems, including RTOSs, offer a variety of mechanisms for communication and synchronization between tasks. These mechanisms are necessary in a preemptive environment of many tasks, because without them the tasks might well communicate corrupted information or otherwise interfere with each other.&lt;br /&gt;&lt;br /&gt;For instance, a task might be preempted when it is in the middle of updating a table of data. If a second task that preempts it reads from that table, it will read a combination of some areas of newly-updated data plus some areas of data that have not yet been updated. [New Yorkers would call this a "mish-mash."] These updated and old data areas together may be incorrect in combination, or may not even make sense. An example is a data table containing temperature measurements that begins with the contents "10 C." A task begins updating this table with the new value "99 F", writing into the table character-by-character. If that task is preempted in the middle of the update, a second task that preempts it could possibly read a value like "90 C" or "99 C." or "99 F", depending on precisely when the preemption took place. The partially updated values are clearly incorrect, and are caused by delicate timing coincidences that are very hard to debug or reproduce consistently.&lt;br /&gt;&lt;br /&gt;An RTOS's mechanisms for communication and synchronization between tasks are provided to avoid these kinds of errors. Most RTOSs provide several mechanisms, with each mechanism optimized for reliably passing a different kind of information from task to task.&lt;br /&gt;&lt;br /&gt;Probably the most popular kind of communication between tasks in embedded systems is the passing of data from one task to another. Most RTOSs offer a message passing mechanism for doing this, as seen in Figure 5. Each message can contain an array or buffer of data.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Figure 5: Intertask Message Communication&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If messages can be sent more quickly than they can be handled, the RTOS will provide message queues for holding the messages until they can be processed. This is shown in Figure6.&lt;br /&gt;&lt;br /&gt;Another kind of communication between tasks in embedded systems is the passing of what might be called "synchronization information" from one task to another. "Synchronization information" is like a command, where some commands could be positive, and some negative. For example, a negative command to a task would be something like "Please don’t print right now, because my task is using the printer." Or more generally, "I want to lock the . . . for my own use only." A positive command would be something like "I’ve detected a cardiac emergency, and I want you to help me handle it." Or more generally, "Please join me in handling . . ."&lt;br /&gt;&lt;br /&gt;Most RTOSs offer a semaphore or mutex mechanism for handling negative synchronization (sometimes called "mutual exclusion"). These mechanisms allow tasks to lock certain embedded system resources for their use only, and subsequently to unlock the resource when they’re done.&lt;br /&gt;&lt;br /&gt;For positive synchronization, different RTOSs offer different mechanisms. Some RTOSs offer event-flags, while others offer signals. And yet others rely on message passing for positive synchronization as well as data passing duties.&lt;br /&gt;&lt;br /&gt;Determinism and high-speed message passing&lt;br /&gt;&lt;br /&gt;Intertask message communication is another area where different operating systems show different timing characteristics. Most operating systems actually copy messages twice as they transfer them from task to task via a message queue. See Figure 6. The first copying is from the message-sender task to an operating system-owned "secret" area of RAM memory (implementing the "message queue"); and the second copying is from the operating system’s "secret" RAM area to the message-receiver task. Clearly this is non-deterministic in its timing, as these copying activities take longer as message length increases.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Figure 6: Message Transfer via Message Queue&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;An approach that avoids this non-determinism and also accelerates performance, is to have the operating system copy a pointer to the message and deliver that pointer to the message-receiver task without moving the message contents at all. In order to avoid access collisions, the operating system then needs to go back to the message-sender task and obliterate its copy of the pointer to the message. For large messages, this eliminates the need for lengthy copying and eliminates non-determinism.&lt;br /&gt;&lt;br /&gt;Dynamic memory allocation&lt;br /&gt;&lt;br /&gt;Determinism of service times is also an issue in the area of dynamic allocation of RAM memory. Many general-computing non-real-time operating systems offer memory allocation services from what is termed a "Heap." The famous "malloc" and "free" services known to C-language programmers work from a heap. Tasks can temporarily borrow some memory from the operating system’s heap by calling "malloc", and specifying the size of memory buffer needed. When this task (or another task) is finished with this memory buffer it can return the buffer to the operating system by calling "free." The operating system will then return the buffer to the heap, where its memory might be used again, perhaps as part of a larger buffer. Or perhaps it may in the future be broken into several smaller buffers.&lt;br /&gt;&lt;br /&gt;Heaps suffer from a phenomenon called "External Memory Fragmentation" that may cause the heap services to degrade. This fragmentation is caused by the fact that when a buffer is returned to the heap, it may in the future be broken into smaller buffers when "malloc" requests for smaller buffer sizes occur. After a heap undergoes many cycles of "malloc"s and "free"s, small slivers of memory may appear between memory buffers that are being used by tasks. These slivers are so small that they are useless to tasks. But they are trapped between buffers that are being used by tasks, so they can’t be coagulated ("glued") together into bigger, useful buffer sizes. Over time, a heap will have more and more of these slivers. This will eventually result in situations where tasks will ask for memory buffers ("malloc") of a certain size, and they will be refused by the operating system --- even though the operating system has enough available memory in its heap. The problem: That memory is scattered in small slivers distributed in various separate parts of the heap. In operating system terminology, the slivers are called "fragments", and this problem is called "external memory fragmentation."&lt;br /&gt;&lt;br /&gt;This fragmentation problem can be solved by so-called "garbage collection" (defragmentation) software. Unfortunately, "garbage collection" algorithms are often wildly non-deterministic – injecting randomly-appearing random-duration delays into heap services. These are often seen in the memory allocation services of general-computing non-real-time operating systems.&lt;br /&gt;&lt;br /&gt;This puts the embedded system developer who wants to use a general-computing non-real-time operating system into a quandry: Should the embedded system be allowed to suffer occasional randomly-appearing random-duration delays if / when "garbage collection" kicks in?... Or, alternatively, should the embedded system be allowed to fragment its memory until application software "malloc" requests to the heap are refused even though a sufficient total amount of free memory is still available? Neither alternative is acceptable for embedded systems that need to provide service continually for long periods of time.&lt;br /&gt;&lt;br /&gt;Real-time operating systems, on the other hand, solve this quandry by altogether avoiding both memory fragmentation and "garbage collection", and their consequences. RTOSs offer non-fragmenting memory allocation techniques instead of heaps. They do this by limiting the variety of memory chunk sizes they make available to application software. While this approach is less flexible than the approach taken by memory heaps, they do avoid external memory fragmentation and avoid the need for defragmentation. For example, the "Pools" memory allocation mechanism allows application software to allocate chunks of memory of perhaps 4 or 8 different buffer sizes per pool. Pools totally avoid external memory fragmentation, by not permitting a buffer that is returned to the pool to be broken into smaller buffers in the future. Instead, when a buffer is returned the pool, it is put onto a "free buffer list" of buffers of its own size that are available for future re-use at their original buffer size. This is shown in Figure 7.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Figure 7: A Memory Pool's Free Buffer Lists&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Memory is allocated and de-allocated from a pool with deterministic, often constant, timing.&lt;br /&gt;&lt;br /&gt;Summary&lt;br /&gt;&lt;br /&gt;Real-time and embedded systems are used in many applications such as airborne computers, medical instruments and communication systems. Embedded systems are characterized by limited processor memory, limited processing power, and unusual interfaces to the outside world. Real-time requirements impose stringent time deadlines for delivering the results of embedded processing.&lt;br /&gt;&lt;br /&gt;RTOS kernels hide from application software the low-level details of system hardware, and at the same time provide several categories of services to application software. These include: task management with priority-based preemptive scheduling, reliable intertask communication and synchronization, non-fragmenting dynamic memory allocation, and basic timer services.&lt;br /&gt;&lt;br /&gt;The issue of timing determinism is important in differentiating general-computing operating systems from real-time operating systems. This issue crops up in many parts of operating system kernels, such as task schedulers, dynamic memory allocation and intertask message communication. While general-computing operating systems often offer non-deterministic services in these areas, fully deterministic solutions are needed for real-time and embedded systems. A number of real-time operating systems implement these solutions in their compact high-performance kernels.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7583883832675464864-3207370328888023122?l=youfindeverything.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://youfindeverything.blogspot.com/feeds/3207370328888023122/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://youfindeverything.blogspot.com/2009/03/fundamentals-of-rtos-to-most-people.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/3207370328888023122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/3207370328888023122'/><link rel='alternate' type='text/html' href='http://youfindeverything.blogspot.com/2009/03/fundamentals-of-rtos-to-most-people.html' title=''/><author><name>Its_nags_blog</name><uri>http://www.blogger.com/profile/17596584488702584996</uri><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></entry><entry><id>tag:blogger.com,1999:blog-7583883832675464864.post-3357966679803796713</id><published>2009-02-21T23:31:00.000-08:00</published><updated>2009-02-21T23:35:37.100-08:00</updated><title type='text'>Nuclear Reactor ......Do u know..</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_i3l111Vg6-o/SaEAIEzk1FI/AAAAAAAAAAU/uaNYSZWdLYA/s1600-h/Picture1.gif"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 303px; height: 158px;" src="http://4.bp.blogspot.com/_i3l111Vg6-o/SaEAIEzk1FI/AAAAAAAAAAU/uaNYSZWdLYA/s320/Picture1.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5305521974748173394" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7583883832675464864-3357966679803796713?l=youfindeverything.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://youfindeverything.blogspot.com/feeds/3357966679803796713/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://youfindeverything.blogspot.com/2009/02/nuclear-reactor-do-u-know.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/3357966679803796713'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/3357966679803796713'/><link rel='alternate' type='text/html' href='http://youfindeverything.blogspot.com/2009/02/nuclear-reactor-do-u-know.html' title='Nuclear Reactor ......Do u know..'/><author><name>Its_nags_blog</name><uri>http://www.blogger.com/profile/17596584488702584996</uri><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/_i3l111Vg6-o/SaEAIEzk1FI/AAAAAAAAAAU/uaNYSZWdLYA/s72-c/Picture1.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7583883832675464864.post-3636787971108589363</id><published>2009-02-21T22:26:00.000-08:00</published><updated>2009-02-23T06:12:09.812-08:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7583883832675464864-3636787971108589363?l=youfindeverything.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://youfindeverything.blogspot.com/feeds/3636787971108589363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://youfindeverything.blogspot.com/2009/02/blog-post.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/3636787971108589363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7583883832675464864/posts/default/3636787971108589363'/><link rel='alternate' type='text/html' href='http://youfindeverything.blogspot.com/2009/02/blog-post.html' title=''/><author><name>Its_nags_blog</name><uri>http://www.blogger.com/profile/17596584488702584996</uri><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></entry></feed>
