Page 1 of 1
CPU Load
Posted: Mon Feb 01, 2010 1:26 pm
by mwood
My netburner application has grown quite large and I'm having concerns that the cpu may be overloaded so I would like to be able to monitor cpu usage. I've looked through the documentation and haven't found anything helpful, maybe I'm overlooking something. This would seem to be a common issue. Does someone know a good way to measure the cpu load?
Re: CPU Load
Posted: Mon Feb 01, 2010 2:18 pm
by tod
A quick way to monitor is to have the lowest priority task in your app (or create an add'l task for this purpose) wake up every tick (or less frequently if you really think the CPU is starving) and do something like std::cout <<"."; You can tell quite a bit from the frequency of the dots. If you're CPU starved you won't get any, if it's a really heavy load you aren't going to get as many as you expect. This is a fairly intrusive way to test but it's all I've ever needed.
You may want to create an empty project with this technique to get a baseline.
Re: CPU Load
Posted: Mon Feb 01, 2010 3:43 pm
by mwood
Thanks, I'll give it a shot. This may take a while to code since my app runs remotely and I don't have access to serial out. I'm using the web server for interaction so I'll need to put a "CPU Usage" indicator in the web page. I'll let you know how it goes.
Re: CPU Load
Posted: Mon Feb 01, 2010 5:54 pm
by Ridgeglider
TWO methods: (from a previous post by Paul:)
edit nburn\include\predef.h and uncomment
#define UCOS_STACKCHECK (1)
Recompile everything.
1)By using taskscan:
#include <taskmon.h>
EnableTaskMonitor();
Then use the taskscan application (see C:\Nburn\docs\NetBurnerPcTools\NetBurnerTools.pdf).
This will report the stack usage, current and max on a per task basis. If you creat the tasks using either:
OSTaskCreatewName() or OSSimpleTaskCreatewName(), the name of each task will also be reported.
By the way NB folks, neither OSTaskCreatewName, nor OSSimpleTaskCreatewName() are described in
C:\Nburn\docs\NetBurnerRuntimeLibrary\uCOSLibrary.pdf although there is an example in C:\nburn\examples\RTOS\OSFlags\main.cpp
2)The other choice is to call
void OSDumpTCBStacks( void );
(see "OSDumpTCBStacks" in C:\Nburn\docs\NetBurnerRuntimeLibrary\uCOSLibrary.pdf )
This prints out stack info to stdout.
Re: CPU Load
Posted: Tue Feb 02, 2010 10:09 am
by lgitlitz
I have a time slice profile utility that may be helpful. What this does is trigger a level 7 interrupt at a certain time interval and record the address of the program counter. It will then print a list of the addresses and how many times each occurred out the debug port. You can then use the winaddr2line pc tool to determine what line of code the address corresponds to. This is set up for the 5270 platforms but should be easily converted for the ether platforms. It also should be somewhat easy to adjust the granularity of the counter if needed. There is a main.cpp in the zip file that demonstrates how this is used.