Thursday 5 April 2018

What's Next.. "Cosmopolitan OS"?


A disclaimer first; this is a debatable blog as I am penning down my views on what I see is needed in future operating systems. These are my thoughts on the capabilities an OS should have and is inspired by Microsoft's WSL (Windows Subsystem for Linux) feature. I am open to differing views, so feel free to share your opinion on this.

Let's start with an analogy (I am sure you might have guessed it by looking at the title). Just like a cosmopolitan city is the one where people coming from different cultures and countries live and work together; we aren't far from the time when an operating system will be able to accommodate applications coming from different operating systems (i.e. built for other OS). An operating system where all the applications can live and run on the same kernel. I termed it as a "Cosmopolitan OS".


Let me give you a background of why I am interested in this topic. As a graduate, I was a hard-core Linux fan; with penguins everywhere and no sign of windows (actually I hated Windows in college days). When I started my career, I was too keen to work on projects on different Unix flavors. In fact, I left my first job when they were trying to put me in a Windows project (that was childish). But as my career grew I had to move across different projects and I started embracing all operating systems; (ahem ahem) including Windows. And now my work at Cloudhouse is totally on Microsoft technologies. But whenever I find a Linux terminal, it feels like I am back home :) So, something like WSL obviously fascinates me. First, let's look at other solutions which were introduced to tackle this very issue of Cross-OS applications.


Existing Solutions
As I mentioned in my previous blog post (One App), I think we are heading towards a world where any application can run on any OS. It is easier said than done and only operating system vendors know the level of difficulty involved in building such a mechanism in the OS layers.


There have already been products to run apps built for a specific OS on a different OS like VMWare's Virtual Machine (VM), Sun Microsystem's Java Virtual Machine (JVM), Citrix's Application Layering (Unidesk), DotCloud's Docker, Wine etc. This is a vast topic in itself, so I'll be writing a separate blog in Tech Talk section, on each of these techniques in detail and will explain what I want to convey with the above diagram. To keep this blog short, I'll limit my write up by just highlighting these technologies in comparison to Cosmopolitan OS.

All the techniques mentioned in the above chart were done at different abstraction levels. For example, a virtual machine (VM) creates a totally separate operating system (user mode + kernel mode) running on top of a base operating systems (to learn more about VMs, refer to my earlier blog on tech talk page here). On the other hand, JVM runs Java code within its own runtime environment (called JRE), which makes calls to host OS on which JVM is running. On the other hand, application layering solution like Unidesk carries the OS image as a layer with it. This layer sits above the host OS. Containers like Docker require their own engine (Docker Engine) which makes calls to the host OS. Wine is another great product which translates Windows API Calls into POSIX calls. 



The Sweet Spot!
These all were exceptionally great inventions but none of these techniques were a part of the OS layers itself. Hence they came with their own overheads and issues. On the other hand, a Cosmopolitan OS would have a "translation layer" built as part of its operating system (and not an additional component provided by a 3rd party) and that's a sweet spot. I think that's where its success lies!

Here is how it would look like. The Applications should run with the same ecosystem which they were built for. Hence they need to have native OS's usermode code. Under the hood, the "translation layer" will do the challenging work of making the "guest usermode" code understandable by the "host kernel". I've no idea what kind of difficulty Wine and WSL developers went through to make this happen. Hats off to them!




Is a fully Cosmopolitan OS practically feasible?
I am no expert in this, but I would say YES! My optimism is based on the fact that most of the general purpose operating systems (like Windows, Linux, Mac) originated from the common ancestor (Unix). Although Windows didn't originate from the same code base, initial NT kernel had support for POSIX, hence it shouldn't be too alien to those family of operating systems.



If you think about the fundamental idea behind any OS, the kernel's functionality remains the same. The architecture and file formats might differ (like monolithic or modular OS, FAT or EFS filesystem etc.), but most of the general purpose operating systems do a similar job.

With Windows Subsystem for Linux (WSL), Microsoft took an initiative to make a "Cosmopolitan OS". An OS which can run any application using only one kernel. I'll be writing about my WSL experiments in detail in the Geeky Corner soon. I like calling it "LinWin Experiments" (as its Linux on Windows).

Here is how it would look for different apps running on Windows kernel. Currently, Microsoft doesn't have any support for OS X over Win (but we never know; they might be working on it right now).






LinWin (Windows Subsystem for Linux)

The idea of WSL itself is quite interesting. It was on my ToDo list for a while, got my hands on it now. It's never too late to learn something new :)

In a nutshell, Microsoft took Linux's user mode code and made it into a container (for example Ubuntu container). When you launch this container on Win10, it, in turn, spawns Windows for Linux Subsystem (wsl.exe). This is similar to the OS translation layer in my diagrams (above). It is responsible for translating Linux calls to Win equivalent calls so that Linux applications could run on Windows kernel. 

Let's not get into the technical details in this blog. There is a lot of material on WSL out there if you want to read more about it. I like diving into the nitty-gritty and trying out some experiments by myself. So, that's my pet project this month. Will update my findings in Geeky Corner here

Signing off for now. Stay tuned!

Priya Saxena.

No comments:

Post a Comment