From 05b9eb0b826b49bed40cb9f39da2691a7b46a4a2 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Mon, 12 Aug 2013 07:21:29 -0700 Subject: [PATCH 1/2] remove compiling warning --- components/pthreads/mqueue.c | 1 + components/pthreads/semaphore.c | 1 + 2 files changed, 2 insertions(+) diff --git a/components/pthreads/mqueue.c b/components/pthreads/mqueue.c index 8886988a1f..7b669dc367 100644 --- a/components/pthreads/mqueue.c +++ b/components/pthreads/mqueue.c @@ -21,6 +21,7 @@ * Date Author Notes */ +#include #include "mqueue.h" #include "pthread_internal.h" diff --git a/components/pthreads/semaphore.c b/components/pthreads/semaphore.c index a1bf42e899..ae69e0d1bc 100644 --- a/components/pthreads/semaphore.c +++ b/components/pthreads/semaphore.c @@ -23,6 +23,7 @@ */ #include +#include #include "semaphore.h" #include "pthread_internal.h" From ad17bc29087ae699071711ce4d780458879d6367 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Mon, 19 Aug 2013 10:08:11 +0800 Subject: [PATCH 2/2] fix debug output of scheduler When print the thread names, we should use "%.*s" instead of bare "%s". --- src/scheduler.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/scheduler.c b/src/scheduler.c index 4889083f0a..cefc5b8c41 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -226,10 +226,12 @@ void rt_schedule(void) /* switch to new thread */ RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, - ("[%d]switch to priority#%d thread:%s\n", - rt_interrupt_nest, - highest_ready_priority, - to_thread->name)); + ("[%d]switch to priority#%d " + "thread:%.*s(sp:0x%p), " + "from thread:%.*s(sp: 0x%p)\n", + rt_interrupt_nest, highest_ready_priority, + RT_NAME_MAX, to_thread->name, to_thread->sp, + RT_NAME_MAX, from_thread->name, from_thread->sp)); #ifdef RT_USING_OVERFLOW_CHECK _rt_scheduler_stack_check(to_thread); @@ -279,11 +281,12 @@ void rt_schedule_insert_thread(struct rt_thread *thread) /* set priority mask */ #if RT_THREAD_PRIORITY_MAX <= 32 - RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("insert thread[%s], the priority: %d\n", - thread->name, thread->current_priority)); + RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("insert thread[%.*s], the priority: %d\n", + RT_NAME_MAX, thread->name, thread->current_priority)); #else RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, - ("insert thread[%s], the priority: %d 0x%x %d\n", + ("insert thread[%.*s], the priority: %d 0x%x %d\n", + RT_NAME_MAX, thread->name, thread->number, thread->number_mask, @@ -316,11 +319,13 @@ void rt_schedule_remove_thread(struct rt_thread *thread) temp = rt_hw_interrupt_disable(); #if RT_THREAD_PRIORITY_MAX <= 32 - RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("remove thread[%s], the priority: %d\n", - thread->name, thread->current_priority)); + RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("remove thread[%.*s], the priority: %d\n", + RT_NAME_MAX, thread->name, + thread->current_priority)); #else RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, - ("remove thread[%s], the priority: %d 0x%x %d\n", + ("remove thread[%.*s], the priority: %d 0x%x %d\n", + RT_NAME_MAX, thread->name, thread->number, thread->number_mask,