7 ms·
A Heavily-Commented Linux Kernel Source Code [pdf]
- qwsfg 8y agoAppreciate the effort but I’m sorry to say the writing is so not the best I can barely understand some of the sentence
- leommoore 8y agoSuper piece of work. A great way for people to see how Linux works up close. Thanks for sharing.
- Etheryte 8y agoTo briefly understand just how thorough this book is with providing all of the necessary background information and context, the chapter that actually matches the book title (Kernel Code), is chapter 8 and starts on page 319.
- wgerard 8y agoHah, this is amazing! This reminds me of how I used to (and still do, sometimes) read third-party code. For an OS class in college, we had to modify fork (and re-build the kernel) to track how many times a particular process had been forked (and probably some other statistics I'm forgetting at the moment). I remember going through a very similar process for the first time - injecting white space below chunks of code, writing out my own comments, and then using that to figure out how to modify fork. Looking at the author's fork.c comments gave me a feeling of nostalgia. The useful part of course is going through yourself and writing your own comments, but it can be really helpful to start with something like this (and then write your own version of the comments).
- ziroshima 8y agoThe title of the book doesn't seem to do the content justice.
- roguepandaz 8y agoTotally, this should be "a new manual to linux"
- kccqzy 8y agoA new manual to old Linux.
- badfrog 8y agoFor sure. Looks like over 300 pages of background about how Linux works before it even gets to the source code!
- deleted 8y ago[deleted]
- iicc 8y agoKernelVersion 0.12 1117 pages 11.1 MB > The main goal of this book is to use a minimal amount of space or within a limited space to dissect the complete Linux kernel source code in order to obtain a full understanding of the basic functions and actual implementation of the operating system. To achieve a complete and profound understanding of the Linux kernel, a true understanding and introduction of the basic operating principles of the Linux operating system. This book's readership is positioned to know the general use of Linux systems or has a certain programming basis, but it lacks the basic knowledge to read the current new kernel code and is eager to understand the working principle and actual code of the UNIX operating system kernel as soon as possible. Realize the lovers.
- CraftThatBlock 8y ago1117 pages for millions of lines of code doesn't seem too bad, relatively speaking
- badfrog 8y agoOnly ~20k lines. From the book's into: > The current Linux kernel source code amount is in the number of millions of lines, the 2.6.0 version of the kernel code line is about 5.92 million lines, and the 4.18.X version of the kernel code is extremely large, and it has exceeded 25 million lines! So it is almost impossible to fully annotate and elaborate on these kernels. The 0.12 version of the kernel does not exceed 20,000 lines of code, so it can be explained and commented clearly in a book
- CraftThatBlock 8y agoAh my bad. I guess it's still relatively fair overall.
- tomxor 8y ago> The 0.12 version of the kernel does not exceed 20,000 lines of code > The 4.18.X version of the kernel code is extremely large, and it has exceeded 25 million lines Is most of this drivers though? whats left once that's removed?
- Thibaut1 8y agoIf Mozilla wants to make a real difference, they'd study uMatrix and figure out how to create UX that would give that degree of flexibility and power to non-technical users. reply
- deleted 8y ago[deleted]
- entelia09 8y agoThis is a really dumb observation, but my apartment is in the cover photo! (Vancouver BC, Canada) Sorry, I got super excited!
- mimimihaha 8y agoJust went to Vancouver a few months ago and I immediately recognized the aquabus and the background. I was just where the picture was eating the market's beefjerky! Crazy small world.
- entelia09 8y agoTrue! I got so excited when I saw the cover photo.
- deleted 8y ago[deleted]
- xerxex 8y agoSame..I got super excited too!
- Jach 8y agoGreat work. In the preface the author states > At present, people in China are already organizing human annotations to publish books similar to this article. Maybe Chinese programmers will herald an increase in literate programming? Seems like a lot of effort could be saved in back-annotating by just starting the program as a literate one in the first place...
- htfy96 8y agoI think the prevalence of book of commented sources in China partly comes from the way that Chinese big companies interview people - asking a lot of implementation details (especially for DBs), even though in most cases that is useless in daily work (similar to Leetcode questions in US interviews). IMO, literate programming sounds more like software development in Japan, where big companies engineers write high-level specification, then the 1st outsource company models class hierarchy, followed by the 2nd outsource company writing function declarations and comments, eventually implemented by the 3rd outsource company.
- Jach 8y agoHere's my favorite example of a literate program: http://www.pbr-book.org/ http://www.pbr-book.org/ I don't see how such a thing could be constructed using that Japanese way. Though I'm not sure how any software could be constructed in that Japanese way. ;)
- 4j4y 8y agoCan someone redirect me to the section of the book where they explain how exactly kernel manages sockets, binds the port and keep tracks of bound/allocated ports.
- mav3rick 8y agoAn easy way to do this is figure out related syscalls. in this case it will be open (vfs of sockets) accept etc. Grep for those and then you'll see the data structures and the code they use.
- simplicio 8y agoI don't think v.12 (the linux version covered in the book) had sockets.
- fulafel 8y agoYep, it seems 0.98 was the first version to have experimental tcp/ip.
- rst 8y agoOf possible (mostly historical) interest at this point, a similar commentary on a fairly early version of the original Unix kernel, by an Australian cs prof named John Lions -- which was very widely circulated among CS students in the '80s, despite this being technically in violation of AT&T's copyright on the book. It's availble online here: http://www.lemis.com/grog/Documentation/Lions/index.php http://www.lemis.com/grog/Documentation/Lions/index.php Note that the code is written in a very archaic dialect of C, and for hardware that didn't support paging in any form (just swapping). Nevertheless, it was an important introduction for a lot of people at the time, not just to the basics of OS implementation details, but also, how to find your way around a nontrivial sized codebase.
- dmix 8y agoThere's also the great "The Design of the UNIX Operating System": https://www.amazon.com/Design-UNIX-Operating-System/dp/0132017997/ https://www.amazon.com/Design-UNIX-Operating-System/dp/01320... Which is probably less relevant today in terms of directly understanding the implementation. But an interesting and enlightening read. Things were much simpler and fundamental back in the 1980s. It's easier to understand that way. Then layer on top.
- nicklaf 8y agoSlightly more recent: The Design and Implementation of the 4.4 BSD Operating System, which includes some of the Berkeley additions to the kernel, such as TCP/IP and sockets. And then there's xv6 [1], a small Unix running on vx32 from MIT for teaching purposes, full of comments, and available as a booklet that is directly inspired by Lions' commentary on the 6th edition of Unix. I actually agree, though: to really appreciate the classics you should start with (Maurice) Bach. :-P [1] https://pdos.csail.mit.edu/6.828/2018/xv6.html https://pdos.csail.mit.edu/6.828/2018/xv6.html
- nicklaf 8y agoCorrection: xv6 runs on QEMU, not vx32 (although Russ Cox co-authored both xv6 and vx32).
- alexitosrv 8y agoAs other commenters pointed out, this seems like an excellent piece! Is not too often than a one thousands pages book catches my attention, and then after a while I notice I been reading intensely the first few pages wanting for more, and so far only has been some paragraphs about the people involved at the very beginning of Linux!. It seems heavy, but rewarding.
- AnyTimeTraveler 8y agoI wish there was an epub version, so I can read it on an ereader. PDF's aren't nice to read on mine.
- anthonybullard 8y agoIf you can, try Calibre[0]. It can do the conversion and ebook management for you. [0] https://calibre-ebook.com https://calibre-ebook.com
- wuxb 8y agoMany of my friend read the Chinese/original version of it more than a decade ago. It's a dictionary-style book. Unfortunately I never had the patient to read it.
- black-tea 8y agoI'd really like to contribute to the kernel one day. Is this work worth reading for someone like me, or is it more for historical interest?
- xerxex 8y agoUnrelated: I am from Vancouver, BC and it is so coool to open a totally unrelated PDF and see a picture of your neighbourhood.
- efiecho 8y agoI just wanted to read a few pages and save the book for later, but I ended up reading for 10 hours straight, I could not stop. Amazing. You can tell the author has put so much work into this, I'm really grateful that he has released this for everyone to read.
- halfelf 8y agoChinese reader here. When I was in college about 11 or 12 years ago, a previous version of it is considered as one of our textbooks for the Operating System course. Most assignment and homework is about to add or modify some modules into kernel 0.11.
- deleted 8y ago[deleted]
- linkmotif 8y agoThis book looks amazing.