Skip to main content
V.H
Senior
November 12, 2021
Solved

Question about the processor load

  • November 12, 2021
  • 1 reply
  • 612 views

Hello,

Is there can do processor load display without operating system ?

This topic has been closed for replies.
Best answer by Danish1

Without an operating-system or other tasking techniques, your processor is either doing things or in-a-tight-loop waiting for more things to do.

A "bare metal" approach to showing processor load would be to light an LED when the processor starts this waiting loop, and turns it off as soon as it has found something to do.

More advanced techniques are possible. Something I often do is "profile" my code, where I have a timer interrupt. Inside the interrupt-service-routine, I examine the return address to know where the processor was interrupted from and store that. (To save RAM I typically have 256 "bins" or address-ranges, and add 1 to the appropriate bin). Once I've run the code long enough to get something representative, I can then log the results.

This way I can know not only what portion of time the processor is executing at-or-near the idle routine, but also what portion of time it spends in other routines so I can know which routines are worth my effort optimising, and which ones use so little cpu time that it's not worth trying.

Hope this helps,

Danish

1 reply

Danish1
Danish1Best answer
Lead III
November 12, 2021

Without an operating-system or other tasking techniques, your processor is either doing things or in-a-tight-loop waiting for more things to do.

A "bare metal" approach to showing processor load would be to light an LED when the processor starts this waiting loop, and turns it off as soon as it has found something to do.

More advanced techniques are possible. Something I often do is "profile" my code, where I have a timer interrupt. Inside the interrupt-service-routine, I examine the return address to know where the processor was interrupted from and store that. (To save RAM I typically have 256 "bins" or address-ranges, and add 1 to the appropriate bin). Once I've run the code long enough to get something representative, I can then log the results.

This way I can know not only what portion of time the processor is executing at-or-near the idle routine, but also what portion of time it spends in other routines so I can know which routines are worth my effort optimising, and which ones use so little cpu time that it's not worth trying.

Hope this helps,

Danish