Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Writing an OS in Rust: Heap Allocation (phil-opp.com)
68 points by phil-opp on June 26, 2019 | hide | past | favorite | 2 comments


Phill's blog series is the best there is for kernel Rust. Glad to see another installment!

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.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: