My Tech notes: June 2008

Unix Documentation

Free Online Unix Training Materials

Lists many links to free Unix training materials.

Pointers and Arrays Materials

Pointers and Arrays materials Explained for C beginners

C FAQ and General Questions C Interview Questions

Powered By

Free XML Skins for Blogger

Powered by Blogger

Monday, June 30, 2008

About thttpd - tiny/turbo/throttling HTTP server Configuration

I am newbie for HTTP servers, so I may miss technical words while writing about thttpd web server. I got simple config file from thttpd site
Which is easy for get going, I was in need to put .gif and .jpg images on my pages, which are tested on other webserver boa where all the pages were coming with CSS formating and images. With new installation of thttpd .jpg images and .gif images were not seen and also CSS formating was missing. I discovered about localpat variable from thttpd, one has to give path in configuration file as
to appear images. All images should be read only format. one can use $chmod 644 *.* command to make files read only.
About CSS, just change the format to read only and keep it in www or html folder it starts appearing. well there is not much documentation on the site, hope you will not spend time in digging the things again.

my configuration file looks as below

some nice Features to list about thttpd

thttpd is a simple, small, portable, fast, and secure HTTP server.

It handles only the minimum necessary to implement HTTP/1.1. Well, maybe a little more than the minimum.
See the comparison chart. It also has a very small run-time size, since it does not fork and is very careful about memory allocation.
It compiles cleanly on most any Unix-like OS, specifically including FreeBSD, SunOS 4, Solaris 2, BSD/OS, Linux, OSF.
In typical use it's about as fast as the best full-featured servers (Apache, NCSA, Netscape). Under extreme load it's much faster.
It goes to great lengths to protect the web server machine against attacks and breakins from other sites.
It also has one extremely useful feature (URL-traffic-based throttling) that no other server currently has. Plus, it supports IPv6 out of the box, no patching required.


Sunday, June 29, 2008

Amma Bhagvan Songs/Bhajans Listen from here

Amma Bhagvan Songs/Bhajans Listen from here

Aawo Rai Bhagvan Hame Darshan Dai doo

Lifestraw Named World-Changing Idea

A revolutionary portable drinking filtration system, that will save thousands of lives.
clipped from
Lifestraw, the portable drinking filtration system, nabbed the top honor in the fifth Saatchi & Saatchi Award for World Changing Ideas last Thursday. Worn around the neck and used like a regular straw, Lifestraw claims to filter 99.9999 percent of bacteria and 98.7 percent of viruses using a halogen-based resin.
Saatchi's worldwide creative director Bob Isherwood had nothing but high praise for the company. "I think it's an amazing idea, a world-changing idea," he said.
"You have such a huge proportion of the world's population that can't drink safe water; 6,000 children a day dying from polluted water. To have a straw that you wear around your neck that you can put in contaminated water and turn it immediately into totally safe water is incredible; it is world-changing."
clipped from
The Lifestraw is a little longer than a toilet paper tube
filters are rated for 700 liters of water -- approximately one year's use for a single individual
But perhaps most exciting is the cost: Only 2 dollars US
 blog it

Saturday, June 28, 2008

tcp_keepalive and tcp_retries

The Proc entries to change the timeout values for TCP keep alive and TCP retransmissions.
1) TCP Keep-Alive:
A) tcp_keepalive_time:
The number of seconds a connection needs to be idle before TCP
begins sending out keep-alive probes. Keep-alives are only sent
when the SO_KEEPALIVE socket option is enabled. The default
value is 7200 seconds (2 hours).
This default value can be changed by over writing the proc entry.
example: echo 20 > /proc/sys/net/ipv4/tcp_keepalive_time.
B) tcp_keepalive_probes:
The maximum number of TCP keep-alive probes to send before giving
up and killing the connection if no response is obtained
from the other end. The default value is 9.
Corresponding proc entry to change this value.
example: echo 2 > /proc/sys/net/ipv4/tcp_keepalive_probes
C) tcp_keepalive_intvl:
The number of seconds between TCP keep-alive probes. The
default value is 75 seconds.
Corresponding proc entry to change this value.
example: echo 10 > /proc/sys/net/ipv4/tcp_keepalive_intvl

1) what ever values has taken in examples is the values that we set for USBIP server.
2) Keepalive timer will be kicked off when there is no data transaction on that particular socket.
Cases in which Heart Beat Fails:
The HeartBeat will fail to close the connection when the device has got the data to send or the board
has some response to send. For ISOCH IN devices there will be always some data to send.
2) TCP Retransmissions:
1) TCP retransmission timer will be start as soon as the data has been given to the
IP layer and this timer will be initiated if no ACK is received for this packet.
2) The maximum number of times a TCP packet is retransmitted in established state before giving up
is based on "TCP_RETRIES2" value. The default value is 15, which corresponds to a duration of approximately 13 min, depending on
the retransmission timeout.
3) The interval between two successive retransmissions will be increased exponentially.
(This is based on the RTT value).
4) we can close the connection early by reducing either "Maximum Retransmission time out" or by reducing the "number of retries".
5) we are reducing the number of retries value to "5", which will take approximately 17 seconds to close the connection.
The proc entry to change this value is

Friday, June 27, 2008

Reason for getting less Network performance In Linux-

Packets can be sent out immediately with out a delay if it falls under below reasons and without violation of Nagle’s rules

Ø It is full sized.

Ø Or it contains FIN. (Already checked by caller)

Ø Or TCP_NODELAY was set.

Ø Or TCP_CORK is not set, and all sent packets are ACKed. With Minshall's modification: all sent small packets are ACKed.

The reason for getting less Network performance In Linux- is as follows.

If we have TSO enabled and if we an 8KB of data to be transmitted, In this case what the TCP/IP stack does is as follows.

STEP1: 8KB of data will be copied from Application to the Kernel Buffer

STEP2: Before forming the TCP segment Nagle’s test will be done, this will be done only if TSO_SEGS is equal to 1. This variable tells the HW to how many chunks this 8kB has to be divided while sending it out on the wire. For Example: IF 8KB of data is to be transmitted and if your MSS is 1448 then your tso_segs will be 6 (i.e. 8192 /1448 ~= 6).

STEP3: TCP/IP stack will only give data of length which is multiple of MSS, i.e., if you have 8KB of data and your max segment size is 1448 then in this case the amount of data that has sent out will be calculated as follows

Amount of data to be sent out = 8192 – (8192 mod 1448)

= 8192 – 952

= 7240

As a result of this only 7240 out of 8192 will be sent out, the remaining amount of data that is 952 will be sent out later as new TCP/IP segment. That is it as fall through again from step2.

STEP4: TCP/IP header will formed successfully for the data of length 7240 and it will be given to the Network driver for sending it out on the wire.

This remaining amount of data 952 bytes will be tried to send out, it will start from step2 again; in this case the tso_segs value will be 1, as a result of this it has to go for Nagel’s test. Since it is not a full sized packet nagle’s test will be failed and the packet will be delayed in sending out. As a result of this we were getting less performance in

This can be avoided by committing the Trimming of data in step3 as our H/W as the feature of handling the entire 8k even if the last chunk is less than MSS or this can also be avoided by disabling Nagle’s algorithm.

Nagle’s algorithm can be disabled by using setsockopt

Thursday, June 26, 2008

s.s.c result 2008 | ssc Results Mumbai Pune |

Well friends Today I don't have Horses to run, you can see lot of rush in google to check SSC results of Maharashtra, well I cant hold myself to publish some information about S.S.C Results 2008.
Namaskar Mitarano, Aapal dahvicha Results eathe check kara..
mumbai ssc results, s.s.c results, 2008 results, mahresult MAHARASHTRA EXAMINATION RESULT, 2008 Mumbai: The Maharashtra State Board of Secondary and Higher Secondary Education declared the SSC Examination results on June 26th, 2007 at 11:00 am IST. Check Your Results Now from the links here
Check Your Results Now with some links collection.

MARCH 2008 S.S.C. Results will be declared on 26th June 2008
The Maharashtra Board SSC 2008 results is scheduled to be declared on 26th June 2008 : 1100 Hours

The official websites for the result are:

Website of the Maharashtra State Board of Secondary and Higher School Education

Website of National Informatics Center

Well there is not site called or www.ssc
www.sscresult above are two site for your results.

Tags: ssc results mumbai, ssc results2008, ssc result maharashtra, ssc results pune maharashtra 2008, maharashtra board ssc results
All the best..
ssc results, sscresults, mumbai ssc results, maharashtra ssc, maharashtra ssc results 2008

Wednesday, June 25, 2008

Bottom half and techniques to implement it

Bottom half and techniques to implement

Bottom half" is a generic operating system term referring to the deferred portion of interrupt processing, so named because it represents the second, or bottom, half of the interrupt processing solution. In Linux, the term currently has this meaning, too. All the kernel's mechanisms for deferring work are "bottom halves." Some people also confusingly call all bottom halves "softirqs," but they are just being annoying. "Bottom half" also refers to the original deferred work mechanism in Linux. This mechanism is also known as a "BH," so we call it by that name now and leave the former as a generic description. The BH mechanism was deprecated a while back and fully removed in 2.5. Currently, there are three methods for deferring work: softirqs, tasklets, and work queues. Tasklets are built on softirqs and work queues are entirely different.

Using Softirqs
Softirqs are reserved for the most timing-critical and important bottom-half processing on the system. Currently only two subsystems networking and SCSIdirectly use softirqs. Additionally, kernel timers and tasklets are built on top of softirqs. If you are adding a new softirq, you normally want to ask yourself why using a tasklet is insufficient. Tasklets are dynamically created and are simpler to use because of their weaker locking requirements, and they still perform quite well. Nonetheless, for timing-critical applications that are able to do their own locking in an efficient way, softirqs might be the correct solution.

Tasklets are a bottom-half mechanism built on top of softirqs. As already mentioned, they have nothing to do with tasks. Tasklets are similar in nature and work in a similar manner to softirqs; however, they have a simpler interface and relaxed locking rules. The decision between whether to use softirqs versus tasklets is simple: You usually want to use tasklets. Softirqs are required only for very high-frequency and highly threaded uses. Tasklets, on the other hand, see much greater use. Tasklets work just fine for the vast majority of cases and they are very easy to use.

In most cases, tasklets are the preferred mechanism with which to implement your bottom half for a normal hardware device. Tasklets are dynamically created, easy to use, and very quick. Moreover, although their name is mind-numbingly confusing, it grows on you: It is cute.

Work Queues
Work queues are a different form of deferring work from what we have looked at so far. Work queues defer work into a kernel thread this bottom half always runs in process context. Thus, code deferred to a work queue has all the usual benefits of process context. Most importantly, work queues are schedulable and can therefore sleep.

Normally, it is easy to decide between using work queues and softirqs/tasklets. If the deferred work needs to sleep, work queues are used. If the deferred work need not sleep, softirqs or tasklets are used.

Tuesday, June 24, 2008

Using "cvs add" recursively instead of "cvs import"

You can use "cvs add" command to check-in any big source like linux kernel instead of "cvs import" since the "cvs import" command is creating branches with versions instead of 1.1.

Suppose you want to check-in a large source which is inside a folder name “newfolder”.

To add the folder “newfolder” and it sub-directories into CVS first do

$ find newfolder –type d –print | xargs cvs add

Then to add the files inside the “newfolder” and its subdirectories

$ find newfolder –name CVS –prune –o –type f –print | xargs cvs add

Then we have to commit these into CVS. The “cvs commit” is recursive, so we can give the following command

$ cvs commit –m “comment” newfolder/.

NOTE Please verify if everything has been checked in with these steps by checking out and compiling. I found some files (only which are last) didn’t get added while doing so for kernel. This might be due to very large number of files in kernel source. This is a one time effort and very easy to maintain.


Monday, June 23, 2008

Compassion and forgiveness-Speaking Tree-Spirituality-Lifestyle-The Times of India

I would like to share a childhood story which my father ceremoniously told us children every year. The story is about Tom’s mother.

Tom has a friend, John. One day, John was being chased by the police and he knocks on Tom’s door. “Please hide me”, he pleads, when Tom’s mother opens the door. Tom’s mother lets him in and gives him refuge. When the police, following close on John’s heels, arrive, Tom’s mother peeps out of the window and asks, “Sergeant, what’s the matter?” The policeman asks: “Did you see John? He came this way”. “No sergeant, I haven’t seen John”, she says.

After the police have left, Tom’s mother goes to the backyard, and helps John to escape. She does so, even after the police inform her that John had a massive fight with Tom, in which Tom was killed. John was her son’s killer.

I found the story boring and meaningless in those days. Now it strikes me as inspirational and revealing. Look around, TV serials, movies, fictional thrillers are built around the theme of vengeance, revenge, hate, sex and blood, to some extent even glorifying abysmal characters.

In such an ambience, where even our cultural icons have fallen from grace, this childhood story, of Tom’s mother, taught as a character-building primer, brings fresh perspective. It upholds that rare spiritual quality, forgiveness.

It is not so easy to forgive. It requires great strength of character. What made Tom’s mother forgive John? Inborn compassion? Perhaps compassion and forgiveness go together. One has to be compassionate enough to be able to forgive.

In our lives, we come across awkward and difficult people, who at some time or the other, wilfully cause harm, hurt and emotional damage. Nursing the wound or waiting to ‘hit back’ can only generate negative energy; destroying peace of mind and obstructing clarity of thought and perception.

All those nice, good people who in their desire to be exemplary in the social eye, often claim with a certain degree of vanity, that they have forgiven so and so. The ‘so and so’ may be the boss, the bosom friend or a non-entity. But scratch a bit, and you get the universal statement, ‘It is easy to forgive, but difficult to forget’. If the memory lingers, it means forgiveness is not total. A bit of the hurt, of the wound still remains embedded in the subconscious mind.

In a letter, John Ekundayo wrote: To err is human and to forgive is divine. Forgiveness is seldom practised. Some may say they have forgiven but they often talk to others with bitterness about the wrong done to them. This is not forgiveness, for true grievance is still present.

Bitterness leads to frustration and emotional imbalance. Gurus have been inducting the therapy of forgiveness. This therapy is a sure panacea for peace of mind. It leads to expansion and that awareness brings the joy of love. Forgiveness is a cleansing and a purifying process. It elevates. It is a peace pill. Forgiveness has the power to heal.

Forgiveness is not a one-time affair. It is a continuous process. It is a process which takes the beautiful form of an everyday prayer, where hands are folded , forgiveness sought and forgiveness given and where that all fulfilling connectivity with the universal soul is resumed. Forgiveness makes life beautiful.

Saturday, June 21, 2008

GTalk Translation Bots: Language translation made easy using GTalk language bots

Learn New Languages using GTalk Was chatting with people from other country a problem because you don’t understand their language? Google has the solution, GTalk translates your chat in 24 different languages on he fly with the help of translation bots. It can’t get any better can it?

Here is how you do it…. if you want to translate English to Chinese, add "" to your GTalk account, where "en2zh" is [from language - en - English]2[to language - zh - Chinese], similarly you can translate using 24 different bots.

These bots are named using two-letter language abbreviations, click here to see the list of abbreviations and know what each abbreviation means.

Following are the available bot addresses:

  1. ar2en
  2. de2en
  3. de2fr
  4. el2en
  5. en2ar
  6. en2de
  7. en2el
  8. en2es
  9. en2fr
  10. en2it
  11. en2ja
  12. en2ko
  13. en2nl
  14. en2ru
  15. en2zh
  16. es2en
  17. fr2de
  18. fr2en
  19. it2en
  20. ja2en
  21. ko2en
  22. nl2en
  23. ru2en
  24. zh2en

Start adding the bots of your choice and showoff your multilingual skills…

cool stuff Thanks

Friday, June 20, 2008

New Research On Octopuses Sheds Light On Memory

It is not completely understood how these two systems are interconnected, if at all. However, the organization in the octopus demonstrates a sophistication that was not described yet in other animals. In the octopus, the short-term and long-term systems are working in parallel, but not independently. This is so because the long-term memory area -- in addition to its capacity to store long-term memories -- also regulates the rate at which the short-term memory system acquires short-term memories. This regulatory mechanism is probably useful in cases where faster learning is significant for the octopus' survival in emergency or risky situations.
Research on octopuses has shed new light on how our brains store and recall memory,

Why octopuses?

Octopuses and other related creatures, known as cephalopods, are considered to be the most intelligent invertebrates because they have relatively large brains and they can be trained for various learning and memory tasks, says Dr. Hochner.

Their behavior repertoire and learning and memory abilities are even comparable in their complexity to those of advanced vertebrates. However, they are still invertebrate mollusks with brains that contain a much fewer number of nerve cells and much simpler anatomical organization than that of vertebrate brains. This unique constellation was utilized to tackle one of the most interesting questions in modern neuroscience, which is how the brain stores and recalls memories

 blog it

Tuesday, June 17, 2008

Quick Note on Set-User-Id (SUID) flag

set-user-id (suid) flag set on file
A binary owned by root with set-user-id flag set runs with root privileges, even when an ordinary user invokes it. [2] This is useful for executables (such as pppd and cdrecord) that need to access system hardware. Lacking the suid flag, these binaries could not be invoked by a non-root user.
-rwsr-xr-t 1 root 178236 Oct 2 2000 /usr/sbin/pppd

Using chmod how to set this flag?
A numeric mode is from one to four octal digits (0-7), derived by adding up the bits with values 4, 2, and 1. Omitted digits are assumed to be leading zeros, except that if the first digit is omitted, a directory's set user and group ID bits are not affected. The first digit selects the set user ID (4) and set group ID (2) and restricted deletion or sticky (1) attributes.
The second digit selects permissions for the user who owns the file: read (4), write (2), and execute (1);
the third selects permissions for other users in the file's group, with the same values;
Fourth for other users not in the file's group, with the same values.

chmod 4777 /sbin/ifconfig
sets the set-uid bit
chmod 2777 /sbin/ifconfig
sets the set-gid bit

Monday, June 16, 2008

Set a Guinness World Record

The official date for the launch of Firefox 3 is June 17, 2008. Join our community and this effort by pledging today.

Download Day

google firefox toolbar

Google has updated their Firefox toolbar to make it compatible with Firefox 3 - the browser that is due tomorrow.

Sunday, June 15, 2008

Clean use of rm command

It is very much possible that we delete some useful files by “rm –rf” or rm, One can make use of “alias “command to prevent deleting useful files.

Like $ alias rm="rm -iv"

Whenever one uses rm it will ask for users permission

Ex.$ “rm: remove regular file `test.c'? y”

And also it will give information to user that xyz.c file is deleted,

Ex. $ removed `test.c'

One can add this line alias rm="rm -iv" in .bashrc file so that whenever user login this options will be set as default.

Friday, June 13, 2008

Steel strips Wheels ltd Looks attractive at current levels

S P Tulsian - Looks attractive at current levels

Thursday, June 12, 2008

Ans by Bhagavan for Break Thru State

Q - Bhagwan what should we do for an Erect Body
Posture, which in turn will help us to be in permanent
Break Thru state ?

Bhagwan: a) What you must do is, you must not get up late in
the morning. You should always get up before Sunrise. That is
very very important.

b) Most important part is, always the day must begun, with
gratitude to ones parents.

c) Third is, you should never eat till your full stomach. Always
some space should be left empty, while eating.

d) Then at night, before you sleep, you must always sit down for
a moment and see what all have happened during the day and
how was your mind functioning, what all feelings you had, how you
did you escape from your thoughts, its ugliness and then, try to
confront it for some time and then go to sleep. Then you will find
that you are intensly aware of your ugliness and there will be no
conflict at all. Then there will be dramatically change and you will
be progressing spiritually, as well.

If all these is maintained properly, it is more than enough to put
your body into a beautiful rythem and break thru state.

Sunday, June 8, 2008

Some good links..From last week research

The Function Pointer Tutorials

C Programming forum


Insight/GDB debugger for Windows on Linux

Linux News group

Sample questions

Insight FAQ from redhat

Kgdb- bug report All questions answered here

Friday, June 6, 2008

Residential phone number lookup

Get the registered name and current address on the phone number.
 blog it

Wednesday, June 4, 2008

What Is Android?

On November 5th, 2007 leading technology and wireless companies came together to announce the future development of a truly open platform for all kinds of mobile devices - Android. Leading this development are Google Inc, T-Mobile, Intel, HTC, Qualcomm, Motorola along with many other companies under the umbrella of the Open Handset Alliance - a global alliance between technology and mobile industry leaders.

The Open Handset Alliance’s common goal is to foster and develop a new breed of innovation for mobile devices allowing a far better user experience than today’s current mobile platforms. The OHA will provide a far greater degree of openess that will enable developers to work and collaborate in ways never before seen, Android will greatly improve and speed up the process in which new and innovative mobile services are development and made available to the end user.
The image “” cannot be displayed, because it contains errors.

Tuesday, June 3, 2008

Dynamic linking and static linking

*   A dynamicllay linked executable is smaller than its statically
counterpart. It saves disk and virtual memory, as libraries
are only mapped in to the process when needed.

* All executables dynamically linked to a particular library share
a single copy of the library at runtime. The kernel ensures that
libraries mapped into memory are shared by all processes using
them. This provides better I/O and swap space utilization and
in sparing of physical memory, improving overall system throughput.

* Dynamic linking permits easy versioning of libraries. New libraries
can be shipped; once installed on the system, old programs
automatically get the benefit of the new version without needing
to be relinked.

* Finally (much less common), dynamically linking allows users to
select at runtime which library to execute against. It's possible
to create library versions that are tuned for speed, or for
memory efficiency, or that contains extra debugging information,
and allow the user to express a preference when execution takes
place by substituting one library file for another.

Monday, June 2, 2008

How to Replace a Switch-Statement

// The four arithmetic operations ... one of these functions is selected
// at runtime with a swicth or a function pointer

float Plus (float a, float b) { return a+b; }
float Minus (float a, float b) { return a-b; }
float Multiply(float a, float b) { return a*b; }
float Divide (float a, float b) { return a/b; }

// Solution with a switch-statement - specifies which operation to execute
void Switch(float a, float b, char opCode)
float result;

// execute operation
case '+' : result = Plus (a, b); break;
case '-' : result = Minus (a, b); break;
case '*' : result = Multiply (a, b); break;
case '/' : result = Divide (a, b); break;

cout << "Switch: 2+5=" << color="#000080">// display result

// Solution with a function pointer - is a function pointer and points to
// a function which takes two floats and returns a float. The function pointer
// "specifies" which operation shall be executed.

void Switch_With_Function_Pointer(float a, float b, float (*pt2Func)(float, float))
float result = pt2Func(a, b); // call using function pointer

cout << "Switch replaced by function pointer: 2-5="; // display result
cout << result << endl;

// Execute example code
void Replace_A_Switch()
cout << color="#0000ff">"Executing function 'Replace_A_Switch'" << endl;

Switch(2, 5, /* '+' specifies function 'Plus' to be executed */ '+');
Switch_With_Function_Pointer(2, 5, /* pointer to function 'Minus' */ &Minus);

Important note: A function pointer always points to a function with a specific signature! Thus all functions, you want to use with the same function pointer, must have the same parameters and return-type!


This is nice one..

int main()
int a,b;
printf("Enter two numbers\n");
printf("a=%d, b=%d\n",a,b);
printf("after swap a=%d b=%d\n",a,b);
return 0;

Sunday, June 1, 2008

how to find sum of digits in C?

int n,i,sum=0,r;
printf("enter the value");