|
@@ -86,66 +86,6 @@ void rt_scheduler_switch_sethook(void (*hook)(struct rt_thread *tid))
|
|
/**@}*/
|
|
/**@}*/
|
|
#endif /* RT_USING_HOOK */
|
|
#endif /* RT_USING_HOOK */
|
|
|
|
|
|
-#ifdef RT_USING_OVERFLOW_CHECK
|
|
|
|
-static void _scheduler_stack_check(struct rt_thread *thread)
|
|
|
|
-{
|
|
|
|
- RT_ASSERT(thread != RT_NULL);
|
|
|
|
-
|
|
|
|
-#ifdef RT_USING_SMART
|
|
|
|
-#ifndef ARCH_MM_MMU
|
|
|
|
- struct rt_lwp *lwp = thread ? (struct rt_lwp *)thread->lwp : 0;
|
|
|
|
-
|
|
|
|
- /* if stack pointer locate in user data section skip stack check. */
|
|
|
|
- if (lwp && ((rt_uint32_t)thread->sp > (rt_uint32_t)lwp->data_entry &&
|
|
|
|
- (rt_uint32_t)thread->sp <= (rt_uint32_t)lwp->data_entry + (rt_uint32_t)lwp->data_size))
|
|
|
|
- {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-#endif /* not defined ARCH_MM_MMU */
|
|
|
|
-#endif /* RT_USING_SMART */
|
|
|
|
-
|
|
|
|
-#ifndef RT_USING_HW_STACK_GUARD
|
|
|
|
-#ifdef ARCH_CPU_STACK_GROWS_UPWARD
|
|
|
|
- if (*((rt_uint8_t *)((rt_ubase_t)thread->stack_addr + thread->stack_size - 1)) != '#' ||
|
|
|
|
-#else
|
|
|
|
- if (*((rt_uint8_t *)thread->stack_addr) != '#' ||
|
|
|
|
-#endif /* ARCH_CPU_STACK_GROWS_UPWARD */
|
|
|
|
- (rt_ubase_t)thread->sp <= (rt_ubase_t)thread->stack_addr ||
|
|
|
|
- (rt_ubase_t)thread->sp >
|
|
|
|
- (rt_ubase_t)thread->stack_addr + (rt_ubase_t)thread->stack_size)
|
|
|
|
- {
|
|
|
|
- rt_base_t level;
|
|
|
|
-
|
|
|
|
- rt_kprintf("thread:%s stack overflow\n", thread->parent.name);
|
|
|
|
-
|
|
|
|
- level = rt_hw_interrupt_disable();
|
|
|
|
- while (level);
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
-#ifdef ARCH_CPU_STACK_GROWS_UPWARD
|
|
|
|
-#ifndef RT_USING_HW_STACK_GUARD
|
|
|
|
- else if ((rt_ubase_t)thread->sp > ((rt_ubase_t)thread->stack_addr + thread->stack_size))
|
|
|
|
-#else
|
|
|
|
- if ((rt_ubase_t)thread->sp > ((rt_ubase_t)thread->stack_addr + thread->stack_size))
|
|
|
|
-#endif
|
|
|
|
- {
|
|
|
|
- rt_kprintf("warning: %s stack is close to the top of stack address.\n",
|
|
|
|
- thread->parent.name);
|
|
|
|
- }
|
|
|
|
-#else
|
|
|
|
-#ifndef RT_USING_HW_STACK_GUARD
|
|
|
|
- else if ((rt_ubase_t)thread->sp <= ((rt_ubase_t)thread->stack_addr + 32))
|
|
|
|
-#else
|
|
|
|
- if ((rt_ubase_t)thread->sp <= ((rt_ubase_t)thread->stack_addr + 32))
|
|
|
|
-#endif
|
|
|
|
- {
|
|
|
|
- rt_kprintf("warning: %s stack is close to end of stack address.\n",
|
|
|
|
- thread->parent.name);
|
|
|
|
- }
|
|
|
|
-#endif /* ARCH_CPU_STACK_GROWS_UPWARD */
|
|
|
|
-}
|
|
|
|
-#endif /* RT_USING_OVERFLOW_CHECK */
|
|
|
|
-
|
|
|
|
static struct rt_thread* _scheduler_get_highest_priority_thread(rt_ubase_t *highest_prio)
|
|
static struct rt_thread* _scheduler_get_highest_priority_thread(rt_ubase_t *highest_prio)
|
|
{
|
|
{
|
|
struct rt_thread *highest_priority_thread;
|
|
struct rt_thread *highest_priority_thread;
|
|
@@ -325,9 +265,7 @@ void rt_schedule(void)
|
|
RT_NAME_MAX, to_thread->parent.name, to_thread->sp,
|
|
RT_NAME_MAX, to_thread->parent.name, to_thread->sp,
|
|
RT_NAME_MAX, from_thread->parent.name, from_thread->sp);
|
|
RT_NAME_MAX, from_thread->parent.name, from_thread->sp);
|
|
|
|
|
|
-#ifdef RT_USING_OVERFLOW_CHECK
|
|
|
|
- _scheduler_stack_check(to_thread);
|
|
|
|
-#endif /* RT_USING_OVERFLOW_CHECK */
|
|
|
|
|
|
+ RT_SCHEDULER_STACK_CHECK(to_thread);
|
|
|
|
|
|
if (rt_interrupt_nest == 0)
|
|
if (rt_interrupt_nest == 0)
|
|
{
|
|
{
|