OS Stuff
i’m currently exploring MINIX and OS development and i need a room to put my thoughts notes whatever the fuck
main resources
books
- explains OS design using minix as example - Operating Systems - Design and Implementation
- i think this is more generic modern OS introspection but still looks good - Modern Operating Systems
websites
osdev
- bootstrapping a minimal kernel - https://wiki.osdev.org/Bare_Bones
- setting up a cross compiler - https://wiki.osdev.org/GCC_Cross-Compiler
making an os in rust blog
OSes to study
MINIX
Microkernel written in C that separates kernel functionality into processes and sends messages between different layers of the OS. — repo: https://github.com/Stichting-MINIX-Research-Foundation/minix
- The companion book, Operating Systems - Design and Implementation, is recommended reading.
- If you want to follow along with the book, switch to tag
v3.1.0, but the latest release is much easier to rebuild and is compatible with more modern software to use as a base. It definitely beats looking at the source code in the book.
- If you want to follow along with the book, switch to tag
- Follow the instructions here to compile: https://wiki.minix3.org/doku.php?id=developersguide:crosscompiling
- Patches to apply to MINIX master branch so it compiles with gcc-10+: https://github.com/Stichting-MINIX-Research-Foundation/minix/pull/322
- Fork of MINIX that compiles on M1 macOS using Docker: https://github.com/lincdog/minix
Compiling without rebuilding the whole system
I’m pretty sure that this actually doesn’t even work…
alias minix-nbmake=$(git rev-parse --show-toplevel)/../obj.i386/tooldir.xyz/bin/nbmake-i386
alias minix-img=CREATE_IMAGE_ONLY=1 $(git rev-parse --show-toplevel)/releasetools/x86_cdimage.sh
# do this inside of the directory you want to recompile, they usually have a Makefile to recompile
minix-nbmake && minix-nbmake install
# create the image
minix-img
Linux
Monolithic kernel written in C. I think most people know this one — repo: https://github.com/torvalds/linux
- A study on the scheduler for Linux 2.6.8.1: https://web.archive.org/web/20070627191326/http://josh.trancesoftware.com/linux/linux_cpu_scheduler.pdf
Serenity
OS with a monolithic kernel written in C++ with a huge monorepo of different utilities. The window system, audio, image rendering, are all seperated into different ‘process servers.’ This description is most likely incorrect and begs for revision. — repo: https://github.com/SerenityOS/serenity
- The creator’s YouTube channel, really informative and entertaining for something to watch when bored: https://www.youtube.com/c/AndreasKling/videos
- I recommend sorting by oldest to see base parts being developed
- I also recommend looking for videos with the title of Code Tour but some of the older implementation videos are also interesting
notes
TODO: scheduling
notes for cross compilation with clang / llvm
this assumes that you have a base from the OSdev Bare Bones OS. i just do this because clang is more convenient to use on macOS
- CFLAGS for clang:
--target=i686-elf -march=i686 -nostdlib -fno-builtin -ffreestandingclang --target=i686-elf -march=i686 -nostdlib -fno-builtin -ffreestanding -c kernel.c -o kernel.o - remove
BLOCKfrom linker.ld,ALIGNperforms basically the same with the LLVM linker. also don’t remove the:s from the file - invoke the LLVM linker like so:
ld.lld -T path-to-linker.ld -o output.bin list-of-object-files.oif this needs better explanation, please advise