Live data from Hacker News

Writing an OS in Rust: Introduction to Paging

os.phil-opp.com

21–30 of 81 posts

Re: Writing an OS in Rust: Introduction to Paging

#21

As a side note: I wish Rust would come to embedded development ASAP running a real time OS written in Rust. You can use massive Boost libraries and Qt frameworks on non-embedded systems with C/C++, but in embedded, there is no such luxury. I am new to it but it is painful and I wish to see a day where we have a complete LLVM based ARM compiler toolchain with Rust sitting on top. I think there were some blog posts abo…

Hey, I saw that links to the Embedded Working Group[0], TockOS[1], and others have been posted already, and those are great places to start!

My company, Ferrous Systems[2], is also focused on embedded systems development in Rust, and we are already helping companies both with embedded linux and bare-metal/RTOS projects in Rust.

We're also running a conference in Berlin on April 26th-29th called OxidizeConf[3] if you are interested in learning more about what is already going on in the Embedded Rust world :)

[0]: https://github.com/rust-embedded/wg

[1]: https://www.tockos.org/

[2]: https://ferrous-systems.com

[3]: https://oxidizeconf.com

Re: Writing an OS in Rust: Introduction to Paging

#22
post #10

Earlier quoted context omitted.

Just found "Handmade Hero" last weekend and now this. Programmer's dream

How does one approach watching Handmade Hero? There's just so much content...

Think it is a problem but every other resource in game development is summarized, organized and bookish.

Handmade Hero is unique in that it is: - Real time, watching a dude program a game - He speaks his though process, stumbles, gets up and resolves issues - Community interaction as they progress through the game

All, at the expense of content bloat. I think its popularity has spoken for itself in that Handmade Hero is a totally unique form of education.

Re: Writing an OS in Rust: Introduction to Paging

#24

I've followed Phil's site on making an operating system. Ever since having worked on PintOS in college, operating systems and their internals have fascinated me. I've tried learning more about writing operating systems via resources like the OSdev wiki, but much of its material almost seems to discourage working on an OS of any kind unless you're already sure of what you're doing. Phil's articles seems so much more a…

I agree. Wouldn't it be amazing to have a "Handmade Hero" series but for OS development in Rust? That would be incredible. A lot of the OS development, especially esoteric subjects are behind walls of IP control barring Linux kernel. Even then, just reading the source code is different than having access to the knowledge base that enables you to write such a code. I am new to all of this but like you, I am fascinated…

>A lot of the OS development, especially esoteric subjects are behind walls of IP control barring Linux kernel.

Join the Redox community! Development is on gitlab[0] and chat is on Mattermost.

0: https://gitlab.redox-os.org/redox-os/

Re: Writing an OS in Rust: Introduction to Paging

#25

As a side note: I wish Rust would come to embedded development ASAP running a real time OS written in Rust. You can use massive Boost libraries and Qt frameworks on non-embedded systems with C/C++, but in embedded, there is no such luxury. I am new to it but it is painful and I wish to see a day where we have a complete LLVM based ARM compiler toolchain with Rust sitting on top. I think there were some blog posts abo…

> I wish Rust would come to embedded development ASAP running a real time OS written in Rust. You want someone to write a Rust RTOS? Or would it suffice for a vendor to release a BSP with Rust support? IMO your current RTOS vendor can (and should!) offer this. Lots of existing RTOS companies will vendor a gcc or clang toolchain for their customers. The fact that C and C++ are well specified independent of their imple…

BSP, board support package.

I had to look that up, seem like what you’re talking about here.

Re: Writing an OS in Rust: Introduction to Paging

#26

I've followed Phil's site on making an operating system. Ever since having worked on PintOS in college, operating systems and their internals have fascinated me. I've tried learning more about writing operating systems via resources like the OSdev wiki, but much of its material almost seems to discourage working on an OS of any kind unless you're already sure of what you're doing. Phil's articles seems so much more a…

I think it's one of these things that's more approachable if you start by working on specific subsystems of an existing OS. This way you don't have to figure everything out at once. At least that's how I did it.

I think writing an OS from scratch is discouraging and not very accessible because... writing an OS is discouraging and not very accessible. It's a bit as if a painter was saying "It tried looking up guides on how to paint The Wedding Feast at Cana but they all make it look super difficult, I wish I could get an easy step-by-step tutorial". Even if you break it down in small, digestible parts I'd wager that you'll end up with a few hundred episodes before you even get a basic microkernel up and running on a modern system. It's truly a daunting task.

I learned that the hard way: I tried to write a guide on how to emulate a PlayStation from scratch. At first you focus on emulating the instructions in the CPU, that's relatively focused and straightforward. But then once you're done with that you need to explain the various peripherals, and the main bus, and the interrupts, and the cache, and the timers, and the pipelines, and the intricacies of the various CD formats, and the memorycard filesystem, and video modes, and paging, and high impedance, and metastability and everything kind of interacts with everything else so it's difficult to maintain a coherent narrative.

On top of that a PlayStation is a ridiculously simple system compared to a modern desktop computer. The task of writing a very accessible guide on how to write an OS that would take you from zero to a working userland is absolutely tremendous. I think you could probably write a thousand-page book on the virtual memory subsystem alone.

Re: Writing an OS in Rust: Introduction to Paging

#27
post #23

Off topic: can we please get support for storing arbitrary data structures inside mmapped files (with nonfixed base address)?

That's not possible to do safely for arbitrary data structures because they can contain pointers or references. If you reload to a different address then the pointers, even within the allocated chunk, would be invalid and require fixup. And if you require fixup then you might as well do (de)serialization for your data structures.

Just allocating into such a memory region (essentially custom page swapping) will eventually be possible with data structures that can be constructed with custom allocators, but it still wouldn't be ok to reload those.

Re: Writing an OS in Rust: Introduction to Paging

#28

I've never programmed in Rust because I still have trouble seeing the point. It seems overly restrictive. A copy of any data has nearly zero marginal cost (and you can pay the cost by doing the work yourself), so in a free machine, it would have nearly zero price. If widely useful data is protected by the borrow checker, far fewer people will use it. It is easy to show that the total utility of a piece of data to the…

Did you just read the Mongo/Amazon article and get inspired?

Re: Writing an OS in Rust: Introduction to Paging

#29

I've followed Phil's site on making an operating system. Ever since having worked on PintOS in college, operating systems and their internals have fascinated me. I've tried learning more about writing operating systems via resources like the OSdev wiki, but much of its material almost seems to discourage working on an OS of any kind unless you're already sure of what you're doing. Phil's articles seems so much more a…

definitely not an easy journey :D to learn to write x64 OS. After getting paging and interrupts it plunged me into the depths of compilers / assemblers / file formats and linking & loading all to be tackled at the same time :'D would use ELF to prevent 2 of the topics, but where's the fun in that :D

like these articles too as they are fairly complete where a lot of other tutorials omit a long of things or are just some scattered collection of information which is hard to put into a project.

Re: Writing an OS in Rust: Introduction to Paging

#30

Earlier quoted context omitted.

> I wish Rust would come to embedded development ASAP running a real time OS written in Rust. You want someone to write a Rust RTOS? Or would it suffice for a vendor to release a BSP with Rust support? IMO your current RTOS vendor can (and should!) offer this. Lots of existing RTOS companies will vendor a gcc or clang toolchain for their customers. The fact that C and C++ are well specified independent of their imple…

BSP, board support package. I had to look that up, seem like what you’re talking about here.

Sorry, yes, that's what I meant. It's a soup-to-nuts working+tested configuration of a board, bootstrap code, examples that exercise board features, etc. IIRC this is common for chip/computer/board/RTOS vendors to provide.
Post reply on HN