Kernel Fun (Day 1)

{This is a part of a series on my interactions with linux kernel . I will make entry about every days proceedings.  }

I decided to play with kernel a bit. Actually I was playing with shell scripting, and wanted to learn some system calls. After browsing a bit , I realized it would be easier to learn if i start messing up with kernel. And in the process , I might be able to add one or two new words in my cv 🙂

Getting the code

1 . First I installed virtualbox . Installation was very easy , just keep accepting all the default stuffs.

2. Then I started the virtual machine with a ubuntu image .

3. After installing ubuntu I installed git (It is a svn used for managing kernel source)

sudo apt-get install git

4. Next I moved to my home directory and downloaded the latest kernel source by issuing the following command

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git

5. You may use pull to update the code
git pull

So that completes downloading and setting up environment . Tomorrow will try to compile it.

Limiting memory use to a % of total memory

One of my friend was very annoyed with his application. He thinks there is one unknown process which occasionally eats up total memory available. So he was asking , if there is some way to limit memory usage to a predefined portion of total available memory. I googled , and most people say this is indeed a very very bad idea. Applications should not measure ram and occupy. If ten applications are coded, such that they occupy 1/4th of ram, and they are ran together, then crash is inevitable. In the process I learnt a way to get memory related stats on a unix system. Just parse the file at /proc/meminfo


 

{Used cat to see meminfo}

Otherwise  a system wide setting can also be changed using ulimit .  For more info read here. {Read the warnings at bottom first.}