I have been asked twice how iocp works (the operating system works, not the function), so I think it is necessary to write it down. After searching for the Internet for half a day, I wrote some functional implementation principles and did not mention the important points. In the last interview, the technical director told me that the book "Windows Advanced Programming Guide" has mentioned this, I came back and checked it out. I did have a detailed explanation on page 614, but I don't quite understand it. I 'd like to introduce the original article first:
Conclusion: The goal of port completion is to make the number of threads in the release thread (running thread) List and the number of concurrent threads specified when it is created (the last parameter of createiocompletionport, generally, the number of CPUs is the same. If one thread in the release thread list enters the waiting state and the release thread list becomes smaller, the other thread will be released after the completion of the port. Therefore, the number of threads to be created should be greater than the specified number of concurrent threads. Generally, the number of CPUs is * 2 + 2, which is said to be the optimal number of threads.