Cultivation of "internal strength" by Windows programmers

Source: Internet
Author: User

Note: This blog is excerpted from the recommendation sequence of a book (bamboo path-go to Windows driver development.

 

I have always thought that programming is a wonderful thing, and it can bring about the desire to create and control. Whenever I read or write a piece of code, I naturally imagine how this piece of code completes the predefined logic. When faced with an unfamiliar development environment or a new basic platform, you must first understand how the environment or platform works and what functions are provided. The Code itself may be very complex and even fascinating, but in general, truly beautiful high-quality code is often simple and easy to understand. For code writers or maintainers, it is not the Code itself, but the ability to understand and control the lower-level development platform. It may be called "internal strength ".

This idea applies to both application software programmers and system software programmers. For application software programmers, the low-layer application development platform is the basis for supporting application development. For example, to develop Windows applications based on the Windows SDK, it is necessary for programmers to understand the basic elements in the Windows SDK, such as message distribution mechanism and various graphical functions. In this case, reading typical examples of program code can quickly lead the entry. Similarly, if a C/C ++ programmer is confined to the C/C ++ language itself, it is difficult to compile high-quality utilities. They should not only master the usage of functions and types in the C/C ++ Runtime Library, but also understand the implementation mechanisms of these functions and types. Even if libraries at the source code level, such as STL (standard template library of C ++ ), you also need to understand its code implementation to make use of these libraries flexibly (such as various container data structures, iterators, or algorithms in STL ).

So what is "internal strength" for system software programmers? System software refers to the software that the operating system itself or is attached to the operating system to provide services for the application software. System software may have the opportunity to deal directly with hardware, which gives programmers more control capabilities, they have the opportunity to intervene in the operating system's behavior logic, and even change the operating system's behavior characteristics. However, there is a higher requirement for system software code. Modern Operating systems provide strong fault tolerance capabilities for application software. application failures do not affect the stability of the operating system. However, the operating system has limited Fault Tolerance capabilities for system software, after all, the system software may be integrated into the operating system's execution logic as part of the operating system. Therefore, understanding and understanding the operating system mechanism has become the basic prerequisite for system programmers to compile correct and efficient system software. The so-called "internal strength" is here.

Developing software on Windows platforms, writing Windows Kernel drivers is the most challenging for programmers. The amount of kernel driver code is usually small, but any function in the driver framework, or even any line of code in these functions, may have complicated logic behind it, or implicit requirements and assumptions. Even if drivers are purely self-defined functions, they must be cautious about environment-related factors, such as whether the code can be interrupted or reentrant, or whether the referenced memory is switched to external memory. On the other hand, many concepts in application software development, such as address space, memory management, exception handling, and multi-thread concurrency, may require different understanding methods in driver development. In addition, the commonly used C Runtime library functions are basically no longer suitable for drivers, and driver writers must face a completely new underlying environment and support platform. Therefore, to compile a correctly running driver, the programmer must not only understand the target device or function (which may include the features of hardware devices) of the driver ), we also need to know how the Windows Kernel deals with drivers, as well as many management and operation mechanisms in the kernel, especially memory management, thread scheduling, and concurrency control.

When the Windows Kernel drivers are loaded into the kernel and started, they become part of the Windows Kernel. The interface functions in the driver are called by the kernel at the right time, this is the basic way for Windows drivers to work. Microsoft defines the WDM (Windows Driver Model) to define the driver structure and how the Windows Kernel interacts with the WDM driver. WDM not only includes the driver framework defined by the I/O manager, but also defines how the driver supports PNP (Plug and Play, plug-and-play), power management and WMI (Windows Management Instrumentation, Windows Management specifications ). Therefore, to write a driver that fully supports WDM, you also need to understand the various kernel components involved in WDM.

To facilitate the development of Windows drivers, Microsoft defines a driver framework called WDF (Windows Driver Foundation ).
Driver framework ). Kmdf is actually a library, which encapsulates some basic code logic in WDM, so that programmers can compile the WDM driver more conveniently. Kmdf can partially simplify the development tasks of the Windows kernel driver, but it does not actually reduce the complexity of the kernel driver, and even requires additional learning efforts from programmers.

All in all, as a system programmer, you need to understand the components of the target operating system dealing with your software, you also need to be very clear about how the development tools you depend on help you achieve this. System programmers often face a longer learning curve than application programmers. However, the pleasure that system programmers get from programming is also hard to understand at the application layer.

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.