Restrict CPU usage for a software program

S

Thread Starter

Siebe Dijkstra

I've written a little program (Labwindows) that communicates to a plc to take some data and chart it. At certain times it prints this chart to 'pdf'
files. During the chart printing it slows down the processor and the CPU is loaded 100% (Windows NT taskmanager) for about 10-20 sec. This slows
down other (more important) tasks. During normal operation CPU load is around 30-40%

Is there a way in NT to limit my program to say 50% CPU usage? The software has a very low 'priority' compared with the other tasks. Also it is no issue if the chart printing takes a little longer.

thanks in advance,

Siebe Dijkstra
 
If your program is the lowest priority task, you are not degrading the system even when CPU usage is at 100%. All this means is that your task
is running instead of the system idle task.

But if you say the other tasks are slowed down, in fact, the priority of your printing task is not really the lowest. Did you actually measure a slowdown?

The simplest thing is to simply put in some Sleep instructions, which are available in most languages. If you can break your calculations into 1% slices, you can sleep for 100 milliseconds between slices, to allow the other stuff to run. This'll add about 10 seconds to the elapsed time of your process.

Maybe that'll be all you need.

Rufus


 
J

Johan Bengtsson

If the software have a low priority it should fix itself completely since lower priority tasks simply don't get any processor time in NT when some higher priority task wants it.

I wonder if it really is the application taking that time or if it might be some driver.
In the NT taskmanager: go to the tab showing a graph over processor and memory usage, in the menu select view/show kernel times. You should now have one green and one red line in the processor usage graph. If the red one rises a lot you have a driver (such as the IDE driver) taking a lot of processor time.

If that is the problem I really think you should fix that (the computer will be a *lot* more responsive if you do)

I would suggest looking at % CPU in the "Processes" tab also to check what process really uses the CPU.

If the printing is done by launching another process it might be possible that this new process don't have lower priority. In this case you might be able to solve it by rising the
priority of your other (more important) tasks, This might be a good idea if they are tasks that are needed to get CPU-time at regular intervals, but be aware that rising priority of a process can make the entire system respond less to keystrokes/mousemoves/etc. This is normally not a problem if the high priority processes do little computing and releases the processor often.

You might need to check if it is a memory bottleneck too, in that case you can get a lot of extra CPU-time by the increased need of swapping memory and if you have a bad IDE-driver (consuming
lots of CPU time) and your swap file is located on that this can be really significant.

Some ideas, I don't have any direct answer (others might and I would like to hear that too if they have...) but as I said it should not be a problem at all if the processes have very
different priority.

/Johan Bengtsson

----------------------------------------
P&L, Innovation in training
Box 252, S-281 23 H{ssleholm SWEDEN
Tel: +46 451 49 460, Fax: +46 451 89 833
E-mail: [email protected]
Internet: http://www.pol.se/
----------------------------------------

 
R

Ranjan Acharya

Try looking at a copy of the book entitled "Windows NT Performance:
Monitoring, Benchmarking and Tuning" by Edmead and Hinsberg. ISBN 1-56205-942-4. My copy cost me CDN$42.95, a little pricey, but that always
seems the case with these types of books. It takes you through various methods of system analysis so that you can pinpoint the source or
performance problems on any NT system. Having the NT Resource Kit is also helpful. There are tuning tools in that kit including CPU prioritisation aids.

I should note from my own experience, that normally it boils down to poor choices of underlying hardware (e.g., using plain old IDE with FAT rather than some sort of high-speed SCSI-3 with RAID and NTFS). Badly written software does not help either.

Good Luck

Ranjan
 
G

Guy Van den Broeck

I was just looking for people on the net which also had some incidents with high processor usage. For quite a time I'm having problems with VIA 4-1 drivers(V4.37) They should control my IDE bus traffic but when I want to write or read a CD they don't get to nominal performance.
I'm running XP PRO so I don't think it's my ASPI layer which is bad (Or am I wrong here???)

I hope someone get's in touch with me so we could plan ourselves a way out. (I fixed it once but I don't know why it doesn't work now) Is it XP ??? Bàààààààààààààd Microsoft :c

Please mail me or contact me with MSN chat for a smoother way of conversation. Thanx
 
Top