Hallo Community Mein Programm besteht aus einem Teil der immer läuft (Interrupt für ADC usw.) und einem Teil der asynchron zum Programm läuft. Nun wollte ich eine Art Task Manager für den µC zu machen, der mir anzeigt wieviel Prozent der Rechenkapazität ausgelastet sind. Dazu habe ich folgenden Code gebaut.
1 | void Performance_Check() |
2 | {
|
3 | performance.counter++; |
4 | if(performance.ind >= 20) |
5 | {
|
6 | if (performance.counter < performance.counter_low) |
7 | performance.counter_low = performance.counter; |
8 | if (performance.counter > performance.counter_high) |
9 | performance.counter_high = performance.counter; |
10 | performance.ind=0; |
11 | performance.counter_low = 65500; |
12 | }
|
13 | }
|
14 | |
15 | // In der Ausgaberoutine dann
|
16 | performance.percentage = 100-((performance.counter_low*100)/performance.counter_high); |
Zur Erklärung performance_check wird in der main while schleife gepollt. performance.ind wird in einer Timer Interrupt Routine erhöht. Funktioniert schonmal ganz gut. Ist es sinnvoll das so zu machen? Die Division frisst Rechenzeit. Wie kann ich hier besser arbeiten? Wie erfasse ich auch noch die "ständigen Lasten" des Systems. mfg Jan