Sunday, 8 April 2018

WSL in a Nutshell

Windows Subsystem for Linux is a feature released in 2016 by Microsoft to run Linux binaries natively on Windows 10. I've written this blog while doing some experiments on WSL to summarise key points which I've learned. These are taken from Channel 9 videos where Microsoft's WSL team members have explained the concepts clearly. Also, Jessie Frazelle's blog is a good read to understand the internals. 



WSL Key Points
Here is a diagram from Microsoft's WSL blog explaining the overall architecture.



















I am writing down my notes from Architectural Overview video. Please go through the video if you have time.


As soon as WSL is launched (either using wsl command or linux apps like Ubuntu), bash.exe is invoked which sends a call to lxss Session Manager service using COM interface. Lxss session manager then triggers an ioctl call to lxss/lxCore to create the actual Linux instance. lxss/lxCore is the PICO Provider. It a driver emulating Linux kernel operations and coordinating with NT Kernel to translate system calls. It can be very loosely compared to a light-weight Linux kernel layer built on top of Windows kernel. I would say this is a stacked kernel architecture. Its a way of abstracting Linux kernel via the Linux kernel interface. NT kernel doesn't understand binaries in EFL format. So, it depends on lxss/lxCore component to handle the Linux binaries.

Lxss subsystem then spawns a Linux Instance which is like a container or virtualized OS. It contains PICO processes made up of unmodified Linux binaries (like bash, vim etc.). For each command executed from bash.exe, the lxss session manager makes a call to lxss/lxCore subsystem in kernel mode. Then the session manager spawns init process (in the context of that Linux instance). Init then spawns bin/bash or vim tasks (which are unmodified Linux binaries)

I'll be updating this blog as I keep exploring and understanding more about WSL. I'll also keep updating my experiments in the Geeky Corner.


Priya Saxena.

No comments:

Post a comment