You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by vi...@apache.org on 2019/11/08 01:02:24 UTC
[mynewt-core] branch master updated: kernel/os: count t_run_time in
cpu time ticks
This is an automated email from the ASF dual-hosted git repository.
vipulrahane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 3d0b218 kernel/os: count t_run_time in cpu time ticks
new d57a406 Merge pull request #2089 from vrahane/os_task_run_time_cputime
3d0b218 is described below
commit 3d0b21840008a03d8211467272e97f6015e3fd9d
Author: Vipul Rahane <vr...@gmail.com>
AuthorDate: Thu Nov 7 16:15:31 2019 -0800
kernel/os: count t_run_time in cpu time ticks
- task runtime - t_run_time variable can now be counted in cpu time
ticks if OS_TASK_RUN_TIME_CPUTIME syscfg is set.
---
kernel/os/src/os_sched.c | 11 +++++++++--
kernel/os/syscfg.yml | 5 +++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/kernel/os/src/os_sched.c b/kernel/os/src/os_sched.c
index f1a82be..1a468b2 100644
--- a/kernel/os/src/os_sched.c
+++ b/kernel/os/src/os_sched.c
@@ -74,6 +74,8 @@ err:
void
os_sched_ctx_sw_hook(struct os_task *next_t)
{
+ uint32_t ticks;
+
#if MYNEWT_VAL(OS_CTX_SW_STACK_CHECK)
os_stack_t *top;
int i;
@@ -84,8 +86,13 @@ os_sched_ctx_sw_hook(struct os_task *next_t)
}
#endif
next_t->t_ctx_sw_cnt++;
- g_current_task->t_run_time += g_os_time - g_os_last_ctx_sw_time;
- g_os_last_ctx_sw_time = g_os_time;
+#if MYNEWT_VAL(OS_TASK_RUN_TIME_CPUTIME)
+ ticks = os_cputime_get32();
+#else
+ ticks = g_os_time;
+#endif
+ g_current_task->t_run_time += ticks - g_os_last_ctx_sw_time;
+ g_os_last_ctx_sw_time = ticks;
}
struct os_task *
diff --git a/kernel/os/syscfg.yml b/kernel/os/syscfg.yml
index 746acb0..6d89eec 100644
--- a/kernel/os/syscfg.yml
+++ b/kernel/os/syscfg.yml
@@ -180,6 +180,11 @@ syscfg.defs:
Interval for sanity check on main task. Setting a 0 will disable
sanity check on main task. Value is in milliseconds.
value: 0
+ OS_TASK_RUN_TIME_CPUTIME:
+ description: >
+ If set, run time is measured in cpu time ticks rather than OS time
+ ticks.
+ value: 0
syscfg.vals.OS_DEBUG_MODE:
OS_CRASH_STACKTRACE: 1