samples: subsys: debug: sysview: Adapt k_thread_foreach API

Use k_thread_foreach() API instead of iterating over the
_kernel.threads list.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
This commit is contained in:
Ramakrishna Pallala 2018-05-11 10:26:37 +05:30 committed by Anas Nashif
parent 769c3a8bf2
commit ef4cb15f04

View file

@ -94,27 +94,29 @@ static void send_system_desc(void)
SEGGER_SYSVIEW_SendSysDesc("O=Zephyr");
}
static void sysview_api_send_task(const struct k_thread *thr, void *udata)
{
char name[20];
snprintk(name, sizeof(name), "T%xE%x",
(uintptr_t)thr, (uintptr_t)thr->entry);
/* NOTE: struct k_thread is inside the stack on Zephyr 1.7.
* This is not guaranteed by the API, and is likely to change
* in the future. Hence, StackBase/StackSize are not set here;
* these could be stored as part of the kernel event.
*/
SEGGER_SYSVIEW_SendTaskInfo(&(SEGGER_SYSVIEW_TASKINFO) {
.TaskID = (u32_t)(uintptr_t)thr,
.sName = name,
.Prio = thr->base.prio,
});
}
static void sysview_api_send_task_list(void)
{
struct k_thread *thr;
for (thr = _kernel.threads; thr; thr = thr->next_thread) {
char name[20];
snprintk(name, sizeof(name), "T%xE%x", (uintptr_t)thr,
(uintptr_t)thr->entry);
/* NOTE: struct k_thread is inside the stack on Zephyr 1.7.
* This is not guaranteed by the API, and is likely to change
* in the future. Hence, StackBase/StackSize are not set here;
* these could be stored as part of the kernel event.
*/
SEGGER_SYSVIEW_SendTaskInfo(&(SEGGER_SYSVIEW_TASKINFO) {
.TaskID = (u32_t)(uintptr_t)thr,
.sName = name,
.Prio = thr->base.prio,
});
}
k_thread_foreach(sysview_api_send_task, NULL);
}
static u32_t zephyr_to_sysview(int event_type)