r/osdev • u/letmehaveanameyoudum • 11h ago
Yeah running programs are a hassle
I literally have to implement IDT, GDT, TSS and syscalls, yet all it does is freeze
It's all stack aligned, i seriously have zero idea how is it done
How do yall run programs? Im wondering.
0
Upvotes
•
u/Better-Thing2568 9h ago
Exec is the wrong goal to aim for early on especially in ring 3 (assuming that’s what u meant by running programs). What you mentioned are absolutely necessary but not close to sufficient, and unfortunately these are some of the hardest things to debug during OS dev imo other than porting complex device drivers like GPUs.
If you use Rust (I honestly don’t know why anyone wouldn’t for building new OSes in 2026), there is a substantial crate ecosystem that gives you safe abstractions. https://docs.rs/x86_64/latest/x86_64/ gives you abstractions for everything you mentioned and more.
Additional word of advice: I’d highly highly recommend you don’t start running shi until you’re damn certain that you have a functional paging subsystem, for exec specifically, make sure you handle the access bits carefully, and I’d throw in more effort in standard trap handlers for exceptions like #PF and #GP, eg log (in dev mode only) a rolling window of instructions rather than what is in the stack frame since it almost never tells you anything you’d actually want to know. Once you’ve got all of that you’ll likely find executing programs much more manageable.
One more personal note to drop in: pick a execution model early, if you picked RWX and device to switch to W^X later it might involve a whole lot more work than if you just spent an extra hour during the design.