6.5. Matching the Number of Threads to the Number of CPUs
When you run a compute-bound program on a Windows 2000 machine that has multiple CPUs, you should split the computation portion of the program into a set of threads whose number matches the number of CPUs. For example, in the Mandelbrot program seen in the previous section, you would create one redrawing thread for each CPU that is available. Each redrawing thread can handle a portion of the image. Windows 2000 will run each separate thread on a different CPU, so the program will make maximum use of the CPU power available. Listing 6.10 demonstrates how to split the Mandelbrot program into multiple threads.
Code Listing 6.10. A multi-threaded implementation that will create one thread ...
Get Win32 System Services: The Heart of Windows® 98 and Windows® 2000 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.