You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ut...@apache.org on 2020/06/03 16:59:23 UTC

[mynewt-mcumgr] branch master updated: cmd/os_mgmt/port/zephyr: zephyr port os enhancement

This is an automated email from the ASF dual-hosted git repository.

utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git


The following commit(s) were added to refs/heads/master by this push:
     new 473f6e6  cmd/os_mgmt/port/zephyr: zephyr port os enhancement
473f6e6 is described below

commit 473f6e6534c1daf72b79a40a23a2bf98bb88faf1
Author: Frank Li <lg...@163.com>
AuthorDate: Fri May 22 23:16:34 2020 +0800

    cmd/os_mgmt/port/zephyr: zephyr port os enhancement
    
    This patch add two new features:
    - show task name
    - show task stack usage
    
    Signed-off-by: Frank Li <lg...@163.com>
---
 cmd/os_mgmt/port/zephyr/src/zephyr_os_mgmt.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/cmd/os_mgmt/port/zephyr/src/zephyr_os_mgmt.c b/cmd/os_mgmt/port/zephyr/src/zephyr_os_mgmt.c
index e6ac44d..75194e9 100644
--- a/cmd/os_mgmt/port/zephyr/src/zephyr_os_mgmt.c
+++ b/cmd/os_mgmt/port/zephyr/src/zephyr_os_mgmt.c
@@ -56,6 +56,9 @@ int
 os_mgmt_impl_task_info(int idx, struct os_mgmt_task_info *out_info)
 {
     const struct k_thread *thread;
+#if defined(CONFIG_INIT_STACKS) && defined(CONFIG_THREAD_STACK_INFO)
+    size_t unused;
+#endif
 
     thread = zephyr_os_mgmt_task_at(idx);
     if (thread == NULL) {
@@ -63,12 +66,26 @@ os_mgmt_impl_task_info(int idx, struct os_mgmt_task_info *out_info)
     }
 
     *out_info = (struct os_mgmt_task_info){ 0 };
+
+#ifdef CONFIG_THREAD_NAME
+    strncpy(out_info->oti_name, thread->name, OS_MGMT_TASK_NAME_LEN-1);
+    out_info->oti_name[OS_MGMT_TASK_NAME_LEN - 1] = '\0';
+#else
     ll_to_s(thread->base.prio, sizeof out_info->oti_name, out_info->oti_name);
+#endif
+
     out_info->oti_prio = thread->base.prio;
     out_info->oti_taskid = idx;
     out_info->oti_state = thread->base.thread_state;
 #ifdef CONFIG_THREAD_STACK_INFO
     out_info->oti_stksize = thread->stack_info.size / 4;
+#ifdef CONFIG_INIT_STACKS
+    if (k_thread_stack_space_get(thread, &unused) == 0) {
+        out_info->oti_stkusage = (thread->stack_info.size - unused) / 4;
+    } else {
+        out_info->oti_stkusage = 0;
+    }
+#endif
 #endif
 
     return 0;