Re:Writing an OS in Rust: Heap Allocation
by phil-opp on Thursday June 27, 2019 @05:51AM
(#20293008)
Thanks so much!
Yes, I'm eagerly awaiting https://github.com/rust-lang/rust/pull/58457 and your follow-up https://github.com/rust-lang/rust/pull/60703. AFAIK, a global allocator is still required with them (so we still have to initialize it), but it allows us to choose a different allocator for some collections, e.g. to avoid deadlocks in interrupt handlers.
Note that in Rust today we can only use standard collection with the global allocator. https://github.com/phil-opp/blog_os/blob/post-10/src/main.rs... in the blog post it is intialized, and there's nothing to prevent allocation earlier and that will fail.
But there is work in progress (first https://github.com/rust-lang/rust/pull/58457) that will allow using local allocators, removing the ambient authority that makes that failure possible. Note that this doesn't mean a runtime cost. One can pass around a zero-sized token that is completely erased.