The OutRider Computing Journal

A free monthly column for users, administrators, programmers and hobbyists who use UNIXlike Operating Systems.

Home | Search | Site Map | Feedback | Subscriptions


WHYTO: Revisiting Kernel Source

Awhile back, OutRider presented a wishy washy column on Understanding the Source. Some recommended ways to better understanding how a GNU/Linux operating system works and presumably how many other UN*X Operating Systems probably work.

But we never said why.

For most, sheer hack curiosity is enough, but I have a case in point that may illuminate some reasons to sift through kernel guts and organs.

The Case of task_struct()

Don't ask me why, because now I cannot remember, but I suddenly became obsessed with how a process works within UN*X. It was probably related to a work issue at the time, but that is neither here nor there. So I picked up my kernel books, GNU/Linux apps books and my plethora of HOW-TO's, Unleashed series and whatever else I had about and started digging only to ultimately end up at the source code.

I was snooping around the kernel source when I found this C structure called task_struct() - all over the place. Hmmm - this must have something to do with tasks. I won't go into the details of it suffice to say it was a series of pointers and variables to other structures and variables which give information about the running task. For example, here is a quick list of a few attributes it points to from within the structure:

Interesting no? So I poked around, found all of these other places and in general - had a good time.

Flash Forward a few weeks. I am crawling around Hewlett Packard's documentation and white paper' site looking for something totally unrelated. Since I couldn't find it, I was determined to find something useful while I was there - and I did - a brief white paper on the task structure in HP-UX. Of course no source code was provided >;-(

Now, let's roll back again, this time a year before I used the task_struct. I am trying to test out process accounting on a HP-UX 10.20 server. I activate it but the system tells me I have to have security auditing as well so I say - "sure go right ahead". Well, luckily it was a test machine. It pretty much destroyed what last shreds of performance that machine had. I couldn't figure out why. I ended up dropping the whole project.

Flash back forward to the HP web site and here is what it said about HP-UX task data structures:

The process structure has the following information:

and if process accounting and auditing is turned on:

I immediately made the connection. The thought of all of those additional data structures tied to each and every process structure plus STDIN, STDERR and STDOUT - well - after I did the math it was pretty phenomenal. Actually as I look back I am surprised the box didn't thrash and crash before I shut it off.

The Allusions of Understanding

Armed with the knowledge of how one Operating System works can ultimately prepare you for combating all sorts of other Operating Systems, especially ones of similar nature. In this case, I was able to address a problem that I would not have figured out on my own until a little later, granted, I would have known without browsing the GNU/Linux source code since I know how to program in C - but I had a much clearer conception of the problem.


(C) Copyright 1999, 2000 OutRider
See OutRider Policies Document for more Information.
Modified on $Date: 1999/10/01 12:56:06 $ by Jason Fink ( jrf@diverge.org )