resea icon indicating copy to clipboard operation
resea copied to clipboard

Rewrite the kernel in Rust (2nd try)

Open nuta opened this issue 4 years ago • 2 comments

Interestingly, Resea Kernel is used to be written in Rust. However, it soon be rewrote in C because of the following drawbacks:

  • It tends to consume too much kernel stack (especially core::fmt).
  • It implicitly employs panics to prevent undefined behaviors.
  • libcore is too large for the microkernel (occupies approximately 30% of .text).
  • Writing intrusive data structures (e.g., LinkedList<T>, SpinLock<T>) is painful.

I do think C is better for a minimalistic microkernels as of this writing, that said, I also believe that the problems might be addressed someday.

nuta avatar Feb 18 '21 13:02 nuta

Small codebases in C are not a problem. Microkernels of a few thousand lines are therefore no problem.

It's when codebases approach hundreds of thousands or millions of LOC that it becomes unwieldy.

The kernel is pretty small (3200 LoC) but the entire Resea operating system exceeds 90.000 LoC (including the kernel). Wouldn't it therefore be more logical to rewrite just the servers in Rust?

P.S.: I used the following command to calculate the LoC: find . -name '*.c' | xargs sed '/^\s*#/d;/^\s*$/d' | wc -l

Sologix avatar Nov 07 '21 16:11 Sologix

Locked because this issue is becoming another place to enjoy meaningless "Rust vs. C" dispute.

nuta avatar Jul 31 '23 07:07 nuta