Various notes on operating systems for whenever I get around to trying to make my own.
Jonathan Blow on how an operating system should work
https://www.youtube.com/watch?v=k0uE_chSnV8
- Current OSes have too many processes running by default before you’re even doing anything with your computer(400 in this discussion)
- Current OSes have way too many executables by default (4500 in this discussion)
- A functional OS should not be doing very much. If a user wants to do a bunch of work that’s good but the OS should not be large
- No drivers
- Most things should happen in userspace
- Programs should be able to go over the network without talking through the kernel
- Processes communicate through memory mapping/memcpy
- Few processes running
- Processes super-sandboxed from each other, basics of how OS works, not additional thing
- Core interface that OS implements should be as simple as possible -> facilitate DMA with hardware, handle memory pages, etc.
- Basically microkernel but better
- This ideally would be a lot more performant because you don’t have to keep going through kernel space or use syscalls for every little thing
- No installs/invisible installs, you just run it, program shouldn’t be able to access anything else anyways so no need for install, it runs in its own little sandbox
- All code position-independent so no static/dynamic libraries, just one library type which could be statically or dynamically linked at compile time (ideally statically, but in such a way that the program knows what code came from which library so if a security patch is needed we can know which processes need to be updated/changed).
- Command line programs and library functions should be the same, with the command line possibly implementing extra interface stuff, but either way no separation
- It’s not a good idea to have a ton of software on your OS, most software is bad and fluff and really not needed
- Don’t try to replicate functionality of Linux, Windows, MacOS, etc.
- Batch scripting is not a good idea because it usually turns into programs to just run programs
- No PATH variable because programs can’t arbitrarily read the FS, but maybe more structured folder?
- No registry
Jonathan Blow on Drivers
https://www.youtube.com/watch?v=xXSIs4aTqhI
- Communication over DMA
- Each process implements own TCP stack (i.e. it’s basically in a library)
- What we have now is a mess where drivers from anyone get complete access to the kernel
- Drivers are a mess anyways, a program to connect to a printer should just connect to the printer, not need to go through a middleman
- Stuff like sound is solved, but very broken/complicated in a lot of OSes, it should be simple to stream sound to devices, no need for 100s of drivers
- Make the hardware target the software, not the other way around. One software stack/protocol is really simple to maintain compared to 100s of different pieces of software to support 100s of different devices (i.e. standardize on some set of protocols or say “if you want to support this OS, you have to do this in your hardware”), if not then use a userspace translation program, so at least this “driver” doesn’t have kernel access.
Potential Default Font
http://paulbourke.net/dataformats/hershey/
Programmable OS
An OS built upon the principle of infinite mutability where there is no difference between a shell and a text editor or the programs running on it and the kernel. Similar to early computers which ran BASIC, a user is immediately dropped into a REPL (maybe Scheme-based?) with which they can immediately start programming the computer to do anything they want of it. Programs can simply be functions, GUIs can be immediately modifiable through a console window, and so on.
Using interpreted languages for the majority of system tasks is ideal, as they are typically easier and faster to write, experiment with, and debug compared to compiled languages. Also, performance is not typically a concern for general OS tasks, though the ability to compile programs should obviously be included for those situations in which performance is a critical aspect.
Scheme or other LISP-like languages seem to be ideal for this purpose given their property of treating code as data and allowing you to mold the language to fit your specific purposes. It’s not uncommon for programs written in such languages to have effectively built their own programming language through the use of composing the basic tools LISP-likes give you.
Yes, this kind of sounds like emacs taken to the next level…
No Symlinks
The trouble with symbolic links
Cheap Complexity
https://www.schneier.com/blog/archives/2022/08/security-and-cheap-complexity.html
Starting from a Linux Distro
Using Linux From Scratch to get an idea of how things can be done, what needs to be done
https://www.linuxfromscratch.org/
pkgsrc as packaging system?
https://www.pkgsrc.org/#index5h1
Try to incorporate as many BSD-likes as possible, even though we still have to work with the Linux kernel. e.g. bsdutils instead of coreutils?
Issue with modern OS desktops
Innovation was done for the sake of innovation and for the new shiny.
The desktop metaphor was done by Windows 95 and we haven’t really changed anything since then.
Don’t change things for the sake of change, to make users struggle to find where things are now when all they want to do is get their work done.
https://www.theregister.com/2022/09/05/opinioncolumnmodernosdesktop/
OSDev Wiki
Memory Management on Old OSes
http://basalgangster.macgui.com/RetroMacComputing/TheLongView/Entries/2011/1/22_MoreMasters%3B.html
Another video series on making an OS
https://www.youtube.com/watch?v=MwPjvJ9ulSc&list=PLm3B56ql_akNcvH8vvJRYOc7TbYhRs19M
Continuation Passing Style
In continuation passing style, a stack is not needed because functions never return, the code is simply compiled into sequences of instructions with GOTOs. This might be an interesting thing to try for an operating system, entirely eliminating issues related to stack overflow, stack smashing, etc. Although it would come at the cost of very ugly code if written with a traditional language, so perhaps a new language could be designed just for this OS?
https://ericnormand.me/podcast/what-is-a-continuation
If I ever make an OS, I will need to have support for stylus input and writing freely over everything.
I wish computers were a lot closer to the pen and paper experience. Where you can take some text or a passage from a book or anything like that and just start scribbling and writing and highlighting, regardless of any specific drawing support in any app.
I would also so very much love to have a text editor that supported creating pages on an infinite plane.
Basically like a neverending desk, where you can make pages of any size and format, organize them how you’d like, draw on them, rearrange them, etc.
But then also combine this with the power of computers where nothing is concrete. You can drag and drop text from one page to another, split pages up to reorder things, have infinite undo, modify images on the fly, etc.
PROGRAMMING FROM THE GROUND UP AN INTRODUCTION TO PROGRAMMING USING LINUX ASSEMBLY LANGUAGE
Notes on Programming in the OS
When programming, you should always be able to jump to source code of any libraries you use, as if it was part of your project. If you call printf from stdio.h, for example, you should be able to just jump to its definition/implementation.
Notes on a Shell
Is there another way to handle shell-based input that doesn’t require ugly escaping of special characters?
It would be nice to be able to write something akin to cp -r Downloads/Dir With Spaces Documents/ instead of needing to escape the spaces (cp -r Downloads/Dir\ With\ Spaces Documents/) or quote the whole string in question (cp -r "Downloads/Dir With Spaces" Documents/).
It’s not so much that there are scenarios that quoting would be impossible, it’s more that I’d rather just not have to worry about the need to do it in the first place.
The end goal would be to make the system as “user-friendly” as possible in so much as the user interacting with the shell doesn’t have to think about such simple shell-specific details as this, and can just type what they mean without worrying.
Notes on File Managers
im very surprised that no file manager has a method to open a file for /viewing/ (eg double click) or for /editing/ (eg alt+double click), and have two context menu options for these two common actions instead i spend too much time going open with…. and then not knowing what its going to default to next time, and end up opening an image i wanted to view in gimp, or a html i wanted to edit in firefox
Notes on File Systems
Other Helpful Resources
- Software Unscripted: Scratch-Building an Operating System with Steve Klabnik ← This is also useful for “C package manager” ideas.
- Recfiles - a simple database format
- The Little Book About OS Development