From 495246d2d4a3d474d736a325dec5754ef297ac09 Mon Sep 17 00:00:00 2001 From: Christian Mehlis Date: Thu, 17 Oct 2013 15:25:43 +0200 Subject: [PATCH] add thread_getname function --- core/include/thread.h | 6 ++++++ core/thread.c | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/core/include/thread.h b/core/include/thread.h index 46716cbad0..064aefb344 100644 --- a/core/include/thread.h +++ b/core/include/thread.h @@ -45,6 +45,12 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void (*f */ unsigned int thread_getstatus(int pid); +/** + * @brief returns the name of a process. + * @return NULL if pid is unknown + */ +const char *thread_getname(int pid); + /** * @brief Puts the current thread into sleep mode. Has to be woken up externally. */ diff --git a/core/thread.c b/core/thread.c index 90424cb708..bce3573943 100644 --- a/core/thread.c +++ b/core/thread.c @@ -47,6 +47,15 @@ unsigned int thread_getstatus(int pid) return sched_threads[pid]->status; } +const char *thread_getname(int pid) +{ + if (sched_threads[pid] == NULL) { + return NULL; + } + + return sched_threads[pid]->name; +} + void thread_sleep() { if (inISR()) {