出品 | OSC開源社區(ID:oschina2013)
《Exploring the internals of linux v0.01》是一篇解讀 Linux 內核第一版開源代碼的文章。此文今天在 Reddit 和 Hacker News 都沖上了熱門。
原文:https://seiya.me/blog/reading-linux-v0.01
文章介紹道,Linux 內核首個開源版本 (v0.01) 的體積非常小,僅包含 10,239 行代碼。如果除去注釋和空行,只剩下 8,670 行。正因它足夠小,所以方便理解,是了解類 UNIX 操作系統內核內部結構的良好起點。
部分要點 & 有趣的冷知識:
- v0.01 總共包含 66 個 system call,如下:access acct alarm break brk chdir chmod chown chroot close creat dup dup2 execve exit fcntl fork fstat ftime getegid geteuid getgid getpgrp setsid getpid getppid getuid gtty ioctl kill link lock lseek mkdir mknod mount mpx nice open pause phys pipe prof ptrace read rename rmdir setgid setpgid setuid setup signal stat stime stty sync time times ulimit umask umount uname unlink ustat utime wAItpid write
- 針對 i386 進行了深度硬編碼
- Linux 內核最初的名字為 "FREAX"# Makefile for the FREAX-kernel.
-
5 行代碼實現 Kernel panic
volatilevoidpanic(constchar* s)
{
printk("Kernel panic: %snr",s);
for(;;);
}
- Linus 當時沒有 8MB RAM 的機器 * For those with more memory than 8 Mb - tough luck. I've * not got it, why should you :-) The source is here. Change * it. (Seriously - it shouldn't be too difficult. ...
Linux v0.01 源代碼下載:https://cdn.kernel.org/pub/linux/kernel/Historic/linux-0.01.tar.gz