Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. C / C++ / MFC
  3. CPU 100% ( Windows NT)`

CPU 100% ( Windows NT)`

Scheduled Pinned Locked Moved C / C++ / MFC
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kumar
    wrote on last edited by
    #1

    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.

    M D 2 Replies Last reply
    0
    • K 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.

      M Offline
      M Offline
      Member 1208965
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • K 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.

        D Offline
        D Offline
        Dark Angel
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups