windows xp - How can I reduce high CPU usage from DPC's with USB Serial Ports

06
2013-08
  • rossmcm

    I have an app that communicates with up to 50 devices over serial ports. The communication takes place in threads, and the threads are throttled so that only a certain number are active at once. The threads are created as required, do their work, and terminate and free their used resources.

    In some instances the serial ports are implemented with Moxa TCP/IP Ethernet ports. A Moxa driver runs on the PC which exposes the Moxa devices on the network as a COM Port.

    In other cases the serial ports are implemented via USB hubs that provide 10 serial ports each.

    Here's the problem. When only the Moxa serial ports are used, and (say) 8 are enabled, the CPU usage of the app wavers between 1% and 30%, depending on how many threads are active. The app behaves sensibly and the PC is responsive.

    When 8 USB ports are then enabled, the CPU usage of the app peaks at 50-60% as I would expect, but the total PC CPU usage climbs to near 100% and stays there. Not surprisingly everything grinds to a halt.

    I used Process Explorer and found that the bulk of the CPU usage outside of my app was in two tasks - System Idle Process/DPCs (Deferred Procedure Calls) and System Idle Process/System. The usage in these tasks peaks at around 40% each. When only Moxa ports are in use, these tasks show no significant CPU usage.

    I've tried messing with the thread priority and it makes no difference. The ports run at a relatively low baudrate (2400).

    Running a DPC latency checker tool shows up to 6ms latency when the USB serial ports are in use.

  • Answers
  • rossmcm

    The high CPU usage stemmed from the fact that in the application each channel opened its serial port at the start of the session and kept it open for the duration of the application session. This was fine with ports based on the Moxa ethernet-to-COM Port adapters, or with "local" ports, but in USB ports, just having the port open causes DPC CPU usage. Having 16 USB ports open makes the PC unusable, despite there being no traffic on any port.

    I changed the app so that the ports are opened whenever they are required (which is only for a few seconds every minute or so) and closed immediately afterwards.


  • Related Question

    windows xp - Task Manager shows 100% CPU utilization, but nothing in process list does
  • nathan

    I'm using WinXP, and I notice that in the Task Manager, on the Performance tab my CPU usage is 100%. But When I go to the Processes tab, and sort by CPU System Idle Process is taking up 90%. I've double checked that things like AVG anti-virus isn't actively scanning, and that jkdefrag is not defragging. But I know something is taking CPU cycles, because the machine is very slow. How do I determine which process is hammering the CPU if it doesn't show in the Process List?


  • Related Answers
  • Greg Hewgill

    Process Explorer is a much better tool for inspecting processes than the built-in Task Manager. While it might not answer your question completely, it may give you more insight into the problem.

  • heavyd

    Make sure that the "Show processes from all users" checkbox is checked at the bottom of the process list in Task Manager, so that all processes are show.

  • Paul Woodward

    I was having a similar problem a couple of days ago and it turned out the machine was infected with a Rootkit. Since removal things seemed to have calmed down.