blog_os
blog_os copied to clipboard
How to communicate between rings?
User-space programs should run in CPU ring3, but kernel runs in ring0, how to communicate between rings?
The kernel can go to userspace using iret/sysret and userspace can call into the kernel using the syscall instruction or by causing an exception.
The kernel can go to userspace using iret/sysret and userspace can call into the kernel using the syscall instruction or by causing an exception.
What is needed to do before userspace and what are the best resources @bjorn3 ?
Maybe https://wiki.osdev.org/Getting_to_Ring_3 would help you?
- https://nfil.dev/kernel/rust/coding/rust-kernel-to-userspace-and-back/
- https://github.com/nikofil/rust-os
My OS: https://github.com/ChocolateLoverRaj/code-runner/tree/edition-3. Note that I am still working on the ELF stuff.
Does userspace run slower than or as fast as kernelspace? Since userspace has less privilege, the hardware or kernel needs to check the privilege.
Same speed. Only transitions between rings are relatively slow (couple hundred cycles if you optimize our kernel a bit).