The Windows NT kernel is written very advanced and can run on multiple subsystems. For example, in addition to a subsystem for Windows, there was also a system for OS/2 and a system for POSIX. You had to install and enable these two manually, but in Windows NT you can only run POSIX compliant software along with OS/2 binaries and DOS games.
Of course, the code often had to be compiled for the system, but this is often the case with POSIX compatibility. However, there’s nothing stopping you from compiling GCC files from the POSIX environment and pretending you’re using AT&T Unix. You can write UNIX code from start to finish without having to access the Windows API or Microsoft C Runtime.
You can also not only compile the executables and move them to another machine, you also have to install the necessary subsystem on the other machine before you can run the code.
The Microsoft POSIX subsystem from 1993 succeeded Windows Services for Unix, which Microsoft purchased externally. You can only run this system in your Windows 7 installation as long as you have the correct version (Enterprise, Ultimate); I’ve played with that for a while. Without an X11 server, use was limited, and cygwin was a better way to run programs in a Unix-like environment at the time, but it was right there. You can also see the processes in, for example, the task manager and many system maintenance programs did not understand anything.
Microsoft supported this system until 2014, but with Windows 8 they dropped it. In Windows 10, they added WSL again and WSL 1 was similar in design to that of previous subsystems. Unfortunately, emulating a Linux kernel turned out to be too difficult to work well and in WSL2, a different approach was chosen, a well-integrated virtual machine.
Various subsystems allow Microsoft to flip the entire system API if they want to without breaking compatibility. In an alternate world, it wouldn’t be impossible to add a subsystem around Windows Vista for OSX that allows you to run Mac programs with almost complete transparency. Virtualization these days is so cheap that I don’t expect to see a lot of subsystem capabilities anymore, but it’s a great piece of kernel design that not many people are familiar with.
“Lifelong zombie fanatic. Hardcore web practitioner. Thinker. Music expert. Unapologetic pop culture scholar.”