On Thu, Jul 23, 2020 at 4:52 PM Grant Taylor via TUHS <tuhs@minnie.tuhs.org> wrote:
 
Do you have any idea how Windows Subsystem for Linux compares to Cygwin?
  For this use case and / or in general?

Very short version:

First, Windows is a layered OS.  At the bottom is the NT Executive, a fairly conventional kernel.  Running on top of that is the Win32 subsystem (note that this name is used for both 32-bit and 64-bit windows).  Peers of Win32 have existed in the past, notably an OS/2 subsystem and a Posix-compatible third-party subsystem.

Cygwin is a shim DLL that provides a Posix environment to programs running in the Win32 layer of Windows.  It is fairly source-code compatible with Linux.  Cygwin programs and ordinary Windows programs can coexist freely. In particular, they share the same filesystems, and Cygwin programs understand both Posix and Windows pathnames (where C: is mapped to /cygdrive/c).  Most Cygwin APIs are implemented using Win32 APIs, but some require NT Executive APIs.

WSL version 1 is a Linux kernel emulator running on the NT Executive.  It is binary-compatible with Linux (but not with 32-bit Linux programs) as a result, and gets special services from the Executive, including lightweight processes.  (Win32 processes are very heavyweight, which makes long shell scripts like ./configure quite slow on Cygwin.)  There is an X server called Cygwin/X; any other X server for Windows can also be used.

Interoperation allows WSL1 to mount Win32 file systems and exec() Win32 programs (the lightweight process is upgraded to a Win32 process).  WSL1 and Win32 share the same TCP and UDP port space.  Unfortunately, a WSL1 program that tries to invoke a Linux kernel operation not yet supported by the emulator will crash.  The Linux file system is stored in a dedicated section of the Win32 file system; files stored there can be read by Win32 programs but not written.  There is no X server, but once again Cygwin/X or alternatives can be used on the Win32 side.

WSL version 2, which is very new, is an ultra-lightweight VM that can run a Linux kernel.  This means that all kernel services are automatically provided.  The filesystem is a virtual disk formatted as ext4, which gives WSL2 much better local filesystem performance than WSL1.  The same interoperations exist as for WSL1, except that the VM has a different IP address from the Win32 system, so ports are not shared.  The filesystems are fully shared through the 9P2000 (yes!) protocol, allowing Linux to mount Win32 filesystems and vice versa.  Unfortunately the 9P support is not exposed to users.

This may indeed be the year of Linux on the (Windows) desktop.

(Comments and corrections always welcome.)