4 ms·
Such an inspiring read! Thanks for writing and/or sharing. One of my many future hermit projects is to hack on an early version of Linux. ------------ Please i
by hnthrowaway0315 2y ago
Such an inspiring read! Thanks for writing and/or sharing. One of my many future hermit projects is to hack on an early version of Linux.
------------ Please ignore just jotting down for future myself ---------------
(Actually I want to study Win NT more than Linux as it brought me good memories, but Win NT was designed as a mature product from the beginning, and even the leaked 3.5 source code is way too much for me.)
I checked the version history and 0.11 seems to be a good start. Reasons:
- There is this book (https://download.oldlinux.org/ECLK-5.0-WithCover.pdf https://download.oldlinux.org/ECLK-5.0-WithCover.pdf) which follows the style of Lion's Unix v6 book and uses the 0.12 kernel as reference;
- 0.11 doesn't have a virtual memory or a virtual terminal, and they are among the software I'd like to implement;
- 0.11 does have the basic stuffs so I assume it is not too difficult to set it up with QEMU and QEMU-gdb;
The list of software to implement in mind:
- a Debugger (I'll probably use QEMU-gdb, but if I can write a simple step-in debugger maybe it makes it a bit easier to dogfood? Still too early though as there is no compiler on it)
- a Virtual Memory system (following the MIT xv6 lab, maybe a bit more advanced as I will complete the MIT xv6 labs before pursuing this venture);
- a Virtual terminal (not sure how much I can implement, maybe just a basic one with limited control sequence support);
- a USB driver (not sure if it's possible for 0.11, I have never written a driver before);
- a mouse driver (again probably too difficult for me);
- a LOT of CLI programs as warm-up. Basically simpler versions of modern ones (less switches);
- a text editor. I never liked the key layout of emacs or vim so this is going to be my own thing. I care a lot about moving caret around without using a mouse;
- a very basic GUI system. Nothing fancy, just something that can show windows and some widgets. Maybe don't even care about multiple windows. Showing one window with a menu and some buttons probably needs a lot of effort;
- a compiler/linker of a simple language (can't dogfood without an editor, a compiler, a linker and a debugger I think)
Preparations:
- I need to complete all MIT RISC xv6 labs;
- I need to figure out how to write drivers for USB and mice;
- I want to investigate how X11 and Win32 GUI were implemented and figure out the architecture;
- I need to figure out how to write terminals and text editors. There are tons of tutorials online so shouldn't be too tough;
- I need to study compiler theory, just continue reading Crafting Interpreters should be good enough;
- I need to figure out a comfortable development and debugging environment;
- qingcharles 2y agoI always drop this book when people talk about writing or hacking their own OS etc: https://www.amazon.com/Developing-32-Bit-Operating-System-Cd-Rom/dp/0672306557 https://www.amazon.com/Developing-32-Bit-Operating-System-Cd... Can probably find it on a shadow library. Getting something to boot on x86 is a little tricky, because IIRC the CPU comes up in real mode, so you have to create your own boot sector and bootloader before you can even execute your kernel. That book + Linux inspired me to write my own OS in 1995. My goal was to have an OS that booted directly into a modern GUI and fitted (with basic tools) onto a single 1.4Mb floppy, which I did manage.
- hnthrowaway0315 2y agoThanks for the introduction to this book. AFAIK Linux 0.11 does have its own bootloader in the form of `bootsect.S` but I'm not an OS guy so definitely could be wrong. Now that I think more about the project, probably the first obstacle is how do I compile the thing...someone must have tried that, or the book must have a section about that. But I'll study xv6 first, just to give me some practices.
- p_ing 2y ago> I want to study Win NT Windows NT Design Workbook: https://computernewb.com/~lily/files/Documents/NTDesignWorkbook/ https://computernewb.com/~lily/files/Documents/NTDesignWorkb... Tale of Two Kernels: https://youtu.be/HdV9QuvgS_w https://youtu.be/HdV9QuvgS_w And I'm sure you've picked up a copy of Windows Internals. Right now I'm waiting for a copy of Inside Windows NT which is the first edition of that series as well as Inside the Windows NT File System, both by Helen Custer.
- deleted 2y ago[deleted]
- hnthrowaway0315 2y agoThanks man. I do have a copy of "Inside Windows NT", but I decided to study XV6 first because of its pedagogical value. It's hard even to compile the leaked NT 3.X source code.