• Immutable Page
  • Info
  • Attachments

KernelSafari

Don't want to start hacking yet, but like to take apart the kernel to see how it works ?


And here is a beautiful ascii-art representation of kernel facilities/structure:

userspace process <-------------------------------------------------------------------------------------+
        |                                                                                               |
        +-------> files/directories                                                                     |
        |               |                                                                               |
        |               +-------> file -> VFS -> filesystem -> file_operations table -> function        |
        |               |                                                                               |
        |               +-------> directory(file) -> VFS -> filesystem -> file_operations -> function   |
        |                                                                                               |
        +-------> character/block devices                                                               |
        |               |                                                                               |
        |               +-------> file -> VFS -> device table -> char/block functions -> driver         |
        |               |                                                                               |
        |               +-------> file -> VFS --------------> filesystem --------------> devfs driver   |
        |                                                                                               |
        +-------> pipes/sockets                                                                         |
        |               |                                                                               |
        |               +-------> system call -> socket -> layer-4 -> layer-3 -> NIC driver             |
        |               |                                                                               |
        |               +-------> descriptor -> buffer -> descriptor -----------------------------------+-------+
        |                                                                                                       |
        +-------> system calls                                                                                  |
        |               |                                                                                       |
        |               +------> interrupt -> system call handler -> sys_syscall() -> do_syscall()              |
        |                                                                                                       |
        +-------> virtual memory                                                                                |
        |               |                                                                                       |
        |               +-------> malloc() -> mmap() -> VMA -> KMA -> page manager -> hardware memory           |
        |               |                                                                                       |
        |               +-------> malloc() -> mmap() -> VMA -> KMA -> kswapd -> swap manager -> block device    |
        |                                                                                                       |
        +-------> process management                                                                            |
        |               |                                                                                       |
        |               +-------> system call(fork) -> system call handler -> sys_fork()/sys_clone() -----------+
        |               |                                                                                       |
        |               +-------> system call(kill) -> system call handler -> sys_kill() -----------------------+
        |               |
        |               +-------> IPC -> system call(ipc) -> system call handler -> sys_ipc() ------------------+
        |                                                                                                       |
        +-------------------------------------------------------------------------------------------------------+

Anybody want to draw this over? ;)

-Brad

Reorganized it to take less horizontal space.

-Renaud

Fixed it so you can view it (removed the equals)

-Izomorfix

Made it more understandable using a bit more whitespace, but I'm not sure if it's still right (see, not understandable enough).

-Devin Torres

Hi, I have some problems with the meaning of the arrows:

  • The arrows starting from userspace process seem to be calls to functions in "packages" (i.e. files/directories, ...). Now what is the connection between sys_ipc() and user space?

  • Under files/directories seems to be an interface file (the interface for userspace processes) which calls functions in the VFS interface. This calls functions in the filesystem interface and so on. Is this always some type of call under all "packages"?

  • What does the connection between sys_...(), descriptor and userspace process mean? Maybe arrows at the "junctions" ("+") might help as I otherwise have to go up to userspace proecess to now the direction to take. (for example like this: "{descriptor


>+


}") (fix me - sorry for this, but "Help" doesn't seem to work right now)

A legend is missing with an explanation of the arrows and the nodes (they are more likely self-explanatory). Distinction between different types of nodes (if there are different types) might help (or make things messy).

Something more specific: If a process wants to read from a file it calls something under files/directories or character/block devices? Do functions from files/directories call character/block devices? I'm just wanting to improve the diagram. So if answers are not helpful just ignore the question :)

-Flo

Tell others about this page:

last edited 2006-03-05 10:35:17 by 203-109-214-139