From b3e1507bcff974167a34ca78382ac85b5e66b890 Mon Sep 17 00:00:00 2001 From: shaojinchun Date: Wed, 12 Dec 2018 09:36:39 +0800 Subject: [PATCH] 1 RT_THREAD_CTRL_BIND_CPU define to 4 2 RTM_EXPORT(rt_cpus_lock_status_restore) 3 sync ARCH_CPU_STACK_GROWS_UPWARD in _rt_scheduler_stack_check() --- include/rtdef.h | 2 +- src/cpu.c | 2 +- src/scheduler.c | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/rtdef.h b/include/rtdef.h index 253ec36968..6d5263ef62 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -500,7 +500,7 @@ typedef siginfo_t rt_siginfo_t; #define RT_THREAD_CTRL_CLOSE 0x01 /**< Close thread. */ #define RT_THREAD_CTRL_CHANGE_PRIORITY 0x02 /**< Change thread priority. */ #define RT_THREAD_CTRL_INFO 0x03 /**< Get thread information. */ -#define RT_THREAD_CTRL_BIND_CPU 0x03 /**< Set thread bind cpu. */ +#define RT_THREAD_CTRL_BIND_CPU 0x04 /**< Set thread bind cpu. */ #ifdef RT_USING_SMP diff --git a/src/cpu.c b/src/cpu.c index ef6dce1787..3e2d65dfb9 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -86,6 +86,6 @@ void rt_cpus_lock_status_restore(struct rt_thread *thread) rt_hw_spin_unlock(&_cpus_lock); } } -RTM_EXPORT(rt_post_switch); +RTM_EXPORT(rt_cpus_lock_status_restore); #endif diff --git a/src/scheduler.c b/src/scheduler.c index e177bde6b7..aafa1f4529 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -99,11 +99,19 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread) level = rt_hw_interrupt_disable(); while (level); } +#if defined(ARCH_CPU_STACK_GROWS_UPWARD) + else if ((rt_ubase_t)thread->sp > ((rt_ubase_t)thread->stack_addr + thread->stack_size)) + { + rt_kprintf("warning: %s stack is close to the top of stack address.\n", + thread->name); + } +#else else if ((rt_ubase_t)thread->sp <= ((rt_ubase_t)thread->stack_addr + 32)) { rt_kprintf("warning: %s stack is close to end of stack address.\n", thread->name); } +#endif } #endif