Hacker News new | ask | show | jobs
by trh0awayman 1383 days ago
I want to see this taken to the logical extreme. A real OS with actual drivers (no unikernel, no virtio) for a small set of hardware that only serves static pages. No need for virtual memory. Just hardcode the blog posts right into the OS and use the most minimal TCP stack you can make.
11 comments

I think that should be possible with Cosmopolitan Rust (https://ahgamut.github.io/2022/07/27/ape-rust-example/). It would create a Baremetal runnable ELF binary with just cosmopolitan libc statically linked, not sure about driver support though.
Keep on going down that rabbit hole: burn it into an FPGA.
> No need for virtual memory.

If it's amd64, long mode requires a page table. Otherwise, a page table is handy so you can get page faults for null pointer dereferencing. Of course, you could do that only for development, and let production run without a page table.

My hobby OS can almost fill your needs though, but the TCP stack isn't really good enough yet (I'm pretty sure I haven't fixed retransmits after I broke them, no selective ack, probably icmp path mtu discovery is broken, certainly no path mtu blackhole detection, ipv4 only, etc), and I only support one realtek nic, cause it's what I could put in my test machine. Performance probably isn't great, but it's not far enough along to make a fair test.

I am actually not sure if a more minimal TCP stack would be the best, especially if you would need to handle packet loss because of congestion for example. For example recent work such as RACK-TLP gives certain workloads better performance, but it is not something you would have in a minimal TCP stack
I guess Unikraft is that, kinda? https://github.com/unikraft/app-nginx
I don't see any easy way to get an existing Rust application running on Unikraft. I'll keep an eye out though!
Well, that shows some promising numbers, but it's still a unikernel rather than an embedded OS which is I think what OP is asking for.
One approach is to run some kind of optimizer on a docker image that throws away everything that does not contribute to the end goal of yeeting text at http clients.
Seems like a case for a unikernel running on bare metal. No copying bytes across kernel/user, no context switching at all.
I guess I didn't realize unikernels could run on bare metal. I've only seen them running on a hypervisor.
I think they typically target hypervisors because it's far more likely that that's what people will want to run on, but there's nothing fundamental stopping a unikernel from running on bare metal.
Just like on most low end embedded systems. Bare metal rules there.
I almost wonder if I should try to get Shrine/TempleOS to do that. That could be a very interesting post.
It already exists in the embedded device word

I remember working in 2008 on a project for some geothermal devices that were spitting some IoT data on a "hardcoded" html page directly in the C code of the program, the device was using a chinese 8051-like CPU so you had no OS-per se

With a bit of dedication you could probably get that put together with https://github.com/auxoncorp/ferros using Rust & seL4.
I think you could do that with redbean, or very nearly so.
Why stop there? Bake your blog to hardware.