from Hacker News

Brushing up on operating systems and C programming

by shbhrsaha on 1/21/18, 12:13 AM with 85 comments

  • by teeray on 1/21/18, 2:36 AM

    Can anyone recommend an intermediate to advanced C book? I feel like most C material I've been exposed to in the past lacks what a modern C project should have when it comes to best practices, code organization, build tools (should I use make for this, cmake, where does autotools fit? what about clang vs gcc?), linters (valgrind?), testing, etc. I recognize that much of this falls outside of C, but all of these tools seem like things C projects routinely grapple with.
  • by tony on 1/21/18, 5:39 AM

    I recommend (by most expensive, to free):

    Marshall Kirk McKusick's FreeBSD Intensive Code Walkthrough: https://www.mckusick.com/courses/advdescrip.html

    Also, The Design and Implementation of the FreeBSD Operating System (2nd Edition): https://www.amazon.com/Design-Implementation-FreeBSD-Operati...

    Thirdly: grab a copy of FreeBSD (or OpenBSD) and (a) set it up in VirtualBox and SSH it into locally (b) use an old ThinkPad. Then grab the source code of the base system. Build and install it. And start reading code of things like usr.bin/grep/grep.c

  • by partycoder on 1/21/18, 2:05 AM

    This book is not about OS dev but rather systems programming: "The Linux Programming Interface", https://nostarch.com/tlpi

    For OS development resources, this wiki is very good: http://wiki.osdev.org

  • by dhuramas on 1/21/18, 2:12 AM

    http://pages.cs.wisc.edu/~remzi/OSTEP/ is really good and approachable. It was even recommended in one of the Gatech OS courses.
  • by beeforpork on 1/21/18, 10:36 AM

    To learn which traps to avoid in C, have a look at SEI CERT C. It's written very well with examples and explanations, and is structured as a coding guide.

    https://wiki.sei.cmu.edu/confluence/display/c/SEI+CERT+C+Cod...

  • by csnewb on 1/21/18, 1:48 AM

    I recently decided to review operating systems, but my old Tanenbaum textbook from college would take forever to read through especially now that I'm working full time. I've been watching the Berkeley lecture series on Youtube (CS 162) and its been pretty good at covering the main topics concisely.
  • by lettergram on 1/21/18, 6:30 AM

    I personally found the best method of brushing up on C and operating systems was just walking through examples myself...

    Haven't personally done it for a few years, but I went through step by step on my blog (particularly in 2014):

    https://austingwalters.com/knowledge/

    I also have a nice repo of a bunch of IPC examples:

    https://github.com/lettergram/IPC-examples

  • by beeforpork on 1/21/18, 10:44 AM

    Knowing and fully understanding the concept of undefined behaviour (UB) and the difference to unspecified and implementation-defined behaviour is a must for safe and secure C programming. Because arguably, C and C++ are broken at the specification level. Chris Lattner puts this in kind words:

    http://blog.llvm.org/2011/05/what-every-c-programmer-should-...

  • by zabana on 1/21/18, 7:46 AM

    Somewhat unrelated but I've always wanted ask: What types of small projects can a beginner start to develop a better understanding of C ? (Beyond basic syntax, something that would actually make use of memory allocation, pointers etc)
  • by b3h3moth on 1/21/18, 1:18 PM

  • by django1993 on 1/21/18, 10:13 AM

    I would also recommend reading Computer Systems: A Programmer's Perspective, 3rd Edition.
  • by stiff on 1/21/18, 1:35 PM

    I like this little book, in very small amount of space it teaches you how to build a bare bones OS, from there you can start doing your own experiments which I think is the best way to really learn something:

    https://littleosbook.github.io/

    It's good to not only know operating systems in general, but also to understand some of the internals of the operating system you are actually using. For Linux, this is good:

    https://0xax.gitbooks.io/linux-insides/content/index.html

  • by andlrc on 1/21/18, 10:20 AM

    TLPI is a fantastic reference book to have when written code.
  • by orsenthil on 1/21/18, 8:21 AM

    CS50 courses (This is CS50!), cs50.io is currently one of the easiest and the best introduction to C language. It's very modern approach to teaching C programming.
  • by swinghu on 1/22/18, 1:30 AM

    mark as it is ,learned a lot
  • by sifoo on 1/21/18, 4:21 AM

    Will recommending my own project get me hell-voted? Cixl is a straight forward 3-stage (parse/compile/eval) interpreter that is designed to be as fast as possible without compromising on simplicity, transparency and flexibility. The codebase has no external dependencies and is currently hovering around 7 kloc including tests and standard library. There are some articles explaining design decisions, but I've been mostly busy with code. The code should be perfectly readable though, and contains plenty of good ideas distilled from 32 years of daily practice.

    https://github.com/basic-gongfu/cixl

    https://github.com/basic-gongfu/cixl/tree/master/devlog