Virtual Machine Technology Overview 4-virtual machine at the API Layer

Source: Internet
Author: User

The typical representative of the API-layer virtual machine is the open-source project wine, which constructs an adapter layer between a Windows user-mode application and other operating systems ), when these applications need to call a Win32 API function in other operating systems, wine converts the call to a simulated Implementation of the function in the corresponding operating system.

The function of the wine system in the entire running environment can be understood from three perspectives.

L from the perspective of Windows applications, wine provides simulation of the Windows software runtime environment. However, this is not a simulation of processor commands, but a simulation of Win32 API functions.

L from the perspective of Linux and its kernel, wine forms an intermediate layer between the Linux kernel and Windows applications. On the one hand, it provides a complete dynamic link library (DLL) for Windows applications ), on the one hand, it converts Windows system calls in applications and dynamic link libraries into Linux system calls with similar semantics.

L from the perspective of Windows dynamic Connection Library and service process, wine is a key component of windows that is simulated on Linux.

 

 

Figure 1 wine Architecture

Wine does not contain any Linux kernel module, that is, all components of wine are implemented in user mode. Wine needs to simulate Windows system calls in Linux User Mode Based on Linux system calls. However, system calls are similar to function calls. It is very difficult to make the two "function calls" completely consistent in the call context, input parameters, function semantics, and returned results. To make up for this semantic gap in the user State, wine introduces the wine Server service process.

As shown in figure 1, wine constructs an adaptation layer between Windows application software and Linux kernel, including a wine service process (wine server) and a group of Windows dynamic connection libraries. In addition, wine's simulation of user interface APIs still relies on X server. When running a Windows application, wine needs to interact with three processes:

L windows application process. This process forwards Windows API function calls layer by layer through various dynamic connection libraries provided by wine until the Linux kernel system calls. In wine, the process needs to communicate with the wine service process through socket and pipe interfaces to call the system functions provided by the wine service process and manage the service process. Windows application processes running on wine are loaded from wine jobs.WineMigrated,WineEstablish a connection with the wine service process for the running of the application, load the target program, and finally transfer it to the entry function of the Target Program (WinmainFunction) to start running.

L wine service process. This process provides communication and synchronization between Windows processes, management of Windows processes and threads, registry services, and management of various Win32 objects. The wine service process does not conflict with the related services provided by the Linux kernel for management of processes and inter-process communication. Therefore, it only provides components that do not exist in the Linux kernel or are incompatible with the Windows kernel. The wine service process is actually providing Remote Procedure Call (RPC) for Windows applications ). It can be said that the wine service process is the core of the entire wine platform. Through this service process, wine constructs a virtual "Windows Kernel" in the user space ". The purpose of the wine service process is to make up for the differences between the Windows Kernel and other operating system kernels in the user mode. Although the remote process call method reduces the performance to a certain extent, but it also avoids the potential instability caused by modifying the Linux kernel.

L x service process. This process provides GUI services, graphical display and output, and keyboard and mouse input in non-Windows operating environments.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.