1

Obviously, they created a Linux environment for Linux applications to run in Windows. But,

  • What kind of techniques are used for this?
  • Are there any special mechanisms followed?
phuclv
  • 30,396
  • 15
  • 136
  • 260
arulappan
  • 993

1 Answers1

4

There are no such things as Linux emulators

  • If you're talking about Cygwin then they literally reimplement all Unix system calls in terms of Windows API calls in a special userspace DLL file. Programs compiled for Cygwin environment therefore can't run independently in Windows

    Cygwin consists of two parts: a dynamic-link library (DLL) as an API compatibility layer in the form of a C standard library providing a substantial part of the POSIX API functionality, and an extensive collection of software tools and applications that provide a Unix-like look and feel.

    ...

    Cygwin consists of a library that implements the POSIX system call API in terms of Win32 system calls, a GNU development toolchain (including GCC and GDB) to allow software development, and running of a large number of application programs equivalent to those on Unix systems

    https://en.wikipedia.org/wiki/Cygwin

  • If you're talking about the MSYS/MSYS2 family or MinGW then they're not a simulator in any sense. Programs are compiled into native Windows binaries using Microsoft C library and they can run without any special environment

    Although both Cygwin and MinGW can be used to port Unix software to Windows, they have different approaches: Cygwin aims to provide a complete POSIX layer comprising a full implementation of all major Unix system calls and libraries. Compatibility is considered higher priority than performance. On the other hand, MinGW's priorities are simplicity and performance. As such, it does not provide certain POSIX APIs which cannot easily be implemented using the Windows API, such as fork(), mmap() and ioctl(). Applications written using a cross-platform library that has itself been ported to MinGW, such as SDL, wxWidgets, Qt, or GTK+, will usually compile as easily in MinGW as they would in Cygwin.

    https://en.wikipedia.org/wiki/MinGW#Comparison_with_Cygwin

  • In Windows 10 MS introduced which is really a Linux simulator and not an emulator, just like how Wine is not an emulator. They have a special kernel component to handle Linux system calls and convert them to Windows version in order to run native Linux ELF binaries without recompiling

    WSL is a collection of components that enables native Linux ELF64 binaries to run on Windows. It contains both user mode and kernel mode components. It is primarily comprised of:

    • User mode session manager service that handles the Linux instance life cycle
    • Pico provider drivers (lxss.sys, lxcore.sys) that emulate a Linux kernel by translating Linux syscalls
    • Pico processes that host the unmodified user mode Linux (e.g. /bin/bash)

    Block chart

    WSL executes unmodified Linux ELF64 binaries by virtualizing a Linux kernel interface on top of the Windows NT kernel. One of the kernel interfaces that it exposes are system calls (syscalls). A syscall is a service provided by the kernel that can be called from user mode. Both the Linux kernel and Windows NT kernel expose several hundred syscalls to user mode, but they have different semantics and are generally not directly compatible. For example, the Linux kernel includes things like fork, open, and kill while the Windows NT kernel has the comparable NtCreateProcess, NtOpenFile, and NtTerminateProcess.

    https://blogs.msdn.microsoft.com/wsl/2016/04/22/windows-subsystem-for-linux-overview/

    Note that its successor WSL2 (released in 2019) is completely different. It's not a simulator anymore and runs in a real Linux VM

In the past there were also Microsoft POSIX subsystem and Windows Services for UNIX but they're not meant to run Linux. For more information read

phuclv
  • 30,396
  • 15
  • 136
  • 260