diff options
Diffstat (limited to 'core/cortex-m/task.c')
-rw-r--r-- | core/cortex-m/task.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/core/cortex-m/task.c b/core/cortex-m/task.c index 4d47041e8a..b7aa30c955 100644 --- a/core/cortex-m/task.c +++ b/core/cortex-m/task.c @@ -51,8 +51,12 @@ static const char * const task_names[] = { #ifdef CONFIG_TASK_PROFILING static uint64_t task_start_time; /* Time task scheduling started */ -static uint64_t exc_start_time; /* Time of task->exception transition */ -static uint64_t exc_end_time; /* Time of exception->task transition */ +/* + * We only keep 32-bit values for exception start/end time, to avoid + * accounting errors when we service interrupt when the timer wraps around. + */ +static uint32_t exc_start_time; /* Time of task->exception transition */ +static uint32_t exc_end_time; /* Time of exception->task transition */ static uint64_t exc_total_time; /* Total time in exceptions */ static uint32_t svc_calls; /* Number of service calls */ static uint32_t task_switches; /* Number of times active task changed */ @@ -245,7 +249,7 @@ void svc_handler(int desched, task_id_t resched) task_ *current, *next; #ifdef CONFIG_TASK_PROFILING int exc = get_interrupt_context(); - uint64_t t; + uint32_t t; #endif /* @@ -261,7 +265,7 @@ void svc_handler(int desched, task_id_t resched) * start time explicitly. */ if (exc == 0xb) { - exc_start_time = get_time().val; + exc_start_time = get_time().le.lo; svc_calls++; } #endif @@ -293,7 +297,7 @@ void svc_handler(int desched, task_id_t resched) #ifdef CONFIG_TASK_PROFILING /* Track time in interrupts */ - t = get_time().val; + t = get_time().le.lo; exc_total_time += (t - exc_start_time); /* @@ -337,7 +341,7 @@ void __keep task_start_irq_handler(void *excep_return) * Get time before checking depth, in case this handler is * pre-empted. */ - uint64_t t = get_time().val; + uint32_t t = get_time().le.lo; int irq = get_interrupt_context() - 16; /* @@ -715,7 +719,10 @@ void task_clear_fp_used(void) int task_start(void) { #ifdef CONFIG_TASK_PROFILING - task_start_time = exc_end_time = get_time().val; + timestamp_t t = get_time(); + + task_start_time = t.val; + exc_end_time = t.le.lo; #endif start_called = 1; |