Windows Server programming-Chapter 2 Communication Between device I/O and threads-1

Source: Internet
Author: User

When I was working on a project a few years ago, I referred to the book Programming Server-Side Application For Microsoft Windows 2000, which was written by the famous Jeffery Rechard and the author of Windows core Programming. At that time, the second chapter was translated for others in the Working Group. Today, I have sent this old article to enrich my blog and hope to help others.

Chapter II Device I/O Communication with threadsI cannot fully express the importance of this chapter. This chapter covers two essential topics for high performance and scalable applications: device I/O and inter-thread communication. A Scalable Application should be as efficient as processing a small amount of concurrent transactions when processing a large number of concurrent transactions. For service applications, a typical operation is to process irregular client requests, and the processing capability required for this request is unpredictable. These requests often come from I/O devices, such as network adapters. Generally, requests are processed with additional I/O operations, such as disk file access. For Microsoft Windows applications, threads are the best mechanism for splitting jobs. Each thread is assigned to a processor, so that a machine with multiple processors can execute multiple operations at the same time to increase throughput. When a thread submits a device I/O Request, the thread is temporarily suspended until the device completes the I/O Request. This suspension seriously reduces the performance, because the thread cannot do other useful work at this time, such as initializing another client request and processing it. Therefore, simply put, you should keep the thread busy and do useful work, rather than simply suspending it. To keep the threads busy, inter-thread communication is required so that the threads can understand each other's operations. Microsoft has spent several years researching and testing in this field, and has developed a good mechanism for inter-thread communication. This mechanism is called the I/O completion port, which can help you create high-performance, scalable applications. One example is the new Job kernel object (Job kernel object) in Windows 2000: when a Job object is monitored for an operation, it needs to be processed, it sends a notification event to an I/O completion port. Examples of JobLab applications can be obtained from Programming Application For microsoft Windows, Forth Edition (Windows core Programming, this example describes how to enable I/O to complete port and task object work together. Based on years of Windows development experience, I found that more and more people are using I/O to complete the port. I feel that every Windows developer must thoroughly understand how I/O completes the port. Many sample programs in this book use I/O to complete the port. Even if I describe the I/O completion port in the topic of device I/O in this chapter, note that the I/O completion port is not completely for the device I/O, simply put, it is a recognized inter-process communication mechanism for handling infinite requests.

Based on the above comments, you may think that I am the big fans of the I/O completion port. I hope that after this chapter, you will become a fan of me. Before learning about the I/O completion port details, I will describe how Windows originally provided inter-thread communication and device I/O support to developers. This will bring you a lot of experience on the I/O finished port. At the end of this chapter, I/O Completion Ports will be discussed in detail in the "I/O Completion Ports" section.

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.