Home > Backend Development > C++ > Why Are There Extra Threads in Simple C Programs on Windows 10?

Why Are There Extra Threads in Simple C Programs on Windows 10?

Linda Hamilton
Release: 2024-10-27 17:59:01
Original
240 people have browsed it

Why Are There Extra Threads in Simple C   Programs on Windows 10?

Windows 10's Thread Pool in Action

Why does Windows 10 introduce additional threads in an ostensibly simple C program? This question arises when comparing the behavior of such a program on Windows 7 and Windows 10. While Windows 7 shows only one thread in the debugger, Windows 10 displays five threads, including four "worker threads."

The key to understanding this phenomenon lies in the role of the loader, ntdll.dll, on Windows 10. By setting a breakpoint on the TppWorkerThread() function, the entry point for thread-pool threads, we can capture the stack trace of the first threadpool thread being created.

The stack trace reveals that the loader is utilizing the threadpool to load DLLs on Windows 10. This concurrency allows Windows 10 to take advantage of multiple cores, resulting in faster process initialization.

Therefore, the additional threads seen in a simple C program on Windows 10 are a byproduct of the loader's optimization techniques. This behavior is intended to enhance performance and can be attributed to Windows 10's advancements in resource management.

The above is the detailed content of Why Are There Extra Threads in Simple C Programs on Windows 10?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template