Search code examples
c++visual-c++shellexecute

Limited CPU load in external program executed from c++ application


My application written in Visual C++ executes an external program with system function call. A system command is a call of stereoscopic player instance with certain stereo 3D video file and fullscreen mode passed as parameters.

The problem is that stereoscopic player called from C++ app plays video very slowly. Executing the same command from Windows cmd doesn't cause such behaviour.

When I run built-in Windows CPU load analyzer I get the following results (I can attach a screenshot if needed):

  • The stereoscopic player instance executed from cmd loads all available cores simultaneously for 40-50% each (I tried with 2 and 4 cores on different machines).
  • The stereoscopic player instance executed from C++ app loads the first core for 90-100% and doesn't load other cores.

How can I solve this problem?


Solution

  • Try using SetProcessAffinityMask for the process you are spawning