提交 ff658411 编写于 作者: D dzzxzz@gmail.com

fixed coding style in src/scheduler.c

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2526 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 dec45642
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
* 2006-03-17 Bernard the first version * 2006-03-17 Bernard the first version
* 2006-04-28 Bernard fix the scheduler algorthm * 2006-04-28 Bernard fix the scheduler algorthm
* 2006-04-30 Bernard add SCHEDULER_DEBUG * 2006-04-30 Bernard add SCHEDULER_DEBUG
* 2006-05-27 Bernard fix the scheduler algorthm for same priority thread * 2006-05-27 Bernard fix the scheduler algorthm for same priority
* schedule * thread schedule
* 2006-06-04 Bernard rewrite the scheduler algorithm * 2006-06-04 Bernard rewrite the scheduler algorithm
* 2006-08-03 Bernard add hook support * 2006-08-03 Bernard add hook support
* 2006-09-05 Bernard add 32 priority level support * 2006-09-05 Bernard add 32 priority level support
...@@ -83,7 +83,8 @@ static void (*rt_scheduler_hook)(struct rt_thread *from, struct rt_thread *to); ...@@ -83,7 +83,8 @@ static void (*rt_scheduler_hook)(struct rt_thread *from, struct rt_thread *to);
* *
* @param hook the hook function * @param hook the hook function
*/ */
void rt_scheduler_sethook(void (*hook)(struct rt_thread *from, struct rt_thread *to)) void
rt_scheduler_sethook(void (*hook)(struct rt_thread *from, struct rt_thread *to))
{ {
rt_scheduler_hook = hook; rt_scheduler_hook = hook;
} }
...@@ -114,7 +115,8 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread) ...@@ -114,7 +115,8 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread)
} }
else if ((rt_uint32_t)thread->sp <= ((rt_uint32_t)thread->stack_addr + 32)) else if ((rt_uint32_t)thread->sp <= ((rt_uint32_t)thread->stack_addr + 32))
{ {
rt_kprintf("warning: %s stack is close to end of stack address.\n", thread->name); rt_kprintf("warning: %s stack is close to end of stack address.\n",
thread->name);
} }
} }
#endif #endif
...@@ -185,7 +187,8 @@ void rt_system_scheduler_start(void) ...@@ -185,7 +187,8 @@ void rt_system_scheduler_start(void)
} }
#if RT_THREAD_PRIORITY_MAX > 32 #if RT_THREAD_PRIORITY_MAX > 32
highest_ready_priority = (number << 3) + rt_lowest_bitmap[rt_thread_ready_table[number]]; highest_ready_priority = (number << 3) +
rt_lowest_bitmap[rt_thread_ready_table[number]];
#else #else
highest_ready_priority = number; highest_ready_priority = number;
#endif #endif
...@@ -193,7 +196,8 @@ void rt_system_scheduler_start(void) ...@@ -193,7 +196,8 @@ void rt_system_scheduler_start(void)
/* get switch to thread */ /* get switch to thread */
to_thread = rt_list_entry(rt_thread_priority_table[highest_ready_priority].next, to_thread = rt_list_entry(rt_thread_priority_table[highest_ready_priority].next,
struct rt_thread, tlist); struct rt_thread,
tlist);
rt_current_thread = to_thread; rt_current_thread = to_thread;
...@@ -250,14 +254,16 @@ void rt_schedule(void) ...@@ -250,14 +254,16 @@ void rt_schedule(void)
} }
#if RT_THREAD_PRIORITY_MAX > 32 #if RT_THREAD_PRIORITY_MAX > 32
highest_ready_priority = (number << 3) + rt_lowest_bitmap[rt_thread_ready_table[number]]; highest_ready_priority = (number << 3) +
rt_lowest_bitmap[rt_thread_ready_table[number]];
#else #else
highest_ready_priority = number; highest_ready_priority = number;
#endif #endif
#endif #endif
/* get switch to thread */ /* get switch to thread */
to_thread = rt_list_entry(rt_thread_priority_table[highest_ready_priority].next, to_thread = rt_list_entry(rt_thread_priority_table[highest_ready_priority].next,
struct rt_thread, tlist); struct rt_thread,
tlist);
/* if the destination thread is not the same as current thread */ /* if the destination thread is not the same as current thread */
if (to_thread != rt_current_thread) if (to_thread != rt_current_thread)
...@@ -281,13 +287,15 @@ void rt_schedule(void) ...@@ -281,13 +287,15 @@ void rt_schedule(void)
if (rt_interrupt_nest == 0) if (rt_interrupt_nest == 0)
{ {
rt_hw_context_switch((rt_uint32_t)&from_thread->sp, (rt_uint32_t)&to_thread->sp); rt_hw_context_switch((rt_uint32_t)&from_thread->sp,
(rt_uint32_t)&to_thread->sp);
} }
else else
{ {
RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("switch in interrupt\n")); RT_DEBUG_LOG(RT_DEBUG_SCHEDULER, ("switch in interrupt\n"));
rt_hw_context_switch_interrupt((rt_uint32_t)&from_thread->sp, (rt_uint32_t)&to_thread->sp); rt_hw_context_switch_interrupt((rt_uint32_t)&from_thread->sp,
(rt_uint32_t)&to_thread->sp);
} }
} }
} }
...@@ -316,7 +324,8 @@ void rt_schedule_insert_thread(struct rt_thread *thread) ...@@ -316,7 +324,8 @@ void rt_schedule_insert_thread(struct rt_thread *thread)
thread->stat = RT_THREAD_READY; thread->stat = RT_THREAD_READY;
/* insert thread to ready list */ /* insert thread to ready list */
rt_list_insert_before(&(rt_thread_priority_table[thread->current_priority]), &(thread->tlist)); rt_list_insert_before(&(rt_thread_priority_table[thread->current_priority]),
&(thread->tlist));
/* set priority mask */ /* set priority mask */
#if RT_THREAD_PRIORITY_MAX <= 32 #if RT_THREAD_PRIORITY_MAX <= 32
...@@ -397,8 +406,10 @@ void rt_enter_critical(void) ...@@ -397,8 +406,10 @@ void rt_enter_critical(void)
/* disable interrupt */ /* disable interrupt */
level = rt_hw_interrupt_disable(); level = rt_hw_interrupt_disable();
/* the maximal number of nest is RT_UINT16_MAX, which is big /*
* enough and does not check here */ * the maximal number of nest is RT_UINT16_MAX, which is big
* enough and does not check here
*/
rt_scheduler_lock_nest ++; rt_scheduler_lock_nest ++;
/* enable interrupt */ /* enable interrupt */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册