Hacker News new | ask | show | jobs
by quietplatypus 3705 days ago
Great article!

I'm not too familiar with OS as a subject, but is the separation between user and kernel mode similar to high-level language versus assembly; i.e., the approach they took was to emulate the Linux kernel, which is sort of like a virtual machine. But I imagine emulating a kernel is harder, right? Because of all the stuff that goes on?

And in general, would kernel emulation be a performant approach for running userspace of any OS in any other OS?

2 comments

It's more like Wine: the code runs directly on the hardware, but there is an extra layer that emulates the system calls. Except that in this case, the emulation has a lot of supporting code in a kernel driver, something that Wine doesn't have. (Actually, for Win32 programs there is also such a layer, however that layer and the NT kernel were designed together from the start, so it can be pretty thin.)
It's an interesting fuzzy gray boundary between the Ubuntu on Windows and "emulation". It's still built as an NT sub-system (like Interix was), and it's still the NT kernel ultimately in charge of everything. The difference seems to be the NT kernel implementing the generic POSIX standard versus the NT kernel implementing the specific system calls of the Linux kernel. So on one hand it is an emulation because there are specific real world binary behaviors (and quirks and bugs) it's trying to replicate, versus implementing standards from a specification document, but on the other hand, it still seems to be the NT Kernel doing NT Kernel things.
I guess the line is a bit blurry, especially when you factor in fast virtualization techniques that involve running emulated instructions directly :)
Gotcha. Thanks for the explanation! Which would you say was harder, Wine or this? It seems like Wine should have been harder since the NT kernel was designed with multiple userspaces in mind...
Wine is basically reverse engineering a badly documented black box. On the other hand, even though the Linux source is available, Microsoft programmers probably aren't allowed to look at it to prevent their code from becoming a derivative GPL'ed work.
> And in general, would kernel emulation be a performant approach for running userspace of any OS in any other OS?

It can come close to the host OS, but that requires a lot of work.

Would this include stuff like printing to stderr being slower on Windows? If they get to write kernel drivers, there could be a chance that they could replicate the file handling behaviors of Linux.
I don't really know anything about this, but if stderr is really slower on Windows, I would suppose that's a userland library thing. I would not know why that would be slower at kernel level. So that problem might not even arise under the Linux emulation.