Your review is Submitted Successfully. ×

Red Hat Linux

0 Followers
4.2

Summary

Red Hat Linux
May 02, 2003 03:52 PM, 1630 Views
(Updated May 02, 2003)
Why Linux is faster than Windows?

The other day I was just toying around in Windows trying to write a C program

that could generate *ALL* the possible 4 letter words.

The motivation came from the fact that 75% of the people use even no of letters

in their passwords as they are easy to remember. Most sites specify 4 as the

min no of letters, so 4 is a good starting point (comparing with all 4 letter

words is an *extremely* cumbersome procedure for hacking a password however

important it is!! But we as novices cannot think at this stage about more

advanced techniques!!!!)

Coming back to our C program, it is extremely simple. We just have to loop 4

times changing from a to z.

Here is the main part of the program.

int i, j, k, l;

for(i=’a’;i<=’z’;i++)

{

for(j=’a’;j<=’z’;j++)

{

for(k=’a’;k<=’z’;k++)

{

for(l=’a’;l<=’z’;l++)

{

printf(’’%c%c%c%c\n’’, i, j, k, l); //u could also put this into a file.

}

}

}

}

This loop runs 26*26*26*26 times. 456976 times!!!! generating all the possible

4 letter words.

It starts with:

aaaa

aaab

aaac

.

.

..

aaba

.

.

..........

zzzz

I tried to output the words on the monitor using printf(). My machine is a P3

550Mhz with 192MB of RAM with TurboC 3.0( I assure u that it is really really

fast!!! Ask any guys if u doubt!).

Windows slogged through the procedure. I didn’t have the patience to wait till

it finished. I calculated that it takes approximately 676 seconds to output all

the words (Run this program in TurboC and see. The second letter of the word

changes once every second. So, the first letter changes once every 26 seconds

26 times thus making 26*26 = 676 seconds). It takes 11 minutes to run!!

The same program in Linux(I use Red Hat Linux ver6.2), the same printf() statement,

and LO!

The words fly by and it is done in 15 seconds (Just try it in Linux and see!).

Now, how is Linux 44 times faster than Windows?

Linux is moreover a multitasking system and our program gets a small chunk of

CPU time whereas in Windows our program runs unperturbed by others and yet,

Linux just races away. It definitely is a tribute to its unique architecture

and design which makes this possible.

I am finding out the exact reason for this although I have a vague idea.

Meanwhile, a small excercise would help. Instead of generating output on the

screen using printf(), open a file and try to store the words in the file. Now

run both the programs in Windows and Linux. What did u find?

The result will be interesting and throw some light upon why this happens.

Rest of this after I learn exactly about what is happening.

(5)
VIEW MORE
Please fill in a comment to justify your rating for this review.
Post

Recommended Top Articles

Question & Answer