

Calculate processor usage
#1
Posted 14 September 2010 - 03:48 PM

Take a seat, I'll be right with you.
#2
Posted 14 September 2010 - 04:23 PM
#3
Posted 14 September 2010 - 07:02 PM
Good question. You would think a while(true) loop would mean 100% CPU utilitzation and therefore higher power usage. Is that the case?[snip!]
I was wondering if there is a way to see how busy the CPU is. In the normal world, if you wrote a programme that had While(true){} and waited inside it for an event, you'd be shot (in most cases).
[/snip!]
#4
Posted 14 September 2010 - 07:42 PM
Good question. You would think a while(true) loop would mean 100% CPU utilitzation and therefore higher power usage. Is that the case?
That is the case. Using event handlers and background threads with Sleep(...) timers is "best practice" for .NET Micro Framework and can save you power in many cases. A while(true) loop without any sleeps in it would be keeping the processor plenty busy (up to 100%).
Chris
#5
Posted 14 September 2010 - 07:43 PM
#6
Posted 14 September 2010 - 07:50 PM
I don't know how NETMF handles while loops, but I do know they aren't a good idea. If you have to loop endlessly, you are suppose to use timers.
I don't know how smart NETMF is in handling stuff like that, though.
It's a pretty cool paradigm shift... In traditional embedded programming, while loops are very common. But with .NET Micro Framework, you get the power of richer features: timers, threads, event handlers, etc.
I'd generally avoid using infinite while loops in .NET MF code. But they're great when you're starting out ("blinky" for example).
Chris
#7
Posted 14 September 2010 - 09:30 PM

Take a seat, I'll be right with you.
#8
Posted 15 September 2010 - 03:21 AM
I'd generally avoid using infinite while loops in .NET MF code. But they're great when you're starting out ("blinky" for example).
Chris
Chris,
Two questions,
First question, in my embedded experience with Microchip 8bit PIC's and from what I have seen and done, generally you do have infinite loops that keep the processor going in loops (not including interrupts) because the processor is completing a relatively simple task over and over again forever. While I would prefer that the Netduino doesn't do this so certain items can be garbage collected if need be, I'm not sure I can accomplish this without an infinite loop. How do you get around this?
Second question, what is the recommended minimun resolution for an ExtendedTimer in the .net micro framework for the Netduino? I know for most versions of Windows a timer event resolution is only good for about 55ms. Is there a way to reliably calculate the minimum resolution on a Netduino?
Thanks.---AJB
#9
Posted 15 September 2010 - 04:26 AM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users