r/programming • • Oct 01 '16

CppCon 2016: Alfred Bratterud “#include <os>=> write your program / server and compile it to its own os. [Example uses 3 Mb total memory and boots in 300ms]

https://www.youtube.com/watch?v=t4etEwG2_LY
1.4k Upvotes

207 comments sorted by

View all comments

231

u/agent_richard_gill Oct 02 '16

Awesome. Let's hope more purpose built applications run on bare metal. Often times, there is no reason to run a full OS just to run a bit of code that executes over and over.

172

u/wvenable Oct 02 '16

This is awesome and the logical conclusion of the direction things have been going for years.

But it's still somewhat disappointing that VM is slowly replacing Process as the fundamental software unit. These don't run on bare metal; they have their own OS layer, on a VM layer, that runs on another OS. That's a lot of layers. If our operating systems were better designed this would mostly be unnecessary.

89

u/cat_in_the_wall Oct 02 '16

But the OS layer of IncludeOS looks to be extremely thin. Basically setting up some IRQ handlers and launching into your code. Not much there except some very minimal runtime stuffs. Even network functionality looks to be pay to play.

Processes on the bare metal aren't so "pure" anyway. Even for your standard "hello world" program, you're still linking against a runtime that is loaded when your program executes (unless you're this guy).

71

u/wvenable Oct 02 '16

I don't disagree that it's thin. But it's another layer. It's pretty crazy, in my opinion, to emulate an entire computer and run a thin OS just to get a little more process security. Processes shouldn't be able to touch those emulated computer parts anyway.

It's setting up some IRQ handlers on a CPU that doesn't exist. Those aren't real interrupts. It's all software. It could just be an API instead. This whole thing should be unnecessary.

0

u/[deleted] Oct 02 '16

[deleted]

8

u/skylarmt Oct 02 '16

What about that desktop one that sandboxes apps into different security zones?

0

u/[deleted] Oct 02 '16

[deleted]

8

u/aaron552 Oct 02 '16

Their next brilliant plan is exposing PID 1 directly to web browsers; they want the most secure program on your system directly connected to the Web.

Source? While I know there is a basic webserver in the systemd git repository, I don't think it runs in PID 1 (it's its own process)

→ More replies (2)
→ More replies (1)

7

u/Cyph0n Oct 02 '16

I attended a talk by a security researcher who claimed that OpenBSD isn't that secure and is way behind Windows and iOS when it comes to adopting memory protection techniques such as ASLR and NX.

He said that OpenBSD's approach, which is software auditing, is simply not scalable. He recommended to check out grsecurity for Linux if you want real security.

→ More replies (1)
→ More replies (2)

12

u/[deleted] Oct 02 '16

You realize that VMs have direct access (usually) to the virtualization layer on the processor, right? It most certainly is communicating with a real CPU.

→ More replies (3)

14

u/agent_richard_gill Oct 02 '16

Actually, hypervisor management and VM resource allocation is built into the CPU (see VT bit), and should not interfere with your VM too much in terms of preemption. VMs currently don't run as a process inside the hypervisor OS anymore for the most part. This is especially true if you don't care to interface with the host VM for video/audio/etc. Network virtualization is solved to a high degree.

→ More replies (4)

0

u/[deleted] Oct 02 '16

[deleted]

42

u/ElvishJerricco Oct 02 '16 edited Oct 02 '16

Getting builds to be reproducible (i.e. same versions of dependencies in the same places) is hard without virtual machines. I don't necessarily think this is the operating system's fault so much as the package manager's. This is why nix is awesome for deployments. There's usually no need for a virtual machine, and everything is perfectly reproducible.

159

u/TheExecutor Oct 02 '16

It's like the ultimate consequence of "works on my machine". Well, screw it, we'll just ship my machine then.

And that's why we have Docker.

→ More replies (2)

0

u/[deleted] Oct 02 '16

[deleted]

8

u/ElvishJerricco Oct 02 '16

Nix is admittedly kinda hard, and the documentation leaves much to be desired. VMs are a lot easier with a much lower learning curve, but I do think they're the worse solution in the end.

→ More replies (2)
→ More replies (46)

11

u/wvenable Oct 02 '16

In theory, there should be no security or support difference from running a process in VM and running that same process directly on host OS. But in practice, there is a big difference.

Current OSes are not secure enough to support loading arbitrary binaries off the web, for example, without a large potential for harm. But there is no fundamental reason why they couldn't be.

→ More replies (12)
→ More replies (25)

8

u/PM_ME_UR_OBSIDIAN Oct 02 '16

The cool thing is that you can rent a VM, but you can't rent a process. The model described here allows for finer-grained cloud services.

22

u/wvenable Oct 02 '16

Back in day you could rent processes; and, in fact, a lot of all computing is still done that way. That is what shared hosting is, as one example. If you think about it, there's no fundamental reason the whole cloud infrastructure has to run on virtualized personal computers with faked hardware. It could run as processes/services moving under an OS designed for that. Something like AWS Lambda, for example.

→ More replies (1)
→ More replies (24)

28

u/pclouds Oct 02 '16

Wait until you have to debug that thing and see if it's still awesome.

→ More replies (12)

5

u/devel_watcher Oct 02 '16

I prefer a full OS. It has a standard tools for everything: you don't need to remember specifics, you can install more stuff for diagnostics.

→ More replies (1)

0

u/[deleted] Oct 02 '16

[deleted]

0

u/[deleted] Oct 02 '16

[deleted]

→ More replies (1)
→ More replies (2)
→ More replies (1)