▲ | crowcroft 4 days ago | ||||||||||||||||||||||||||||||||||
This is probably a dumb question from someone who knows almost nothing about system engineering. How hard would it be to boot a computer to this as an OS? | |||||||||||||||||||||||||||||||||||
▲ | MisterTea 4 days ago | parent | next [-] | ||||||||||||||||||||||||||||||||||
> How hard would it be to boot a computer to this as an OS? Unikernels aren't meant to run as a bare metal OS on a standard computer like a PC. Instead they are applications wrapped in thin libraries that allow them to boot in hardware VM's provided by Intel vmx or AMD svm, etc. A hypervisor provides mechanisms for communication with hardware and other resources. They boot fast because the underlying system and hardware is already initialized and running. The main idea of unikernels is to get rid of costly system calls like brk/sbrk called by malloc, open/read/write, etc. between the OS and application. The system never has to switch protection rings which saves a lot of time. This gives the application full control of its compute and memory resources with the possibility of direct hardware access depending on the host hardware and hypervisor. So you can attach things like NVM storage directly to the VM and let the application handle the disk and fs operations. So to answer your original question of using such a wrapper to boot chrome on a PC: you will need a much, much bigger wrapper library which adds in all the hardware access which is a LOT of code (The GPU code alone is scary enough). You must also realize the fast boot time will be obliterated by hardware init which usually takes time as you have to jiggle certain hardware registers to wait, then probe again to see if things are working as advertised. This can take several seconds or more. In the end, you save nothing. If you wanted an OS based on a hypervisor which boots unikernel applications you are at the mercy of the hardware to multiplex access or delegate that to a hypervisor adding more overhead. Again, you saved nothing. In the end, your OS is really a CPU multiplexer and does a great job of providing all the primitives and resources in a generalized, uniform manner. I highly recommend reading this book: https://pages.cs.wisc.edu/~remzi/OSTEP/ | |||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
▲ | csdvrx 4 days ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||
You would have to add support for the peripherals in the kernel, and have some kind of init system. You would also need a filesystem supported to boot the computer. I was doing something similar for the entire OS a few years ago: cosmopolinux, a distribution of cosmopolitan binaries: https://github.com/csdvrx/cosmopolinux My idea was to replace the WSL binaries to have a Linux distribution living on C:\, but that could also be booted baremetal if you didn't want to use Windows I had to put together a multi stage init system for that: if you get the ISO, you can put in on a thumbdrive and boot it: https://gitlab.com/csdvrx/cosmopolinux The only difference between them is the kernel and the filesystem: the github NTFS has a firecracker linux kernel, the gitlab ISO has a regular kernel with many modules. I wanted to do a full NTFS solution but I couldn't find a bootloader I liked that would support booting from a NTFS partition. Booting from an ISO was simpler and faster. | |||||||||||||||||||||||||||||||||||
|