[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] Programming - Where to start (Pretty Long)



Hi Barry,

> Anyway, part of my problem is, I am much more function over form.  I
> don't like making pretty web-based interfaces.  I like the database
> stuff, etc.  I really want to delve down into
> systems/kernel/driver/translator type of stuff.

Systems programming is a huge domain of its own. The Hurd, Linux and
the BSDs are a very nice playground if you want to get some exposure.

> I am reading "The Art of Computer Programming" as was suggested by
> many on the debian-user list and a few suggested that I check out
> the Hurd.

The Art of Computer Programming is perhaps not the right introductory
material to this kind of stuff though (unless you're really masochistic)

If you want to do some kernel or library hacking, you need some
experience with the interfaces that user programs use. For example:
how do you open a file? What is mmap(2)? How do you fork a new process?
What about signal handling? How does the shell do redirection?
What are pipes and how are they used? Basically, you need a broad
overview of the POSIX interface of Unix and Unix-like systems to
userland programs.

One of the classical books (though somewhat old) is still:
Advanced Programming in the UNIX Environment, by W. Richard Stevens.

There are also books specializing in a subset of the POSIX
interfaces, like e.g.: "Practical UNIX Programming: A Guide to
Concurrency, Communication, and Multithreading" by Kay A. Robbins
and Steven Robbins, to give just one example.

After you've got some working knowledge of the userland <-> kernelland
interfaces, you can start peeking under the hood. The obvious way
to do this, is to examine the source code of the C library (glibc
in GNU/{Linux,Hurd} and BSD libc on {Free,Open,Net}BSD). Just try
to understand how a basic operation works. For instance, have a
look at the open(3) library call [don't get too fancy with fork(),
you'll need to understand the ELF format before; leave that for later
and try simple functions first]. This function will do some
housekeeping, then invoke the kernel (monolithic case) or a
file translator (the Hurd) through a system call (a trap in
the monolitic case, an IPC/RPC in the Hurd).

In any case, follow manually the code path from a function call
in your program through libc down into the kernel or translators.
It is incredibly instructive to do so.

To understand what's going on in the Kernel (let's assume for
a moment that we're talking about monolithic kernels like
Linux and *BSD), you need some background in OS design. The design
of the BSD kernels (at least the BSD 4.4 codebase used in all
BSD kernels) is to be found in "The Design and Implementation of
the 4.4 BSD Operating System" by Marshall Kirk McKusick et. al.
This is a high level overview of the Kernel internals. For Linux,
similar books exists as well.

Special case TCP/IP: This is complex code, but it has been
masterfully illustrated and explained in: "TCP/IP Illustrated,
Volume 2: The Implementation" by Gary R. Wright and W. Richard
Stevens. This is a huge book, but it'll give you an exact feeling
of how the standard TCP/IP stack is implemented.

As a microkernel based OS, the Hurd is a special case. You need
to get some feeling about distributed and kernelized systems. One
good book, which also mentions Mach, is "Distributed Operating Systems"
by Andrew S. Tanenbaum. This is again an architecture-type of book
that doesn't get down to real code, but you need to understand
its contents nonetheless.

The Hurd itself is based upon Mach (at least until we've made a lot
of progress on l4-hurd@) . Unfortunately, there is no
good textbook about Mach. You may want to try the obsolete
"Programming under Mach" by Boykin, Kirschen, Langerman, LoVerso,
which contains some good code examples; but be advised that it
covers only Mach 2.5 (think of Mach+BSD combined). Mach 3.0 (and
gnumach which is based upon it) has a different interface and
things are quite different there. You're pretty much on your
own here.

> Barry deFreese
> Debian 3.0r1 "Woody"
> Debian Testing "Sarge"
> Registered Linux "Newbie" #302256 - Debian Developer Wannabe

Happy Hacking!

-Farid.

-- 
Farid Hajji -- Unix Systems and Network Management.
http://www.farid-hajji.net/address.html
Quoth the Raven, "Nevermore." --Edgar Allan Poe.



Reply to: