Skip to content

Commit 0f1313a

Browse files
Merge pull request #1 from IontraLLC/kedar/dev
feature: add ISR profiling support
2 parents 7af6c6e + df35910 commit 0f1313a

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Ports/ARM-Cortex-M/ARMv7-M/os_cpu_c.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,10 @@ void OSTaskSwHook (void)
513513
#if OS_CFG_TASK_PROFILE_EN > 0u
514514
ts = OS_TS_GET();
515515
if (OSTCBCurPtr != OSTCBHighRdyPtr) {
516-
OSTCBCurPtr->CyclesDelta = ts - OSTCBCurPtr->CyclesStart;
517-
OSTCBCurPtr->CyclesTotal += (OS_CYCLES)OSTCBCurPtr->CyclesDelta;
516+
if (ts > OSTCBCurPtr->CyclesStart) {
517+
OSTCBCurPtr->CyclesDelta = ts - OSTCBCurPtr->CyclesStart;
518+
OSTCBCurPtr->CyclesTotal += (OS_CYCLES)OSTCBCurPtr->CyclesDelta;
519+
}
518520
}
519521

520522
OSTCBHighRdyPtr->CyclesStart = ts;

Source/os_core.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,18 @@ void OSIntEnter (void)
272272
return; /* Yes */
273273
}
274274

275+
#if OS_CFG_TASK_PROFILE_EN > 0u
276+
if(OSIntNestingCtr==0) {
277+
CPU_TS ts;
278+
279+
ts = OS_TS_GET();
280+
if(ts > OSTCBCurPtr->CyclesStart) {
281+
OSTCBCurPtr->CyclesDelta = ts - OSTCBCurPtr->CyclesStart;
282+
OSTCBCurPtr->CyclesTotal += (OS_CYCLES)OSTCBCurPtr->CyclesDelta;
283+
}
284+
}
285+
#endif
286+
275287
OSIntNestingCtr++; /* Increment ISR nesting level */
276288
}
277289

@@ -339,6 +351,10 @@ void OSIntExit (void)
339351
#endif
340352
#endif
341353

354+
#if OS_CFG_TASK_PROFILE_EN > 0u
355+
OSTCBCurPtr->CyclesStart = OS_TS_GET();
356+
#endif
357+
342358
OSPrioHighRdy = OS_PrioGetHighest(); /* Find highest priority */
343359
#if (OS_CFG_TASK_IDLE_EN > 0u)
344360
OSTCBHighRdyPtr = OSRdyList[OSPrioHighRdy].HeadPtr; /* Get highest priority task ready-to-run */

0 commit comments

Comments
 (0)