As we know, WSL or Windows Subsystem for Linux is a pretty handy tool, it helps you use the Linux command line on windows, no dual boot or partitioning required
Yeah I won't beat around the bush more, lets learn about its architecture
WSL versions
There are 2 versions of WSL now
- WSL 1: The more widely used version now
- WSL 2: The fairly newer and faster one
Both of them have fairly underlying architectures, so I will be explaining them separately
WSL 1
So WSL 1 works using a translation layer, it has unmodified binaries for applications such as apt, grep, etc
When these libraries make a system call, such as accessing memory or network, they would usually make a request to the Linux kernel, while in WSL, it requests the translation layer, the translation layer converts the UNIX system call to a call compatible with the Windows NT kernel.
This worked great but the problems are obvious, passing every system call through a translation layer would result in performance hits, and wouldn't have all of the system calls translated which may result in commands failing to execute due to an unmapped system call, this resulted in the making of WSL 2
WSL 2
The WSL 2 moved into a virtualization-based approach in which you have an actual Linux kernel sitting inside a very lightweight VM
powered by the Windows Hypervisor Platform. This made file IO much faster due to the avoidance of the translation layer
This resulted in full system call compatibility and much better performance overall
Conclusion
I am pretty sure this article gave you a rough understanding of how WSL works, I will link more comprehensive articles about the architecture but this is a high-level idea about the same
Some articles for the same include
https://docs.microsoft.com/en-us/windows/wsl/faq
https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux
btw, If you do find any factual errors, please comment about it below so I can correct them
This video was hugely inspired by This video by Microsoft, do check it out
Bye
Top comments (2)
Thanks for the article
Thanks for reading