-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 >I've made a small program to use all processors on a system to analyze >N text files. But when it's run on a 8 CPU PC, the CPU time stays around >70%-80% and the idle time between 20-30%.
Your problem is that you need to ensure your threads get launched, and run, on each available processor. As you may have guessed, your best processor utilization will occur with 8 threads in execution on an 8-way box. In version 2.0 of the .NET Framework MS developed an elegant solution for this. Instead of creating your own threads, you can call ThreadPool.QueueUserWorkItem and pass it a delegate to a static function. This will take complete responsibility for allocating threads from the thread pool, and getting them executed on separate processors. Your overall CPU utilization will shoot up to 100. I don't know if this is implemented in Mono. NOTICE: The information contained in this electronic mail transmission is intended by the sender for the sole use of the named individual or entity to which it is directed and may contain information that is privileged or otherwise confidential. Please do not copy it or use it for any purposes, or disclose its contents to any other person. To do so could violate state and Federal privacy laws. If you have received this electronic mail transmission in error, please delete it from your system without copying or forwarding it, and notify the sender of the error by reply email or by telephone, so that the sender's address records can be corrected. Thank you for your cooperation. -----BEGIN PGP SIGNATURE----- Version: PGP Universal 2.6.2 Charset: us-ascii wsBVAwUBR9Blc8hfyUs+le7yAQgYuwf/ckhuc5iK2sMTLy/cgiiPP02M1R+OTOR1 iTYTF74C8Ux/0NqQ+XuLsLK1kibTeaNBa+DnlQHUkMOa73uTAS9fJEuMSlRRWVGP kCjYp9Z03eEo/3QwntcKd8xFAbUGzgNghnPyMhP5tijEn5W/1Ee3caiq5zxmRBdZ 9BBbe33zTNA7NmS5ipGSWx+xf2vWPrrUY6CYJthIbqyQkFcibYoaMmbkBH5x7P/i 90kxDk2KOsKqQtwVWt/r7ska5PkSfzo4uQP3ml+uQOzw+nazeKM/mjrSTdk73zCF pVYqlwWf7v5pNZP+fnh5OG8dqvk31og4xfEhOoZ9ZYjvfdMVEdDOgQ== =dmad -----END PGP SIGNATURE----- _______________________________________________ Mono-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-list
