
Writing an OS in Rust - jfreax
http://blog.phil-opp.com/
======
bitdivision
I recently found out about Redux:

[https://github.com/redox-os/redox](https://github.com/redox-os/redox)

It's pretty incredible how quickly it's come together, there's a reasonable
looking GUI already!

Edit: The author also did an AMA on reddit:
[https://www.reddit.com/r/rust/comments/3mw67c/i_am_jackpot51...](https://www.reddit.com/r/rust/comments/3mw67c/i_am_jackpot51_the_writer_of_redox_a_rust/)

~~~
kibwen
Now with weekly progress reports: [http://www.redox-os.org/news/this-week-in-
redox-3/](http://www.redox-os.org/news/this-week-in-redox-3/)

------
cwzwarich
As far as I can tell, Rust OS projects generally use gratuitous amounts of
unsafe code and are not substantially different than if they were written in
C. I could just be looking in the wrong places. Are there any that take
advantage of Rust's type system to provide real guarantees?

~~~
kibwen
The OP talks about this in the most recent post:

 _" In the previous post we switched from assembly to Rust, a systems
programming language that provides great safety. But so far we are using
unsafe features like raw pointers whenever we want to print to screen. In this
post we will create a Rust module that provides a safe and easy-to-use
interface for the VGA text buffer._"

------
Animats
I'd like to see someone re-implement the QNX real-time microkernel in Rust.
That would be useful. We need a QNX-like OS for embedded devices. Linux is
really the wrong tool for the job. Too much extra stuff which allows attacks.

~~~
walterbell
Could RIM open-source QNX, if the Blackberry Android device is successful?

~~~
jacquesm
I asked, both before QS sold it to RIM and after the deal, in both cases I
didn't even get an answer (and I would have been in a position to put up a
substantial chunk of money in order to get a dual license deal in place). Real
pity, but maybe it will still happen.

QnX is one of the most elegant OSs out there and having a public domain or
GPL'd version of it would be a great thing.

------
devit
If anyone is considering working on an OS in Rust, they could perhaps consider
writing a small hypervisor that could replace Xen, Nova and similar
hypervisors.

This provides the same low-level challenges of writing a kernel, but it's far
easier to get practically usable software than attempting to replace Linux and
would actually be useful in practice.

At the moment, the only way to make a sandbox that has a chance of being
perfectly secure (i.e. no security holes, ever) while still running all kinds
of useful software is to use VMs to sandbox Linux/Windows kernels, and here
the hypervisor is of course the weak point, and current usable hypervisors are
written in C or C++.

~~~
steveklabnik
[https://internals.rust-lang.org/t/unikernels-in-
rust/2494](https://internals.rust-lang.org/t/unikernels-in-rust/2494)

~~~
devit
This seems to be about using Rust for the kernel running inside the virtual
machines, not for the hypervisor itself, which is what I was talking about.

------
achanda358
[https://github.com/flosse/rust-os-comparison](https://github.com/flosse/rust-
os-comparison)

------
steveklabnik
I've read through what was here, and last night, actually built the first
post's code. I really like the depth and style of this particular posts, it
really hits a sweet spot.

------
mtgx
Relevant:
[https://github.com/wbthomason/ironkernel](https://github.com/wbthomason/ironkernel)

------
codepie
I was looking for something similar in C. Most of the resources I found (eg :
os dev-wiki) do not cover the implementation details in such depth. Can anyone
give few pointers?

------
monocasa
No -mno-redzone?

------
bulutsuzku
What's the value and novelty of writing an OS in Rust?

~~~
steveklabnik

      > value
    

Well, Rust is a systems language, and so it should be a good fit for OS
development. We're still working on bits of it, but it's a stated goal of the
language, so testing that out is valuable.

    
    
      > Novelty
    

Well, Rust is still a fairly young language, so there aren't a ton of people
doing things with it yet, relatively speaking. And for OS dev, which is kind
of a niche subject anyway (as much as I love it), there's naturally even less.
So it's basically novel by definition.

~~~
bulutsuzku
> Well, Rust is a systems language, and so it should be a good fit for OS
> development. We're still working on bits of it, but it's a stated goal of
> the language, so testing that out is valuable.

My questions was not well formulated. Let me rephrase it: C is also a system
language and there are plenty of OS libraries written in C. C++ could be seen
as another system language. Even the syntax of Rust is similar to C/C++
according to Wikipedia article. So, what's the advantage of Rust over other
systems language? Better support for autonomous systems? Reflective model? Do
you have a paper? It is a research project? Do you plan to replace Linux or
something like that?

~~~
Zarathustra30
(Safe) Rust provides some nice guarantees. It (should be) impossible to have
use-after-free, buffer overruns, race conditions, etc. in 100% Safe Rust. A
pure Rust OS could provide a safe interface to build safe programs.

While mostly a novelty, an OS capable of executing untrusted code risk-free
could be a powerful tool indeed.

