CPU 100% ( Windows NT)`
-
Hi All, I am working on a telecom project. I am facing CPU 100% problem. Can any one tell me different reasons for a system CPU to reach 100%. I am reading a telephon number from a text file after that dialing the same number. After successfully done I am deleting the text file and updating the counter in DataBase (SQL). All these operations are done within a thread. The Application is a multithreaded application. I am not able to trace why the system CPU is reaching 100%. OS is Windows NT. Waiting for your suggestion(s). Thanks in Advance. Kumar.
-
Hi All, I am working on a telecom project. I am facing CPU 100% problem. Can any one tell me different reasons for a system CPU to reach 100%. I am reading a telephon number from a text file after that dialing the same number. After successfully done I am deleting the text file and updating the counter in DataBase (SQL). All these operations are done within a thread. The Application is a multithreaded application. I am not able to trace why the system CPU is reaching 100%. OS is Windows NT. Waiting for your suggestion(s). Thanks in Advance. Kumar.
In multithreaded programming, you must be careful not to monopolize the CPU. The OS of course looks after scheduling, but it's up to you to let the OS know that you don't need every available timeslice for your loop. A simple thing to do is to Sleep() your thread for a reasonable period of time between checks to see if it has work to do. As a simple test, try putting Sleep(500) somewhere inside your loop and see what kind of effect it has on your CPU usage. You likely should architect a more elegant solution than a simple Sleep() call, one that better matches your program logic, but this should get you started. You should also check out WaitForSingleObject() and its cohorts, it may make sense for your app.
-
Hi All, I am working on a telecom project. I am facing CPU 100% problem. Can any one tell me different reasons for a system CPU to reach 100%. I am reading a telephon number from a text file after that dialing the same number. After successfully done I am deleting the text file and updating the counter in DataBase (SQL). All these operations are done within a thread. The Application is a multithreaded application. I am not able to trace why the system CPU is reaching 100%. OS is Windows NT. Waiting for your suggestion(s). Thanks in Advance. Kumar.
If the application is multithreaded, I would guess that one of the threads is spinning in a while loop, possibly waiting for something to happen. With a thread procedure like: while(1) { WaitForSingleObject(..., 0) <- zero timeout } You can get 100% CPU utilization in a thread. Changing the timeout to 1 millisecond will fix this. Another possibility is that a thread in the database driver is using 100% of CPU time or something is polling and wating for the phone to connect. Hope this helps Peter