Re: OT: How does Linux work?

Ricardo Galli Granada (gallir@atlas-iap.es)
Mon, 7 Jun 1999 15:42:50 +0200 (MEST)


> Could someone please explain how the kernel works? Having just studied
> some of the algorithms used in OS design as part of my CS course, I
> thought it might be nice to see how some of them are actually
implemented

I recommend you the book "Linux Kernel Internals", published by
Addison-Wesley, ISBN 0-201-33143-8

Although is for 2.0 (the second edition) it covers all of these
introductory topics. I bought it because I wanted to change a little
parameters in page cache and buffers algorith and I could not understand
these two concepts (non standard in OS theory)...

> While the sources are fine, the comments lack the depth (IMHO) necessary
> to get a kernel newbie up to speed without the help of a friendly

And out of date....

> * I can see that there are a number of queues used for scheduling, one of
> which uses a round robin scheme. How many are there? What algorithms are
> used? Why were they selected over other choices? How does the SMP code
> affect these algorithms?

Long answer... SCHED_FIFO and SCHED_RR are for "soft real-time"
process. SCHED_OTHER for standard process scheduling. Check
kernel/schedule.c. Scheduling changed a lot in last months.

> * Memory management? How is it made to be architecture independent? How
> does it deal with fragmentation? And swap space? How does the kernel add
> new modules? And release them? (Not really a mm question, that....)

Again, it's difficult to answer in few lines. There is a VMS defined by
the functions in linux/mm. Bascically the VMS consists of a virtual space
address. The memory is divided in pages (4 and/or 8 KB). A virtual address
is converted to a linear address (by the MMU) and the to phys. address
thru a 4 layers page directory. The linear address is divided in four
partes (as in standard "pagination"):

1. Page directory entry (one in x86)
2. Page middle directory entry
3. Page table entry
4. Offset.

All process have two "segments", one is the user segment and the other the
kernel segment. User segment goes up to 0xc0000000 (altought can be
easily changed, I think...), beyond that is the user segment.

All virtual addresses in kernel segment are equal to physical addresses
for all processes.

To be continued in the book....

> * Filing systems. How does the VFS work?

Filing? Firts time I read it... May be file systems?

The VFS is implemented on top of specific file systems format (see
linux/fs), all specific file systems functionalities are implemented
separately. The VFS defines the hierarchy, pipes, simbolic link, sockects,
etc. Basic entity is the i-node (found in any OS book). The systems
amintain cache of directories entries (dentry) for speeding up directory
searchs.

When you read a block (from a read system call, execs or everything
related to block files), it's copied to the page-cache, if the block is
modified, then it's copied (or just moved the pointers?, in 2.0 it was
copied...) to the buffer-cache (note it's the opposite to buffers and
cache theory in most of the OS books).

etc, etc., etc.

--ricardo

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/