21 February 2006

The Unix Kernel

(This is a subheading of Unix-3; earlier post on kernels)

Disclaimer: I am a student of this subject, and not an expert. Please check sources listed at the end of this post.

The kernel is the part of the operating system that interacts directly with with the hardware. It serves to manage computer memory & processor resources and basic input-output (BIOS). A modern kernel is also expected to manage the multithreading abilities of today's microprocessors.

Communications between the kernel and the programs running on the computer are system calls; these include commands such as "open file," "writing to file," "obtain information about file," "terminate process," "change priority of process," and so on. The system calls essentially define standard compliance, and all implementations of Unix System V have compatible system calls. However, the internals (programs that actually execute these system calls on behalf of the kernel) may be quite different from Unix version to version.

Once crucial difference between Unix kernels and those of other programs like MS-DOS is that the former does not give applications direct access to system resources (printers, memory, etc) [*]. Instead, applications have access to the system call interface, which is Unix's version of the API.

Another crucial distinction is that, while [the majority of] OS's treat all input/output (I/O) devices as different classes of objects, Unix treats them as all as files [*]. To flatten matters out even more, Unix files are all identical in format. Only script inside the file actually specifies what format it's supposed to conform to. This is somewhat interesting because, as I mentioned, all I/O devices (including disk drives) are files. Another point I ought to mention, and will surely mention again, is that Unix is all about terseness.* So the root directory in Unix is written as a slash "/." Semantically, I suppose it would be more accurate to say that the root is actually nameless—the slash occurs after the file name, which is why those of you with a Unix account will access it under the path /usr/bin/. All of the files under the root directory are referenced in relation to it, even though they might be on different physical drives from each other.

This is significant for the kernel because it simplifies the organization of system calls. It does present a problem, however, for legacy Unix kernels because of the recent explosion in the number of device types a system is expected to connect to. There is also some concern for Unix users that the kernel is itself another file, and is vulnerable to editing errors. That is why people learning how to use Unix are compelled to learn so much about it.
* Terseness in Unix: system commands generally, not to mention file naming conventions, are examples of Unix's legendary laconicism. I've known people who were utterly enraptured by it, and others who hate it with a passion. Generally speaking, those who hate it are older and are people with whom I've discussed it recently; those who love it are younger and told me about this back in the late 1980's.
RESOURCES: The Art of Unix Programming, Eric Raymond: esp. "The Elements of Operating-System Style"; Wikipedia entry; "Rethinking /dev and devices in the UNIX kernel," Poul-Henning Kamp, FreeBSD Project 2002;

ONLINE TUTORIALS: "Unix for Web developers," eXtropia tutorials; "UNIX Tutorial for Beginners," University of Surrey, Guildford, UK; "Unix System Administration Independent Learning," USAIL;

BOOKS: UNIX: the Complete Reference, by Kenneth Rosen, Douglas Host, James Farber, & Richard Rosinski—Tata McGraw-Hill edition 2002

Labels: , , ,

0 Comments:

Post a Comment

<< Home