Migrate device control applications from Windows to Linux

Source: Internet
Author: User
Article Title: migrate devices from Windows to Linux to control applications. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Understanding Microsoft Windows®And Linux®Operating System Device control principle, this article will simplify®To Linux®Migrate device control applications. The author analyzes the differences between the two and provides C/C ++ examples.

If you have developed device control applications on different platforms, you must understand the differences in Device Control Methods between Windows and Linux. It is quite complicated to migrate applications from one platform to another. This article analyzes the device control principles of the two operating systems and explores the differences from architecture to system calls. This article also provides a migration example (written in C/C ++) to illustrate the migration process in detail.

Working conditions:
According to the purpose of this Article, "Windows" refers to Windows 2000 or later versions, and Microsoft Visual C ++ is installed®6.0 or later versions. Linux should be based on the 2.6 kernel and installed with gnu gcc.

Compare the architecture of Device Control

The Control Methods for Windows and Linux devices are different.

Windows Device Control Architecture

The Windows I/O subsystem associates user applications with device drivers and defines infrastructure support for device drivers. The Device Driver provides an I/O interface for a specific device (see figure 1 ).


Figure 1: Windows Device Control Architecture

During Device Control, I/O operations are encapsulated as IRP (I/O Request Packet ). The I/O manager creates an IRP and sends it to the top of the stack. Then, the device driver obtains the stack address of the IRP. IRP contains the parameters of the I/O Request. Each driver works through a hardware interface based on the request contained by the IRP (such as creating, reading, writing, device I/O control, clearing, or disabling.

Linux Device Control Architecture

The device control architecture of Linux is different. The main difference is that common files, directories, devices, and sockets in Linux are files-everything in Linux is files. To access the device, the Linux kernel maps device operation calls to the device driver through the file system. Linux does not have an I/O manager. All I/O Requests enter the file system from the beginning (see figure 2 ).


Figure 2. Linux Device Control Architecture
 

Compare the device file name and path name

From the perspective of development, obtaining a device handle is a prerequisite for Device Control. However, due to the differences in the device control architecture, obtaining the device handle varies with the Platform (Windows or Linux.

 

[1] [2] [3] [4] [5] Next page

Related Article

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.