04 November 2008

Mini Project #3 - Process Tree in Linux

Mini Project #3 - Process Tree in Linux

A process is a program in execution together with a state comprising of open files, environment variables and pending signal. In any operating system, a process is normally created by another process. And the process dies when it calls the system call "exit" explicitly or implicitly. Each process has relationships with other processes in the system. This mini project is to write a simple tool that dumps the process tree - how one process is related to other processes. The output can be text which can be parsed by other tools.

You have come up with the format and information that should be displayed which can be of use to the users of the tool. The information can be like state, total run time, files opened and pending signals. Here the key is the performance and hence implementing this kernel module or system call is recommended. Initially, the focus should be on getting the information not the formatting the data. Later, the output from the kernel module or system call can be read by parsers implemented in Java or other programming languages.

After implementing this mini projects, the team members will get a good understanding on Linux kernel, important data structures and they can continue to learn Linux on their own by just walking through Linux source code. If you are interested, please submit your intent through email.

All the mini-projects hosted here are open and free. Free to learn and free to be modified. This is a attempt to help students community. This mini project and all other mini projects help you understand the respective areas and gives you insight by doing it.

Two best books on Linux Kernel Internals

Linux is one of most popular kernels around and it will continue to be the darling till foreseeable future. Linux is not Unix. Though it has taken the best practices from Unix and it never pulled off in pushing back some of the concepts which were not good. Today, Linux is growing to be one of the best server operating systems, embedded operating systems and also powering super computers. Linux powers watches to super computers and over a period of time, it has become platform independent.

Over a period of time many Linux distributions evolved and many of the distributions are widely deployed. If you find any Linux geeks and find that they will already have a distribution on their own. Interesting the surprise is not so much for people who stop with user space. If Linux user space surprises you and it is good for you to stop there if you have a weak heart. The surprise will be more and excitement will be more when you start see what is inside, leave alone understanding it. When you start smelling the code, you start understanding it.

But for dull guys like me, having a book or two that explains about Linux kernel indeed help a lot. After hovering Internet for Linux kernel books, I found two books. FYI, this happened three years back. The first book that caught my eyes was "Linux Kernel Development" and the second one was "Understanding the Linux Kernel". I preferred to buy Linux Kernel Development simply because it was thin and I thought it would be easy read. I deferred buying the second book. By decision of buying Linux Kernel Development was right. This books teaches the readers about Linux kernel and importantly you do not need to be a kernel developer. If you have fair programming experience and logical reasoning, you will understand almost 95% of the book. The author, Robert Love explanations and commentary was so lucid and one can practically validate the learning by hacking Linux source code. If you are starting to learn Linux, I recommend you to soon come to kernel space and it will be great experience if you start your journey with this great book.

After reading the chapters on Process, scheduling and system calls in Linux kernel development, you will certainly get a burning desire to hack Linux. That is where the second book comes handy. The second book "Understanding the Linux Kernel" is an handbook with numerous pages with lot of details about the implementation and design decisions. You will find a lot of code taken from Linux source code and explained side by side. My recommendation would be read the chapters in the first book and follow it up with the corresponding chapters in the second book. Then first open the source code and validate what authors say. The learning and understanding will be effective if you complete at least one cycle - First book, second book and source code. You understanding will improve when you repeat the cycles number of times.

Be one of the many guys who smells what Linux kernel is, it is lifetime opportunity.