Tuesday, October 30, 2007

Some Chanakya Quotes

Chanakya (Indian politician, strategist and writer, 350 BC 75 BC)

"A person should not be too honest.
Straight trees are cut first
and Honest people are victimised first."

"Even if a snake is not poisonous,
it should pretend to be venomous."

"The biggest guru-mantra is:
Never share your secrets with anybody. !
It will destroy you."

"There is some self-interest behind every friendship.
There is no Friendship without self-interests.
This is a bitter truth."

"Before you start some work, always ask yourself three questions - Why am I doing it, What the results might be and Will I be successful.
Only when you think deeply and find satisfactory answers to these questions, go ahead."

"As soon as the fear approaches near,
attack and destroy it."

"Once you start working on something,
don't be afraid of failure and don't abandon it.
People who work sincerely are the happiest."

"The fragrance of flowers spreads only in the direction of the wind.
But the goodness of a person spreads in all direction."

"A man is great by deeds, not by birth."

"Treat your kid like a darling for the first five years. For the next five years, scold them.
By the time they turn sixteen, treat them like a friend. Your grown up children are your best friends."

"Books are as useful to a stupid person as a mirror is useful to a blind person."

"Education is the best friend.
An educated person is respected everywhere.
Education beats the beauty and the youth."

Wednesday, October 24, 2007

Quiz Again

CODC Quiz is one of the Annual Event, which I always love to attend. Many Chocos to win, T-Shirts. Today, I won 2 Chocos and 1 T-Shirt.

I'm not much strong in Networking Area, my favorite areas are OS, esp. Unix/Linux.

Choco Question-1:

It is abt "Nicolas Writh" - A Turing Award winner who wrote Pascal PL, and many books on DS and Algos.

Choco Question-2:

It is a simple question, the answer is "Friend Class", you can guess the question.

One Summa Question:

Who wrote TeX - Donald E.Knuth (Thala...)

And The Great T-Shirt Question is....

What is the name "Unix" Stands for:

It is named as a pun on Multics, which some Bell guys like Ken Thompson, Dennis Ritchie, Brian Kernighan were working. Multics is an Multi-users operating system, funded by GE. But Multics was huge flop, so they came with an new operating system which developed on PDP-11 and using C Language, it is been ported to other hardwares.

Guna answered 2 Choco Questions.

I still remember My Senior Dhinesh, asked this same question in the Ragging Session while I was doing my MCA in MKU.

Totally, it is an awesome experience.

Friday, October 19, 2007

C/C++/Unix/Linux Help

This is for some my friends who want to learn C, C++ and Unix/Linux Programming including C/C++ pointers, templates, STL, IPCs like Semaphore, Pipes/FIFO, MQs and Pthreads.

Just leave your questions on comments session, I will try to answer them to the best of my knowledge.

Start Music ...

Pthread Synchronization w/o Mutex

Today, when I was just going through some Pthreads concepts. Pthreads are very useful for writing multi-threaded application, it has more advantages over multi-tasking.

Here is my program of Pthread Synchronization without using Mutex

#include < pthread.h>
#include < stdlib.h>
#include < unistd.h>

int mx=0;

void *thread_function1(void *arg) {
int i;

for ( i=0; i<10; i++) {
while(mx==2);
mx=1;
printf("Thread says hi-%d!\n",i);
mx=2;
}
pthread_exit(0);
}


void *thread_function2(void *arg) {
int i;

for ( i=0; i<10; i++) {
while(mx==1);
mx=2;
printf("Thread says hello-%d!\n",i);
mx=1;
}
pthread_exit(0);
}

int main() {

pthread_t mythread1, mythread2;
pthread_attr_t my_attr;
char *str;

if(pthread_create( &mythread1, NULL, thread_function1, NULL) ) {
printf("error creating thread1.");
abort();
}
if(pthread_create( &mythread2, NULL, thread_function2, NULL) ) {
printf("error creating thread2.");
abort();
}

mx=1;

if ( pthread_join (mythread1, NULL) ) {
perror("error joining thread.");
abort();
}
if ( pthread_join (mythread2, NULL) ) {
perror("error joining thread.");
abort();
}
printf("Pthread Joing Success\n");

exit(0);

}


The main disadvantage of this code, is polling, the while() statement in the 2 threads. When you use Mutex/semaphore, this polling which consume CPU time, can be avoided. I don't know the implementation of Pthread Mutex. But we can try to analyze through time command in the next session.

Next Meet Pannalam....

Tuesday, October 16, 2007

ha ... ha... ha... Stalin

Stalin, What is the use of getting a book, if you are not going to read it ?

See, When ever you read that book, I have asked my Sister to beat you up and give you some important jobs in the Kitchen. Don't waste your precious time by reading other's blobs, go... go... go to Kitchen.

Some Dialogues from 300
=======================
.....
Persian Messenger: What makes this woman think she can speak among men?
Gorgo: Because only Spartan women give birth to real men.
....
Persian messenger: This is blasphemy! This is madness!
Leonidas: [He looks at Gorgo, who nods to him] Madness? THIS IS SPARTA!!! [kicks the screaming messenger down the well]
....
Persian Emissary: No, not slaves. Your women will be slaves. Your sons, your daughters, your elders will be slaves, but not you. By noon this day, you will all be dead men! A thousand nations of the Persian Empire descend upon you. Our arrows will blot out the sun!
Stelios: [grins] Then we will fight in the shade.
....
[The Spartans hold up their shields as a flurry of Persian arrows blot out the sun.]
Leonidas: Persian cowards.
[Suddenly, Astinos begins laughing.]
Stelios: What the hell are you laughing at?
Astinos: You had to say it!
Stelios: What?
Astinos: "Fight in the shade!"
....
Xerxes: Yours is a fascinating tribe. Even now, you are defiant, in the face of annihilation, and the prescence of a god. Imagine what horrible fate awaits my enemies when I would gladly kill half of my own men for victory.
Leonidas: And I would die for any one of mine.
.....
Stelios: It is an honor to die by your side.
Leonidas: It is an honor to have lived at yours.
....
Xerxes: There will be no glory in your sacrifice. I will erase even the memory of Sparta from the histories. Every piece of Greek parchment shall be burned. Every Greek historian and every scribe shall have their eyes put out and their tongues cut from their mouths. Why, uttering the very name of Sparta or Leonidas will be punishable by death. The world will never know you existed at all!
Leonidas: The world will know that free men stood against a tyrant, that few stood against many. And that before this battle is over, even a god-king can bleed.
....

Courtesy: 300 Wikiquote


Today's Quote

=============
"The starting point of achievement is desire. Keep this constantly in mind. Weak desires produce weak results, just as a small amount of fire produces a small amount of heat."

- Napoleon Hill

Monday, October 08, 2007

Language Agnostic Books

I have consolidated some of the Language Agnostic Books from the Computer Zen Link.

List of Language Agnostic Books:
================================
1. Code Complete
2. Pragmatic Programmer
3. Programming Pearls
4. Refactoring
5. Design of the UNIX Operating System
6. Design Patterns
7. The Practice of Programming
8. The Structure and Interpretation of Computer Programs
9. The Mythical Man Month
10. Object Oriented Analyis and Design

The Tao of Programming

In the beginning was the Tao. The Tao gave birth to Space and Time. Therefore Space and Time are Yin and Yang of programming.

Programmers that do not comprehend the Tao are always running out of time and space for their programs. Programmers that comprehend the Tao always have enough time and space to accomplish their goals.

________________________________________________________________________________

The Tao gave birth to machine language. Machine language gave birth to the assembler.

The assembler gave birth to the compiler. Now there are ten thousand languages.

Each language has its purpose, however humble. Each language expresses the Yin and Yang of software. Each language has its place within the Tao.

But do not program in COBOL if you can avoid it.

________________________________________________________________________________

Once the Grand Master Turing dreamed that he was a machine. When he awoke he exclaimed:

"I don't know whether I am Turing dreaming that I am a machine, or a machine dreaming that I am Turing!"

________________________________________________________________________________

A master was explaining the nature of Tao of to one of his novices. "The Tao is embodied in all software - regardless of how insignificant," said the master.

"Is the Tao in a hand-held calculator?" asked the novice.

"It is," came the reply.

"Is the Tao in a video game?" continued the novice.

"It is even in a video game," said the master.

"And is the Tao in the DOS for a personal computer?"

The master coughed and shifted his position slightly. "The lesson is over for today," he said.
________________________________________________________________________________
Link: Tao of Programming

Memory for Programmers

The links to

Memory for Programmers Part-I

Memory for Programmers Part-II

________________________________________________________________________________

The Joel Test

The Joel Test

1. Do you use source control?
2. Can you make a build in one step?
3. Do you make daily builds?
4. Do you have a bug database?
5. Do you fix bugs before writing new code?
6. Do you have an up-to-date schedule?
7. Do you have a spec?
8. Do programmers have quiet working conditions?
9. Do you use the best tools money can buy?
10. Do you have testers?
11. Do new candidates write code during their interview?
12. Do you do hallway usability testing?