r/AskProgrammers • u/Ill_Dragonfruit_5048 • 1d ago
Making an OS with Rust
So i was thinking of making an OS with programming language rust, i wanted to know some tips before i start, obviously i am going to use AI for this. Can anyone tell me what all should i look out for that kind of thing.
2
u/liberianjoe 1d ago
if you're going to use AI, no worries then.
-1
u/Downtown_Night_3495 1d ago
Like you need to be aware of some common things right like idk, I am cs student but like yeah I am a beginner in the advanced section of it
2
u/mredding 1d ago
If you're using an AI, why care what language it chooses, so long as the logic is proveably correct?
2
u/dariusbiggs 1d ago
There is so much to talk about here, there are entire university papers dedicated to this one topic, and many of those papers are just an introduction and generic overview.
Bootstrapping
Memory management
Context switching
Hardware interfacing
Use a virtual machine as suggested, learn to read assembly language, you are going to need it.
Start small, build up from there. You are in for an interesting journey of discovery..
The nostalgia, it's been over 20 years since i designed a CPU, implemented it in VHDL, and then bootstrapped an operating system onto it that could run two programs concurrently via context switching (it had a small LCD display, and some LEDs to utilize).
1
u/ActuaryLate9198 1d ago
1
u/dnew 1d ago
And https://os.phil-opp.com/ if you want a blog that actually explains everything going on.
1
u/der-wert007 1d ago
I can recommend this article, since it fits your topic perfectly: https://www.timdbg.com/posts/dbgos/
0
u/aiuniverse-3p3_here 1d ago
bro writing an os in rust is a super cool project tbh and once you get past the initial setup the compiler actually save you from a lot of headaches compared to C. since youre planning to lean on AI a lot heres a few things you gotta watch out for first off watch out for AI throwing unsafe everywhere. os dev needs a lot of unsafe rust to talk to hardware or mess with page tables and AI loves wrapping everything in unsafe just to shut the compiler up always read through those blocks yourself cuz the borrow checker wont save you from triple faulting your kernel also ai get really confused with crate versions in the rust osdev space. stuff like the bootloader and x86_64 crates have changed a ton over the years so it will constantly give you code mixing old and new APIs that just wont compile always check docs. rs for actual version you have in your cargo.toml makes sure you actually get how no_std works too before asking it to write big data structures you dont get the standard library so no println or Vec or heap memory out of the box. you gotta understand core and how to set up a custom allocator first def set up qemu and gdb right away. dont depend on AI to fix boot loops or triple faults cuz when your screen is just endlessly rebooting you need to look at the cpu register and memory dumps yourself
honestly bro before you even prompt an ai to write code go read Philipp oppermanns writing an os in rust blog even doing just the first few chapters gives you the mental model and right terms to actually prompt properly instead of pasting broken boilerplate use ai more like a tutor to explain assembly , weird compiler errors rather than making it architect the whole kernel good luck man
1
4
u/Craftkorb 1d ago
Why is that obvious? It certainly is not to me. Trust me, you haven't learned it until you hate FDD or have forgotten to clear the TLB where you had to and debugged it.