4 ms·
I've been playing with Rust for os dev and emulation for a little bit. It's great to have others who are significantly more well-versed in this field sharing th
by jscheel 11y ago
I've been playing with Rust for os dev and emulation for a little bit. It's great to have others who are significantly more well-versed in this field sharing their knowledge with those of us who are struggling through it.
- steveklabnik 11y agoWhen the author was writing this post, they said on IRC something like "I've just been reading a ton of manuals, I hope someone more experienced starts writing too." It's all relative :)
- easytiger 11y agoWith that memory model its not surprising. On the other hand, i really really would encourage any new developers to read the rust docs before learning c++ etc. It is amazing to have a language that puts its mem model first. The docs tackle the very basics really well. The k&r c book is amazing but did a poor job of dealing with the true memory model because that was common knowledge at time of writing. Its short because of assumptions the best java (top 0.01%) developers are the only ones I encounter often who understand the x86 + javas basterdised memory model The rest just take it for granted. Even c++ developers (I'm one).
- Cshelton 11y agoI feel far too many books make assumptions that things are "common knowledge". I think they are afraid of putting too much remedial and review stuff at the beginning or in the book in general. But in reality, the percentage of people who understand something fully at the 'expert' level is very small. Best way to find out if you know something or not is too teach someone else.
- steveklabnik 11y agoThis is exactly on point, for any kind of teaching. And reviewing the 'basics' can help situation information in context you already know. Ironically, I often use a paging metaphor here, for stuff that I learned, but haven't thought about recently... going over something again to refresh my memory is just swapping that page back in.
- Manishearth 11y agoI actually doubt Rust puts the memory _model_ first, but it provides a path through which you effectively don't have to worry about it at all. Which is wonderful and good enough, really. IIRC Rust has a similarly confusing underlying memory model. However, due to a lack of direct shared mutable state being available, you don't get to see this often. In fact, one might call Rust's model more confusing than C++ since you have `noalias` everywhere which can enable more aggressive optimizations. But it's mostly irrelevant since you don't deal with it unless you're writing unsafe code. On the "encourage new devs to read the Rust docs" front I agree, though. We've had tons of people saying that they code better C++ after learning Rust. Also I've heard of companies wanting to start programming in C++/Rust-y things with a majority of python/ruby/js/etc devs use Rust because "Rust teaches a lot of things to the programmers that they no longer have to". Something like that.
- kibwen 11y ago> IIRC Rust has a similarly confusing memory model In fact I believe that at a fundamental level Rust is forced to more-or-less adopt C11's memory model thanks to its usage of LLVM, though, as you say, Rust's concurrency safety mechanisms mean that the theoretical soundness issues that apply to C11 are toothless in Rust.
- easytiger 11y agoAgreed. What i meant was they start talking about the memory model at the very beginning of their online book, more than most languages bother with. https://doc.rust-lang.org/book/the-stack-and-the-heap.html https://doc.rust-lang.org/book/the-stack-and-the-heap.html
- steveklabnik 11y agoYeah, this is because we want people who may not have a systems backround to be able to use Rust. That's just general info on the concept of stack vs heap, it's not Rust-specific.
- ekidd 11y agoAuthor here. As steveklabnik says, I'm figuring this out as I go along, with much help from the amazing OSDev wiki: http://wiki.osdev.org/Main_Page http://wiki.osdev.org/Main_Page Basically, this stuff is a ton of fun, and I'm just sharing my learning process with other people in hopes that we can all learn from each other and spend less time digging through hardware data books. :-) In particular, I recommend Philipp Oppermann's great introductory posts: http://os.phil-opp.com/ http://os.phil-opp.com/ And if you'd like to hack on a somewhat more complete Rust-based OS, the Redox people appear to have gone into overdrive in the last few weeks: https://github.com/redox-os/redox https://github.com/redox-os/redox The #rust-osdev channel on Mozilla IRC is also full of great folks, who've helped me with all kinds of challenges.
- kijiki 11y agoamd64 supports a separate interrupt stack (up to 8, IIRC), which would allow you to continue using the redzone optimization.