6 ms·
I don’t believe Rust is ready for OS kernels yet. People have written OS kernels but they really stretch the language to do it. For instance, the default heap a
by muricula 9y ago
I don’t believe Rust is ready for OS kernels yet. People have written OS kernels but they really stretch the language to do it. For instance, the default heap allocation API panics on failure, which isn’t something I want my kernel to do. There’s work on a new API which doesn’t do this in nightly rust, but they could completely change all that tomorrow.
Additionally, alignment constraints are also really important at that level, but rust doesn’t have a mature way to align structures or arrays.
Rust isn’t ready for this space yet.
- steveklabnik 9y agoWhen you're writing a kernel in Rust, you aren't using the default heap allocation API; you aren't using the allocation API at all. You could then build any sort of allocation strategy you want. You don't need to wait for the new traits, though of course, using them eventually helps with interoperability. You're certainly right about "mature way" wrt alignment, but it's something that can be worked around until then.
- tetromino_ 9y agoWell, C's default heap allocation API is not suitable for kernel mode either. Compare libc's malloc and the kernel's kmalloc, with the fine-grained control [1] over what kind of allocation to perform. [1] https://github.com/spotify/linux/blob/master/include/linux/gfp.h https://github.com/spotify/linux/blob/master/include/linux/g...