c++ - Why does Windows 10 start extra threads in my program? -


with visual studio 2015, in new, empty c++ project, build following console application:

int main() {     return 0; } 

set break point on return , launch program in debugger. on windows 7, of break point, program has 1 thread. on windows 10, has five(!) threads: main thread , 4 "worker threads" waiting on synchronization object.

who's starting thread pool (or how find out)?

crystal ball says debug > windows > threads window shows these threads @ ntdll.dll!tppworkerthread. sure enable microsoft symbol server see yourself, use tools > options > debugging > symbols.

this happens in vs2013 not caused new vs2015 diagnostic features, @adam's guess cannot correct.

tppworkerthread() entrypoint thread-pool thread. when set breakpoint debug > new breakpoint > function breakpoint on function. got lucky capture stack trace 1st threadpool thread when 2nd threadpool thread started executing:

    ntdll.dll!_ntopenfile@24()  unknown     ntdll.dll!ldrpmapdllntfilename()    unknown     ntdll.dll!ldrpmapdllsearchpath()    unknown     ntdll.dll!ldrpprocesswork() unknown     ntdll.dll!_ldrpworkcallback@12()    unknown     ntdll.dll!tppworkpexecutecallback() unknown     ntdll.dll!tppworkerthread() unknown     kernel32.dll!@basethreadinitthunk@12()  unknown     ntdll.dll!__rtluserthreadstart()    unknown >   ntdll.dll!__rtluserthreadstart@8()  unknown 

clearly loader using threadpool on windows 10 load dlls. that's new :) @ point main thread executing in loader, concurrency @ work.

so windows 10 taking advantage of multiple cores process initialized faster. feature, not bug :)


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -