I used MinGW-w64 to compile a simple "Hello World" C program on windows. When I ran the executable on a windows 10 machine, I observed from windows task manager that there was one more thread other than the main thread be spawned. After a couple of seconds, this additional thread died. I have no idea what this thread is and what piece of code this thread executes. If I run the same executable on a windows 7 machine, I always observe only 1 thread.
The version of my MinGW-w64 compiler is:
Using built-in specs.
COLLECT_GCC=j:\3rdparty\internal\1103350\win64\MinGW\bin/gcc COLLECT_LTO_WRAPPER=j:/3rdparty/internal/1103350/win64/MinGW/bin/../libexec/gcc/x86_64-w64-mingw32/4.9.2/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-4.9.2/configure --build=x86_64-w64-mingw32 --enable-targets=all --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-libgomp --enable-lto --enable-graphite --enable-cxx-flags=-DWINPTHREAD_STATIC --disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-libstdcxx-debug --enable-threads=posix --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libstdcxx-threads --enable-libstdcxx-time --with-gnu-ld --disable-werror --disable-nls --disable-win32-registry --prefix=/mingw64tdm --with-local-prefix=/mingw64tdm --with-pkgversion=tdm64-1 --with-bugurl=http://tdm-gcc.tdragon.net/bugs
Thread model: posix
gcc version 4.9.2 (tdm64-1)
My windows 10 Pro version is 1511.
This behavior is nothing new, and absolutely unrelated to Windows 10. Each process on Windows NT (and above) are presisent at minimun out of 2 threads. One is the worker-thread itself, and the second is related to wait for process-termination (IIRC). So there is nothing to be concerned. Our crt itself don't spawn threads.
Thanks for your quick reply Kai! But then why I only observe 1 thread when I run the same excutable on Windows 7?