Monday, February 15, 2010

Inspiring Words ......

You know a dream is like a river, ever changing as it flows.
And a dreamer's just a vessel that must follow where it goes.
Trying to learn from what's behind you and never knowing what's in store
makes each day a constant battle just to stay between the shores.
And I will sail my vessel 'til the river runs dry.
Like a bird upon the wind, these waters are my sky.
I'll never reach my destination if I never try,
So I will sail my vessel 'til the river runs dry.
Too many times we stand aside and let the water slip away.
To what we put off 'til tomorrow has now become today.
So don't you sit upon the shore and say you're satisfied.
Choose to chance the rapids and dare to dance the tides.






-Garth Brooks, song The River co-written with Victoria Shaw

Sunday, December 27, 2009

Merry Christmas wishes from President ....

Hi All,

While enjoying my holidays in my hometown bhopal, one thing that i found has not changed at least in my house is the continuously running AIR(All India Radio), when my father is at home. Interestingly the manner in which they present you the news has also not changed much.

On the day of Christmas one doubt that i always had as a child about "All India Radio" and "Doordarshan News" again cropped up.

On the day of Christmas a lady during the news time in AIR said ... "President, Vice-President, Prime Minister has wished every one Merry Christmas". Now the thing i never heard them saying so in their own voice, even in Doordharshan news which does the same. And only AIR and Doordharshan get their wishes, not any other news channel like NDTV or Aaj Tak.

Now i have never understood how do these important ppl convey these wishes to AIR, the possible options i could think of were:

1. They them selves called AIR help-desk, or news editor and told them we would like to wish "merry christmas" (or diwali,holi,new year .. etc), to the world so please convey the message, especially through AIR so that every one knows that they care.
2. They tell their PA to do the same.

3. But the most possible solution i c is they must have told AIR and Doordharshan in Advance that no matter who the President or Prime Minister, and no matter what the festival is, when ever their is any celebration of national importance, make sure these people are wishing "Happy festival" to everyone.

If you dont believe me .... check out the news on 1st Jan 2010 on AIR, when "President, Vice-President and Prime Minister will wish us all "Happy New Year" ..... :)

Friday, November 13, 2009

its my life ....

below is a good cartoon i found on web ... telling u every one has its own style of living ... hope u all also like it ...

Sunday, November 1, 2009

A real multi agent system problem .... !

5 pirates of different ages have a treasure of 100 gold coins.

On their ship, they decide to split the coins using this scheme:

The oldest pirate proposes how to share the coins, and all pirates remaining will vote for or against it.

If 50% or more of the pirates vote for it, then the coins will be shared that way. Otherwise, the pirate proposing the scheme will be thrown overboard, and the process is repeated with the pirates that remain.

Assuming that all 5 pirates are intelligent, rational, greedy, and do not wish to die, (and are rather good at math for pirates) what will happen?

what is Mr Shah Birth date .. ?

Yesterday in a party, I asked Mr. Shah his birthday. With a mischievous glint in his eyes he replied. "The day before yesterday I was 83 years old and next year I will be 86."
Can you figure out what is the Date of Birth of Mr. Shah? Assume that the current year is 2000.

Thursday, October 29, 2009

"hello world" program without a main() function

Hi Friends,

This short article is on request of my friend Viswanath who wanted to run a C program without main() function on his computer .

I have done this on Ubuntu OS , with the simple Linux module , taken form guide :
"The Linux Kernel Module Programming Guide"


note : Aim of this article is not to teach you how to write a Linux kernel module , but to simply write a C program which runs on your Linux system and prints "Hello world", without use of main() function

only thing worth mentioning is "output" from "printk" goes to by default "/var/log/messages" , so your "hello world" would be printed their instead of terminal.


Step 1 :

create a file named hello-1.c with code given below :

/*
* hello−1.c − The simplest kernel module.
*/
#include /* Needed by all modules */
#include /* Needed for KERN_INFO */
int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}

//code ends here


Step 2 :

create a Makefile , with following code : (ie a file name Makefile )

//code starts here

obj-m += hello-1.o

all:
"press tab"make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
"press tab"make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

//code ends here

Step 3:

from terminal with sudo premission run following command :

$ make

you will see output like given below if successful :


hostname:~/lkmpg−examples/02−HelloWorld# make
make −C /lib/modules/2.6.11/build M=/root/lkmpg−examples/02−HelloWorld modules
make[1]: Entering directory `/usr/src/linux−2.6.11'
CC [M] /root/lkmpg−examples/02−HelloWorld/hello−1.o
Building modules, stage 2.
MODPOST
CC /root/lkmpg−examples/02−HelloWorld/hello−1.mod.o
LD [M] /root/lkmpg−examples/02−HelloWorld/hello−1.ko
make[1]: Leaving directory `/usr/src/linux−2.6.11'
hostname:~/lkmpg−examples/02−HelloWorld#


Step 4:


to load your module run command :

$ insmod ./hello-1.ko

now your module should be added in the module list of kernel. For checking this type following command :

$ cat /proc/modules

the first entry should be hello-1 , and thats your module.

Step 5:

to unload your module use following command :

$ rmmod hello-1

Step 6 :

wondering where did your printk " Hello world 1." and " Goodbye world 1."

went just and check the file :

$ cat /var/log/messages

towards the end you will find the two entries ,

Hello world 1.
Goodbye world 1.

Thats it.
Thanx for reading.

Note: if you really want to understand how all this worked please go through the article "The Linux Kernel Module Programming Guide" , which is easily available on web.

What does Compiling / upgrading Linux kernel mean ?

Hey Everyone,

Through this short article i would like to share a concept which most of you might find very trivial , but i myself took sometime to understand it and wanted to share the same if some of you might have felt the same .

Before we proceed lets revise revise four basic concepts very quicky ...

What is an Operating System .. ?

Wikipedia says : The Linux kernel is an operating system kernel used by the Linux family of Unix Like Operating Systems. The Linux kernel was initially conceived and created by Finnish computer science student Linus Torvalds in 1991.

What is a Kernel .. ?

Wikipedia Says : In computing, the 'kernel' is the central component of most computer operating systems it can be thought of as the bridge between application and the actual data processing done at the hardware level. The kernel's responsibilities include managing the system's resources (the communication between hardware and software components).

What is Linux .. ?


Wikipedia Definition : Linux is a generic term referring to Unix-like computer operating systems based on the Linux kernel.

Definition from linux.org : Linux is a free Unix-type operating system originally created by Linus Torvalds with the assistance of developers around the world. Developed under the GNU General Public License , the source code for Linux is freely available to everyone.

What is Linux Kernel .. ?

Wikipedia says : The Linux kernel is an operating system kernel used by the Linux family of Unix Like Operating Systems. The Linux kernel was initially conceived and created by Finnish computer science student Linus Torvalds in 1991.


So from above four question and answers its clear that :

Operating System and Kernel are not the same thing .

So get it clear .... Linux OS and Linux Kernel are not the same thing.

Therefore Ubuntu, fedora , Suse all these are operating Systems based on Linux kernel , started by our friend Linus Torvalds . So when you install any one of these you basically install a full blown Operating System ready to serve you , and this OS internally may be using any Linux Kernel release e.g 2.6.28 or 2.6.30 or .... any other .. they just keep coming with modifications and updates .

Now suppose you have installed a Ubuntu OS on your system with default kernel release 2.6.28 , now after few days you go to www.kernel.org and find the latest kernel release is 2.6.30 , which is ofcourse supposed to be better that 2.6.28 in one or the other aspect.

So now you want to use latest kernel , so now you download the lastest kernel code and " compile that C program code" .

note: to know how to comile kernel code serach web or better look for article written by me : compiling linux kernel 2.6.30

So now after rebooting the system , with new kernel , what difference do you see ....

Practically nothing : Your user name , password are still the same , your wallpaper is still the same , your user setting reamains the same .

Only thing that had changed and is not visible is "Linux Kernel" version , running in background and managing all your resources and processes .

You can check the running version by running following shell command :

$ cat /proc/version

so in the end , just keep in mind Linux based OS and Linux Kernel are two completely different things ... and changing them is also different.

Like you can change your OS from Ubuntu to fedora and both of the may still be using same Linux Kernel 2.6.30 .

Thanx for reading .

About Me

My Photo
Hi Friends, I am Samarth currently pursuing my Masters degree in Information Technology from International Institute of Information Technology ,Bangalore .