Search code examples
c++multicorecpu-cores

Setting process core quotas with C++


If you write software where the customer pays for the number of CPU cores the software uses, then what would be the best way of achiving this in your C++ code? My research so far has led me to use SetProcessAffinityMask on Windows and sched_setaffinity on POSIX systems.


Solution

  • I think you found the best option. Limiting the number of threads is not a good idea if you want to take advantage of the capabilities of multithreaded processors.