Is there a simple explanation for kernels/OSs?

OK, let me give some quick personal background so people who attempt to answer this can decide how much they need to “talk down” to me for understanding.

I understand microprocesser architecture. I have done microprocessor programming (assembly language flash ROM programming). I have also had some experience with higher level programming languages. Old Commodore 64 BASIC and most recently (as some of you have helped me!) learning Java with the intent to move onto C++.

But the computer remains a mystery to me. What exactly is an OS? Is it like a virtual processor? That is the analogy I currently have— that the OS is the go-between for the µP and the rest of the hardware. Is this correct?

IF this is correct, can someone explain to me exactly what the kernel is? a cursory Google search didn’t help me understand anything about kernels if I didn’t already know what they were.

Kernel Os is the right-hand man under General Protection Fault. Both of them take orders from General Error, who always seems to be reading my hard drive for some reason.

Now, please stand by for some real answers.

Quoting from O’Reilly’s “Running Linux”:

An OS includes a kernel and a lot of utilities to make the system usable like a filing system, etc. Some argue that Linux should properly be called GNU/Linux because Linux is the kernel and it uses a collection of Gnu utilities on top of that to make it usable. The same applies to Windows: all the OS functions like file system browsers, copy commands, etc. that a user actually interacts with are all utilites built on top of the Windows kernel.

An OS is responsible for virtual memory management and process synchronization, among other things. You might want to look at books by Andrew Tanenbaum (I think that’s his name, and will check later)–I think he had a bit of influence on the design of Linux, and his books are pretty standard (AFAIK) for university-level OS courses.

The definition of Operating System changes with respect to the architecture. For example, the Linux kernel supplies abstraction layers to user space software that allows them all to share resources such as disks, network cards and so on. The kernel takes care of allotting CPU time and memory space to all the running processes. In other words, it’s pretty minimalistic. The user generally never interacts with the kernel directly, he only uses the software which “asks” the kernel to do things for it. In this sense, the kernel and OS are very different things. The OS consists of the kernel plus all the Stuff required for the user to be productive, which may or may not include a graphical interface. Indeed, the line between OS and simple application software can be blury on Unix type systems. (Just ask 10 people whether or not X11 is part of the OS.)

On the other hand, something like the MacOS (pre-OS X) is built graphically from the ground up. The kernel includes the graphical interface.

Here is a quotation from Neal Stephenson’s excellent essay, In the Beginning was the Command Line:

I think that sums it up fairly well.

Just a few points:

In terms of layers, the OS generally lies between the hardware and the user programs. The user programs (your word processor, web browser, etc.) should not access the hardware directly. They tell the OS what they want done: Read a file, display something on the screen, find the status of the sound card, etc., and the OS provides those and many other services.

Many novices wonder “Why have an OS at all?” The answer also helps to understand the purpose of an OS. In the earliest days of PCs (and even on an old PDP-11 micro I once used) there was no OS at all. Just a boot loader to read in the program and run it. That meant that each program had to include code to read a character from the keyboard, access the floppy drive, or whatever was needed by that program. That was what made Basic interpreters popular then. The programmer programmed in Basic and the interpreter provided the low level OS-like routines. A primitive and harsh way of doing things. Real OSes (which date back to the 50’s) take care of this for the programmer. (And for the user, who can call the OS directly via file copy commands and such.)

The kernel is a minimal set of OS routines that just do the basics and in turn call other OS routines as needed to handle the more complicated stuff. In the old MS-DOS days the kernel was IO.SYS, MSDOS.SYS and COMMAND.COM (the latter sometimes thought of as just being the kernel alone).
BTW, concerning ulrafilter’s OS book recommendation:
Warning: Most OS books are incredibly badly written. They routinely state things true that are in fact known to be false (for decades now), etc. I know, I’ve been working, trying to correct these guys, for over 20 years and it has failed miserably. They include my research, they cite my papers, but they surround it with the same old garbage that my papers point out is garbage. I have seen junior OS profs go ballistic discussing the crummy options they have in selecting textbooks.

FtG
(And Friedo adds some good stuff while I was previewing!)

Know of any good ones?

I do not know of a good one. But I mainly know about the “best sellers” and ones aimed at more specific topics in my area. (I get freebies from publishers and I browse colleagues shelves, etc., when I get a chance.) There could very well be a great OS book out there, but since it so different from the “standard” texts it doesn’t get promoted.

I have a long time friend who is quite big in the OS community and she uses a collection of papers in her undergrad OS course, no text. If she doesn’t think there’s a suitable book, it probably isn’t there.

Some people use OS specific texts: Basically a Linux or WinNT manual. These don’t really provide concepts.

It’s an unfortunate situation. The first “modern” OS books in the 70’s were terrible. No one wants to publish a book that is radically different from them 'cause it won’t sell, etc. Some people consider some of Tannenbaum’s books radical but he isn’t at all. It’s that conservative of a community. It is a classic case of Kuhn’s “The Old Guard has to (literally) die off before the new ideas are accepted.”

FtG

      • A OS is a set of lists, with a small group of functions that maintain the lists. If you “understand” basically at the Turing level how a computer works, then, that’s all there is to it, really. That’s it. Just lists, and lists of lists. And short binary “functions” the processor uses for reading from and writing to the lists.
        Bummer, huh?
        ~
  • Like this: You want a Windows-like OS, on a PC-like computer.
    *So list #1 is a list of CPU commands that tells the CPU how to progress through the list of running programs (list #5 here). This contains the core functions/rules for how to read and write data to the other lists (for instance, if a program is exited, any windows associated it have to be disposed of). This has to be separate from the “running program” list, because the running program list will change, but this will not.
    *List #2 is how the entire memory is enumerated. All the possible memory locations directly acessible to the system have to be numbered differently, in order that any one point can be directly accessible. All the different areas of memory are numbered, too. (This usually will include standard stuff you don’t need drivers for, like HD’s, floppys, CDs and RAM. Other devices have their own access programs that manage their own data transfer, such as ZIP drives.) For instance, you have a PC with floppy A:, HD’s C: and D:, CD-R E: and 256 megs of RAM, listed in that order. This list will list the starting addresses of the instructions of how to find each of these, in a file on the master HD. The actual hard-wired addresses of each depend exactly on the motherboard’s technical standard (or lack thereof).
    *List #3 is all the important byte addresses of each system device, such as where the OS starts, where it stops, and the highest memory address. -The OS needs to use at least a bit of room on each device for itself (for a local directory), and it won’t function properly if this data is overwritten. This is the famed “General Protection Fault”.
    *List #4 is all the hardware addresses -each piece of hardware gets one address to read (commands) from, and write data to. (-Yea, it’s simple, just like that!
    Actually, this is a list of lists of supported hardware. So for example, you’d need a “hard drive list”, a “floppy drive” list, a “CD drive” list, and so on. Each entry in all these lists is the starting address of another list, that gives the addresses of the available functions of each device. This way each drive can have any number of its own functions, or even share functions where appropriate [such as with multiple identical drives]-))
    *List #5 is a list of currently running programs. -Actually, it is a list of beginning addresses of the memory that those programs are using. (another list of addresses) The CPU progresses through this list to multi-task.
    *List #6 is a list of “windows” corresponding to the running programs in list #3. (another list of addresses)
    *List #7 is a table, containing all the information describing how to “build” a window: for instance, its size, its border type, its button arrangement, its title, etc, the entries corresponding to list #4. (more addresses)
    *List #8 is an indice list into list #9, of window drawing functions: each entry here references another location (in list #9) that tells how to draw a part of a window, such as a “close” button. The functions aren’t all the same length, so an intermediate list has to be used to prevent wasting space between drawing functions. All your “normal” drawing stuff goes here, like fonts and such. (more addresses)
    *List #9 is the drawing functions themselves. (CPU drawing functions)
    *List #10 is a list of the starting addresses of all the other lists. This has to be put somewhere the CPU can easily find it, like the boot sector. The CPU goes to the boot sector, finds this list, then finds list #1 and goes to that, and starts running from there.
    ~
    And that’s it really. The BIOS does basic tests on the hardware, you just need to know the address on the master HD it will put your CPU to start. Download a free ASM utility and get cracking, it shouldn’t take but a week or so for you to get something up and running.
    <8^P - MC
      • Oops! -After a few hours sleep it occurs to me that as I typed, I was dreaming again: regarding the example in List #1, ideally, you would want the OS witten so that no resources could ever get stranded; such as the famed Windows memory leaks, where a program “reserves” space in RAM and then gets exited without “unreserving” the space in RAM, and then no other program can use that RAM space until the PC is rebooted. Under Windows, much of the resource management is subject only to individual program control.
        -It is easy to alter a simple Windows program to strand an “uncloseable” program window on-screen, which takes up space in RAM.
        -It shouldn’t be. - MC