How to get number of cores in Win32?

前端 未结 5 909
渐次进展
渐次进展 2020-12-11 17:50

I\'m writing a program in C on windows that needs to run as many threads as available cores. But I dont know how to get the number of cores. Any ideas?

5条回答
  •  臣服心动
    2020-12-11 18:39

    You can call the GetSystemInfo WinAPI function; it returns a SYSTEM_INFO struct, which has the number of processors (which is the number of cores on a system with multiple core CPUs).

提交回复
热议问题